{ "version": 3, "sources": ["../node_modules/events/events.js", "../src/subscription.ts", "../src/types.ts", "../src/utils.ts", "../src/transport_sockjs.ts", "../src/transport_websocket.ts", "../src/transport_http_stream.ts", "../src/transport_sse.ts", "../src/transport_webtransport.ts", "../src/fossil.ts", "../src/json.ts", "../src/centrifuge.ts", "../src/browser.ts"], "sourcesContent": ["// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n'use strict';\n\nvar R = typeof Reflect === 'object' ? Reflect : null\nvar ReflectApply = R && typeof R.apply === 'function'\n ? R.apply\n : function ReflectApply(target, receiver, args) {\n return Function.prototype.apply.call(target, receiver, args);\n }\n\nvar ReflectOwnKeys\nif (R && typeof R.ownKeys === 'function') {\n ReflectOwnKeys = R.ownKeys\n} else if (Object.getOwnPropertySymbols) {\n ReflectOwnKeys = function ReflectOwnKeys(target) {\n return Object.getOwnPropertyNames(target)\n .concat(Object.getOwnPropertySymbols(target));\n };\n} else {\n ReflectOwnKeys = function ReflectOwnKeys(target) {\n return Object.getOwnPropertyNames(target);\n };\n}\n\nfunction ProcessEmitWarning(warning) {\n if (console && console.warn) console.warn(warning);\n}\n\nvar NumberIsNaN = Number.isNaN || function NumberIsNaN(value) {\n return value !== value;\n}\n\nfunction EventEmitter() {\n EventEmitter.init.call(this);\n}\nmodule.exports = EventEmitter;\nmodule.exports.once = once;\n\n// Backwards-compat with node 0.10.x\nEventEmitter.EventEmitter = EventEmitter;\n\nEventEmitter.prototype._events = undefined;\nEventEmitter.prototype._eventsCount = 0;\nEventEmitter.prototype._maxListeners = undefined;\n\n// By default EventEmitters will print a warning if more than 10 listeners are\n// added to it. This is a useful default which helps finding memory leaks.\nvar defaultMaxListeners = 10;\n\nfunction checkListener(listener) {\n if (typeof listener !== 'function') {\n throw new TypeError('The \"listener\" argument must be of type Function. Received type ' + typeof listener);\n }\n}\n\nObject.defineProperty(EventEmitter, 'defaultMaxListeners', {\n enumerable: true,\n get: function() {\n return defaultMaxListeners;\n },\n set: function(arg) {\n if (typeof arg !== 'number' || arg < 0 || NumberIsNaN(arg)) {\n throw new RangeError('The value of \"defaultMaxListeners\" is out of range. It must be a non-negative number. Received ' + arg + '.');\n }\n defaultMaxListeners = arg;\n }\n});\n\nEventEmitter.init = function() {\n\n if (this._events === undefined ||\n this._events === Object.getPrototypeOf(this)._events) {\n this._events = Object.create(null);\n this._eventsCount = 0;\n }\n\n this._maxListeners = this._maxListeners || undefined;\n};\n\n// Obviously not all Emitters should be limited to 10. This function allows\n// that to be increased. Set to zero for unlimited.\nEventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {\n if (typeof n !== 'number' || n < 0 || NumberIsNaN(n)) {\n throw new RangeError('The value of \"n\" is out of range. It must be a non-negative number. Received ' + n + '.');\n }\n this._maxListeners = n;\n return this;\n};\n\nfunction _getMaxListeners(that) {\n if (that._maxListeners === undefined)\n return EventEmitter.defaultMaxListeners;\n return that._maxListeners;\n}\n\nEventEmitter.prototype.getMaxListeners = function getMaxListeners() {\n return _getMaxListeners(this);\n};\n\nEventEmitter.prototype.emit = function emit(type) {\n var args = [];\n for (var i = 1; i < arguments.length; i++) args.push(arguments[i]);\n var doError = (type === 'error');\n\n var events = this._events;\n if (events !== undefined)\n doError = (doError && events.error === undefined);\n else if (!doError)\n return false;\n\n // If there is no 'error' event listener then throw.\n if (doError) {\n var er;\n if (args.length > 0)\n er = args[0];\n if (er instanceof Error) {\n // Note: The comments on the `throw` lines are intentional, they show\n // up in Node's output if this results in an unhandled exception.\n throw er; // Unhandled 'error' event\n }\n // At least give some kind of context to the user\n var err = new Error('Unhandled error.' + (er ? ' (' + er.message + ')' : ''));\n err.context = er;\n throw err; // Unhandled 'error' event\n }\n\n var handler = events[type];\n\n if (handler === undefined)\n return false;\n\n if (typeof handler === 'function') {\n ReflectApply(handler, this, args);\n } else {\n var len = handler.length;\n var listeners = arrayClone(handler, len);\n for (var i = 0; i < len; ++i)\n ReflectApply(listeners[i], this, args);\n }\n\n return true;\n};\n\nfunction _addListener(target, type, listener, prepend) {\n var m;\n var events;\n var existing;\n\n checkListener(listener);\n\n events = target._events;\n if (events === undefined) {\n events = target._events = Object.create(null);\n target._eventsCount = 0;\n } else {\n // To avoid recursion in the case that type === \"newListener\"! Before\n // adding it to the listeners, first emit \"newListener\".\n if (events.newListener !== undefined) {\n target.emit('newListener', type,\n listener.listener ? listener.listener : listener);\n\n // Re-assign `events` because a newListener handler could have caused the\n // this._events to be assigned to a new object\n events = target._events;\n }\n existing = events[type];\n }\n\n if (existing === undefined) {\n // Optimize the case of one listener. Don't need the extra array object.\n existing = events[type] = listener;\n ++target._eventsCount;\n } else {\n if (typeof existing === 'function') {\n // Adding the second element, need to change to array.\n existing = events[type] =\n prepend ? [listener, existing] : [existing, listener];\n // If we've already got an array, just append.\n } else if (prepend) {\n existing.unshift(listener);\n } else {\n existing.push(listener);\n }\n\n // Check for listener leak\n m = _getMaxListeners(target);\n if (m > 0 && existing.length > m && !existing.warned) {\n existing.warned = true;\n // No error code for this since it is a Warning\n // eslint-disable-next-line no-restricted-syntax\n var w = new Error('Possible EventEmitter memory leak detected. ' +\n existing.length + ' ' + String(type) + ' listeners ' +\n 'added. Use emitter.setMaxListeners() to ' +\n 'increase limit');\n w.name = 'MaxListenersExceededWarning';\n w.emitter = target;\n w.type = type;\n w.count = existing.length;\n ProcessEmitWarning(w);\n }\n }\n\n return target;\n}\n\nEventEmitter.prototype.addListener = function addListener(type, listener) {\n return _addListener(this, type, listener, false);\n};\n\nEventEmitter.prototype.on = EventEmitter.prototype.addListener;\n\nEventEmitter.prototype.prependListener =\n function prependListener(type, listener) {\n return _addListener(this, type, listener, true);\n };\n\nfunction onceWrapper() {\n if (!this.fired) {\n this.target.removeListener(this.type, this.wrapFn);\n this.fired = true;\n if (arguments.length === 0)\n return this.listener.call(this.target);\n return this.listener.apply(this.target, arguments);\n }\n}\n\nfunction _onceWrap(target, type, listener) {\n var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener };\n var wrapped = onceWrapper.bind(state);\n wrapped.listener = listener;\n state.wrapFn = wrapped;\n return wrapped;\n}\n\nEventEmitter.prototype.once = function once(type, listener) {\n checkListener(listener);\n this.on(type, _onceWrap(this, type, listener));\n return this;\n};\n\nEventEmitter.prototype.prependOnceListener =\n function prependOnceListener(type, listener) {\n checkListener(listener);\n this.prependListener(type, _onceWrap(this, type, listener));\n return this;\n };\n\n// Emits a 'removeListener' event if and only if the listener was removed.\nEventEmitter.prototype.removeListener =\n function removeListener(type, listener) {\n var list, events, position, i, originalListener;\n\n checkListener(listener);\n\n events = this._events;\n if (events === undefined)\n return this;\n\n list = events[type];\n if (list === undefined)\n return this;\n\n if (list === listener || list.listener === listener) {\n if (--this._eventsCount === 0)\n this._events = Object.create(null);\n else {\n delete events[type];\n if (events.removeListener)\n this.emit('removeListener', type, list.listener || listener);\n }\n } else if (typeof list !== 'function') {\n position = -1;\n\n for (i = list.length - 1; i >= 0; i--) {\n if (list[i] === listener || list[i].listener === listener) {\n originalListener = list[i].listener;\n position = i;\n break;\n }\n }\n\n if (position < 0)\n return this;\n\n if (position === 0)\n list.shift();\n else {\n spliceOne(list, position);\n }\n\n if (list.length === 1)\n events[type] = list[0];\n\n if (events.removeListener !== undefined)\n this.emit('removeListener', type, originalListener || listener);\n }\n\n return this;\n };\n\nEventEmitter.prototype.off = EventEmitter.prototype.removeListener;\n\nEventEmitter.prototype.removeAllListeners =\n function removeAllListeners(type) {\n var listeners, events, i;\n\n events = this._events;\n if (events === undefined)\n return this;\n\n // not listening for removeListener, no need to emit\n if (events.removeListener === undefined) {\n if (arguments.length === 0) {\n this._events = Object.create(null);\n this._eventsCount = 0;\n } else if (events[type] !== undefined) {\n if (--this._eventsCount === 0)\n this._events = Object.create(null);\n else\n delete events[type];\n }\n return this;\n }\n\n // emit removeListener for all listeners on all events\n if (arguments.length === 0) {\n var keys = Object.keys(events);\n var key;\n for (i = 0; i < keys.length; ++i) {\n key = keys[i];\n if (key === 'removeListener') continue;\n this.removeAllListeners(key);\n }\n this.removeAllListeners('removeListener');\n this._events = Object.create(null);\n this._eventsCount = 0;\n return this;\n }\n\n listeners = events[type];\n\n if (typeof listeners === 'function') {\n this.removeListener(type, listeners);\n } else if (listeners !== undefined) {\n // LIFO order\n for (i = listeners.length - 1; i >= 0; i--) {\n this.removeListener(type, listeners[i]);\n }\n }\n\n return this;\n };\n\nfunction _listeners(target, type, unwrap) {\n var events = target._events;\n\n if (events === undefined)\n return [];\n\n var evlistener = events[type];\n if (evlistener === undefined)\n return [];\n\n if (typeof evlistener === 'function')\n return unwrap ? [evlistener.listener || evlistener] : [evlistener];\n\n return unwrap ?\n unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);\n}\n\nEventEmitter.prototype.listeners = function listeners(type) {\n return _listeners(this, type, true);\n};\n\nEventEmitter.prototype.rawListeners = function rawListeners(type) {\n return _listeners(this, type, false);\n};\n\nEventEmitter.listenerCount = function(emitter, type) {\n if (typeof emitter.listenerCount === 'function') {\n return emitter.listenerCount(type);\n } else {\n return listenerCount.call(emitter, type);\n }\n};\n\nEventEmitter.prototype.listenerCount = listenerCount;\nfunction listenerCount(type) {\n var events = this._events;\n\n if (events !== undefined) {\n var evlistener = events[type];\n\n if (typeof evlistener === 'function') {\n return 1;\n } else if (evlistener !== undefined) {\n return evlistener.length;\n }\n }\n\n return 0;\n}\n\nEventEmitter.prototype.eventNames = function eventNames() {\n return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : [];\n};\n\nfunction arrayClone(arr, n) {\n var copy = new Array(n);\n for (var i = 0; i < n; ++i)\n copy[i] = arr[i];\n return copy;\n}\n\nfunction spliceOne(list, index) {\n for (; index + 1 < list.length; index++)\n list[index] = list[index + 1];\n list.pop();\n}\n\nfunction unwrapListeners(arr) {\n var ret = new Array(arr.length);\n for (var i = 0; i < ret.length; ++i) {\n ret[i] = arr[i].listener || arr[i];\n }\n return ret;\n}\n\nfunction once(emitter, name) {\n return new Promise(function (resolve, reject) {\n function errorListener(err) {\n emitter.removeListener(name, resolver);\n reject(err);\n }\n\n function resolver() {\n if (typeof emitter.removeListener === 'function') {\n emitter.removeListener('error', errorListener);\n }\n resolve([].slice.call(arguments));\n };\n\n eventTargetAgnosticAddListener(emitter, name, resolver, { once: true });\n if (name !== 'error') {\n addErrorHandlerIfEventEmitter(emitter, errorListener, { once: true });\n }\n });\n}\n\nfunction addErrorHandlerIfEventEmitter(emitter, handler, flags) {\n if (typeof emitter.on === 'function') {\n eventTargetAgnosticAddListener(emitter, 'error', handler, flags);\n }\n}\n\nfunction eventTargetAgnosticAddListener(emitter, name, listener, flags) {\n if (typeof emitter.on === 'function') {\n if (flags.once) {\n emitter.once(name, listener);\n } else {\n emitter.on(name, listener);\n }\n } else if (typeof emitter.addEventListener === 'function') {\n // EventTarget does not have `error` event semantics like Node\n // EventEmitters, we do not listen for `error` events here.\n emitter.addEventListener(name, function wrapListener(arg) {\n // IE does not have builtin `{ once: true }` support so we\n // have to do it manually.\n if (flags.once) {\n emitter.removeEventListener(name, wrapListener);\n }\n listener(arg);\n });\n } else {\n throw new TypeError('The \"emitter\" argument must be of type EventEmitter. Received type ' + typeof emitter);\n }\n}\n", "import EventEmitter from 'events';\nimport { Centrifuge, UnauthorizedError } from './centrifuge';\nimport { errorCodes, unsubscribedCodes, subscribingCodes, connectingCodes } from './codes';\nimport {\n HistoryOptions, HistoryResult, PresenceResult, PresenceStatsResult,\n PublishResult, State, SubscriptionEvents, SubscriptionOptions,\n SubscriptionState, SubscriptionTokenContext, TypedEventEmitter,\n SubscriptionDataContext\n} from './types';\nimport { ttlMilliseconds, backoff } from './utils';\n\n/** Subscription to a channel */\nexport class Subscription extends (EventEmitter as new () => TypedEventEmitter) {\n channel: string;\n state: SubscriptionState;\n\n private _centrifuge: Centrifuge;\n private _promises: Record;\n private _resubscribeTimeout?: null | ReturnType = null;\n private _refreshTimeout?: null | ReturnType = null;\n private _getToken: null | ((ctx: SubscriptionTokenContext) => Promise);\n private _minResubscribeDelay: number;\n private _maxResubscribeDelay: number;\n private _recover: boolean;\n private _offset: number | null;\n private _epoch: string | null;\n private _resubscribeAttempts: number;\n private _promiseId: number;\n private _delta: string;\n private _delta_negotiated: boolean;\n private _token: string;\n private _data: any | null;\n private _getData: null | ((ctx: SubscriptionDataContext) => Promise);\n private _recoverable: boolean;\n private _positioned: boolean;\n private _joinLeave: boolean;\n // @ts-ignore \u2013 this is used by a client in centrifuge.ts.\n private _inflight: boolean;\n private _prevValue: any;\n private _unsubPromise: any;\n\n /** Subscription constructor should not be used directly, create subscriptions using Client method. */\n constructor(centrifuge: Centrifuge, channel: string, options?: Partial) {\n super();\n this.channel = channel;\n this.state = SubscriptionState.Unsubscribed;\n this._centrifuge = centrifuge;\n this._token = '';\n this._getToken = null;\n this._data = null;\n this._getData = null;\n this._recover = false;\n this._offset = null;\n this._epoch = null;\n this._recoverable = false;\n this._positioned = false;\n this._joinLeave = false;\n this._minResubscribeDelay = 500;\n this._maxResubscribeDelay = 20000;\n this._resubscribeTimeout = null;\n this._resubscribeAttempts = 0;\n this._promises = {};\n this._promiseId = 0;\n this._inflight = false;\n this._refreshTimeout = null;\n this._delta = '';\n this._delta_negotiated = false;\n this._prevValue = null;\n this._unsubPromise = Promise.resolve();\n this._setOptions(options);\n // @ts-ignore \u2013 we are hiding some symbols from public API autocompletion.\n if (this._centrifuge._debugEnabled) {\n this.on('state', (ctx) => {\n // @ts-ignore \u2013 we are hiding some symbols from public API autocompletion.\n this._centrifuge._debug('subscription state', channel, ctx.oldState, '->', ctx.newState);\n });\n this.on('error', (ctx) => {\n // @ts-ignore \u2013 we are hiding some symbols from public API autocompletion.\n this._centrifuge._debug('subscription error', channel, ctx);\n });\n } else {\n // Avoid unhandled exception in EventEmitter for non-set error handler.\n this.on('error', function () { Function.prototype(); });\n }\n }\n\n /** ready returns a Promise which resolves upon subscription goes to Subscribed \n * state and rejects in case of subscription goes to Unsubscribed state. \n * Optional timeout can be passed.*/\n ready(timeout?: number): Promise {\n if (this.state === SubscriptionState.Unsubscribed) {\n return Promise.reject({ code: errorCodes.subscriptionUnsubscribed, message: this.state });\n }\n if (this.state === SubscriptionState.Subscribed) {\n return Promise.resolve();\n }\n return new Promise((res, rej) => {\n const ctx: any = {\n resolve: res,\n reject: rej\n };\n if (timeout) {\n ctx.timeout = setTimeout(function () {\n rej({ code: errorCodes.timeout, message: 'timeout' });\n }, timeout);\n }\n this._promises[this._nextPromiseId()] = ctx;\n });\n }\n\n /** subscribe to a channel.*/\n subscribe() {\n if (this._isSubscribed()) {\n return;\n }\n this._resubscribeAttempts = 0;\n this._setSubscribing(subscribingCodes.subscribeCalled, 'subscribe called');\n }\n\n /** unsubscribe from a channel, keeping position state.*/\n unsubscribe() {\n this._unsubPromise = this._setUnsubscribed(unsubscribedCodes.unsubscribeCalled, 'unsubscribe called', true);\n }\n\n /** publish data to a channel.*/\n publish(data: any): Promise {\n const self = this;\n return this._methodCall().then(function () {\n return self._centrifuge.publish(self.channel, data);\n });\n }\n\n /** get online presence for a channel.*/\n presence(): Promise {\n const self = this;\n return this._methodCall().then(function () {\n return self._centrifuge.presence(self.channel);\n });\n }\n\n /** presence stats for a channel (num clients and unique users).*/\n presenceStats(): Promise {\n const self = this;\n return this._methodCall().then(function () {\n return self._centrifuge.presenceStats(self.channel);\n });\n }\n\n /** history for a channel. By default it does not return publications (only current\n * StreamPosition data) \u2013 provide an explicit limit > 0 to load publications.*/\n history(opts: HistoryOptions): Promise {\n const self = this;\n return this._methodCall().then(function () {\n return self._centrifuge.history(self.channel, opts);\n });\n }\n\n private _methodCall(): any {\n if (this._isSubscribed()) {\n return Promise.resolve();\n }\n if (this._isUnsubscribed()) {\n return Promise.reject({ code: errorCodes.subscriptionUnsubscribed, message: this.state });\n }\n return new Promise((res, rej) => {\n const timeout = setTimeout(function () {\n rej({ code: errorCodes.timeout, message: 'timeout' });\n // @ts-ignore \u2013 we are hiding some symbols from public API autocompletion.\n }, this._centrifuge._config.timeout);\n this._promises[this._nextPromiseId()] = {\n timeout: timeout,\n resolve: res,\n reject: rej\n };\n });\n }\n\n private _nextPromiseId() {\n return ++this._promiseId;\n }\n\n private _needRecover() {\n return this._recover === true;\n }\n\n private _isUnsubscribed() {\n return this.state === SubscriptionState.Unsubscribed;\n }\n\n private _isSubscribing() {\n return this.state === SubscriptionState.Subscribing;\n }\n\n private _isSubscribed() {\n return this.state === SubscriptionState.Subscribed;\n }\n\n private _setState(newState: SubscriptionState) {\n if (this.state !== newState) {\n const oldState = this.state;\n this.state = newState;\n this.emit('state', { newState, oldState, channel: this.channel });\n return true;\n }\n return false;\n }\n\n private _usesToken() {\n return this._token !== '' || this._getToken !== null;\n }\n\n private _clearSubscribingState() {\n this._resubscribeAttempts = 0;\n this._clearResubscribeTimeout();\n }\n\n private _clearSubscribedState() {\n this._clearRefreshTimeout();\n }\n\n private _setSubscribed(result: any) {\n if (!this._isSubscribing()) {\n return;\n }\n this._clearSubscribingState();\n\n if (result.recoverable) {\n this._recover = true;\n this._offset = result.offset || 0;\n this._epoch = result.epoch || '';\n }\n if (result.delta) {\n this._delta_negotiated = true;\n } else {\n this._delta_negotiated = false;\n }\n\n this._setState(SubscriptionState.Subscribed);\n // @ts-ignore \u2013 we are hiding some methods from public API autocompletion.\n const ctx = this._centrifuge._getSubscribeContext(this.channel, result);\n this.emit('subscribed', ctx);\n this._resolvePromises();\n\n const pubs = result.publications;\n if (pubs && pubs.length > 0) {\n for (const i in pubs) {\n if (!pubs.hasOwnProperty(i)) {\n continue;\n }\n this._handlePublication(pubs[i]);\n }\n }\n\n if (result.expires === true) {\n this._refreshTimeout = setTimeout(() => this._refresh(), ttlMilliseconds(result.ttl));\n }\n }\n\n private async _setSubscribing(code: number, reason: string) {\n if (this._isSubscribing()) {\n return;\n }\n if (this._isSubscribed()) {\n this._clearSubscribedState();\n }\n if (this._setState(SubscriptionState.Subscribing)) {\n this.emit('subscribing', { channel: this.channel, code: code, reason: reason });\n }\n // @ts-ignore \u2013 for performance reasons only await _unsubPromise for emulution case where it's required.\n if (this._centrifuge._transport && this._centrifuge._transport.emulation()) {\n await this._unsubPromise;\n }\n if (!this._isSubscribing()) {\n return;\n }\n this._subscribe();\n }\n\n private _subscribe(): any {\n // @ts-ignore \u2013 we are hiding some symbols from public API autocompletion.\n this._centrifuge._debug('subscribing on', this.channel);\n\n // need to check transport readiness here, because there's no point for calling getData or getToken\n // if transport is not ready yet\n // @ts-ignore \u2013 we are hiding some symbols from public API autocompletion.\n if (!this._centrifuge._transportIsOpen) {\n // @ts-ignore \u2013 we are hiding some symbols from public API autocompletion.\n this._centrifuge._debug('delay subscribe on', this.channel, 'till connected');\n // subscribe will be called later automatically.\n return null;\n }\n\n const self = this;\n const getDataCtx = {\n channel: self.channel\n };\n\n if (!this._usesToken() || this._token) {\n if (self._getData) {\n self._getData(getDataCtx).then(function (data: any) {\n if (!self._isSubscribing()) {\n return;\n }\n self._data = data;\n self._sendSubscribe(self._token);\n })\n return null;\n } else {\n return self._sendSubscribe(self._token);\n }\n }\n\n this._getSubscriptionToken().then(function (token) {\n if (!self._isSubscribing()) {\n return;\n }\n if (!token) {\n self._failUnauthorized();\n return;\n }\n self._token = token;\n if (self._getData) {\n self._getData(getDataCtx).then(function (data: any) {\n if (!self._isSubscribing()) {\n return;\n }\n self._data = data;\n self._sendSubscribe(token);\n })\n } else {\n self._sendSubscribe(token);\n }\n }).catch(function (e) {\n if (!self._isSubscribing()) {\n return;\n }\n if (e instanceof UnauthorizedError) {\n self._failUnauthorized();\n return;\n }\n self.emit('error', {\n type: 'subscribeToken',\n channel: self.channel,\n error: {\n code: errorCodes.subscriptionSubscribeToken,\n message: e !== undefined ? e.toString() : ''\n }\n });\n self._scheduleResubscribe();\n });\n return null;\n }\n\n private _sendSubscribe(token: string): any {\n // we also need to check for transport state before sending subscription\n // because it may change for subscription with side effects (getData, getToken options)\n // @ts-ignore \u2013 we are hiding some symbols from public API autocompletion.\n if (!this._centrifuge._transportIsOpen) {\n return null;\n }\n const channel = this.channel;\n\n const req: any = {\n channel: channel\n };\n\n if (token) {\n req.token = token;\n }\n\n if (this._data) {\n req.data = this._data;\n }\n\n if (this._positioned) {\n req.positioned = true;\n }\n\n if (this._recoverable) {\n req.recoverable = true;\n }\n\n if (this._joinLeave) {\n req.join_leave = true;\n }\n\n if (this._needRecover()) {\n req.recover = true;\n const offset = this._getOffset();\n if (offset) {\n req.offset = offset;\n }\n const epoch = this._getEpoch();\n if (epoch) {\n req.epoch = epoch;\n }\n }\n\n if (this._delta) {\n req.delta = this._delta;\n }\n\n const cmd = { subscribe: req };\n\n this._inflight = true;\n\n // @ts-ignore \u2013 we are hiding some symbols from public API autocompletion.\n this._centrifuge._call(cmd).then(resolveCtx => {\n this._inflight = false;\n // @ts-ignore - improve later.\n const result = resolveCtx.reply.subscribe;\n this._handleSubscribeResponse(\n result\n );\n // @ts-ignore - improve later.\n if (resolveCtx.next) {\n // @ts-ignore - improve later.\n resolveCtx.next();\n }\n }, rejectCtx => {\n this._inflight = false;\n this._handleSubscribeError(rejectCtx.error);\n if (rejectCtx.next) {\n rejectCtx.next();\n }\n });\n return cmd;\n }\n\n private _handleSubscribeError(error) {\n if (!this._isSubscribing()) {\n return;\n }\n if (error.code === errorCodes.timeout) {\n // @ts-ignore \u2013 we are hiding some symbols from public API autocompletion.\n this._centrifuge._disconnect(connectingCodes.subscribeTimeout, 'subscribe timeout', true);\n return;\n }\n this._subscribeError(error);\n }\n\n private _handleSubscribeResponse(result) {\n if (!this._isSubscribing()) {\n return;\n }\n this._setSubscribed(result);\n }\n\n private _setUnsubscribed(code, reason, sendUnsubscribe): Promise {\n if (this._isUnsubscribed()) {\n return Promise.resolve();\n }\n let promise = Promise.resolve();\n if (this._isSubscribed()) {\n if (sendUnsubscribe) {\n // @ts-ignore \u2013 we are hiding some methods from public API autocompletion.\n promise = this._centrifuge._unsubscribe(this);\n }\n this._clearSubscribedState();\n } else if (this._isSubscribing()) {\n if (this._inflight && sendUnsubscribe) {\n // @ts-ignore \u2013 we are hiding some methods from public API autocompletion.\n promise = this._centrifuge._unsubscribe(this);\n }\n this._clearSubscribingState();\n }\n if (this._setState(SubscriptionState.Unsubscribed)) {\n this.emit('unsubscribed', { channel: this.channel, code: code, reason: reason });\n }\n this._rejectPromises({ code: errorCodes.subscriptionUnsubscribed, message: this.state });\n return promise;\n }\n\n private _handlePublication(pub: any) {\n if (this._delta && this._delta_negotiated) {\n // @ts-ignore \u2013 we are hiding some methods from public API autocompletion.\n const {newData, newPrevValue} = this._centrifuge._codec.applyDeltaIfNeeded(pub, this._prevValue)\n pub.data = newData;\n this._prevValue = newPrevValue;\n }\n // @ts-ignore \u2013 we are hiding some methods from public API autocompletion.\n const ctx = this._centrifuge._getPublicationContext(this.channel, pub);\n this.emit('publication', ctx);\n if (pub.offset) {\n this._offset = pub.offset;\n }\n }\n\n protected _handleJoin(join: any) {\n // @ts-ignore \u2013 we are hiding some methods from public API autocompletion.\n const info = this._centrifuge._getJoinLeaveContext(join.info)\n this.emit('join', { channel: this.channel, info: info });\n }\n\n protected _handleLeave(leave: any) {\n // @ts-ignore \u2013 we are hiding some methods from public API autocompletion.\n const info = this._centrifuge._getJoinLeaveContext(leave.info)\n this.emit('leave', { channel: this.channel, info: info });\n }\n\n private _resolvePromises() {\n for (const id in this._promises) {\n if (!this._promises.hasOwnProperty(id)) {\n continue;\n }\n if (this._promises[id].timeout) {\n clearTimeout(this._promises[id].timeout);\n }\n this._promises[id].resolve();\n delete this._promises[id];\n }\n }\n\n private _rejectPromises(err: any) {\n for (const id in this._promises) {\n if (!this._promises.hasOwnProperty(id)) {\n continue;\n }\n if (this._promises[id].timeout) {\n clearTimeout(this._promises[id].timeout);\n }\n this._promises[id].reject(err);\n delete this._promises[id];\n }\n }\n\n private _scheduleResubscribe() {\n const self = this;\n const delay = this._getResubscribeDelay();\n this._resubscribeTimeout = setTimeout(function () {\n if (self._isSubscribing()) {\n self._subscribe();\n }\n }, delay);\n }\n\n private _subscribeError(err: any) {\n if (!this._isSubscribing()) {\n return;\n }\n if (err.code < 100 || err.code === 109 || err.temporary === true) {\n if (err.code === 109) { // Token expired error.\n this._token = '';\n }\n const errContext = {\n channel: this.channel,\n type: 'subscribe',\n error: err\n };\n if (this._centrifuge.state === State.Connected) {\n this.emit('error', errContext);\n }\n this._scheduleResubscribe();\n } else {\n this._setUnsubscribed(err.code, err.message, false);\n }\n }\n\n private _getResubscribeDelay() {\n const delay = backoff(this._resubscribeAttempts, this._minResubscribeDelay, this._maxResubscribeDelay);\n this._resubscribeAttempts++;\n return delay;\n }\n\n private _setOptions(options: Partial | undefined) {\n if (!options) {\n return;\n }\n if (options.since) {\n this._offset = options.since.offset;\n this._epoch = options.since.epoch;\n this._recover = true;\n }\n if (options.data) {\n this._data = options.data;\n }\n if (options.getData) {\n this._getData = options.getData;\n }\n if (options.minResubscribeDelay !== undefined) {\n this._minResubscribeDelay = options.minResubscribeDelay;\n }\n if (options.maxResubscribeDelay !== undefined) {\n this._maxResubscribeDelay = options.maxResubscribeDelay;\n }\n if (options.token) {\n this._token = options.token;\n }\n if (options.getToken) {\n this._getToken = options.getToken;\n }\n if (options.positioned === true) {\n this._positioned = true;\n }\n if (options.recoverable === true) {\n this._recoverable = true;\n }\n if (options.joinLeave === true) {\n this._joinLeave = true;\n }\n if (options.delta) {\n if (options.delta !== 'fossil') {\n throw new Error('unsupported delta format');\n }\n this._delta = options.delta;\n }\n }\n\n private _getOffset() {\n const offset = this._offset;\n if (offset !== null) {\n return offset;\n }\n return 0;\n }\n\n private _getEpoch() {\n const epoch = this._epoch;\n if (epoch !== null) {\n return epoch;\n }\n return '';\n }\n\n private _clearRefreshTimeout() {\n if (this._refreshTimeout !== null) {\n clearTimeout(this._refreshTimeout);\n this._refreshTimeout = null;\n }\n }\n\n private _clearResubscribeTimeout() {\n if (this._resubscribeTimeout !== null) {\n clearTimeout(this._resubscribeTimeout);\n this._resubscribeTimeout = null;\n }\n }\n\n private _getSubscriptionToken() {\n // @ts-ignore \u2013 we are hiding some methods from public API autocompletion.\n this._centrifuge._debug('get subscription token for channel', this.channel);\n const ctx = {\n channel: this.channel\n };\n const getToken = this._getToken;\n if (getToken === null) {\n this.emit('error', {\n type: 'configuration',\n channel: this.channel,\n error: {\n code: errorCodes.badConfiguration,\n message: 'provide a function to get channel subscription token'\n }\n });\n throw new UnauthorizedError('');\n }\n return getToken(ctx);\n }\n\n private _refresh() {\n this._clearRefreshTimeout();\n const self = this;\n this._getSubscriptionToken().then(function (token) {\n if (!self._isSubscribed()) {\n return;\n }\n if (!token) {\n self._failUnauthorized();\n return;\n }\n self._token = token;\n const req = {\n channel: self.channel,\n token: token\n };\n const msg = {\n 'sub_refresh': req\n };\n // @ts-ignore \u2013 we are hiding some symbols from public API autocompletion.\n self._centrifuge._call(msg).then(resolveCtx => {\n // @ts-ignore - improve later.\n const result = resolveCtx.reply.sub_refresh;\n self._refreshResponse(result);\n // @ts-ignore - improve later.\n if (resolveCtx.next) {\n // @ts-ignore - improve later.\n resolveCtx.next();\n }\n }, rejectCtx => {\n self._refreshError(rejectCtx.error);\n if (rejectCtx.next) {\n rejectCtx.next();\n }\n });\n }).catch(function (e) {\n if (e instanceof UnauthorizedError) {\n self._failUnauthorized();\n return;\n }\n self.emit('error', {\n type: 'refreshToken',\n channel: self.channel,\n error: {\n code: errorCodes.subscriptionRefreshToken,\n message: e !== undefined ? e.toString() : ''\n }\n });\n self._refreshTimeout = setTimeout(() => self._refresh(), self._getRefreshRetryDelay());\n });\n }\n\n private _refreshResponse(result: any) {\n if (!this._isSubscribed()) {\n return;\n }\n // @ts-ignore \u2013 we are hiding some methods from public API autocompletion.\n this._centrifuge._debug('subscription token refreshed, channel', this.channel);\n this._clearRefreshTimeout();\n if (result.expires === true) {\n this._refreshTimeout = setTimeout(() => this._refresh(), ttlMilliseconds(result.ttl));\n }\n }\n\n private _refreshError(err: any) {\n if (!this._isSubscribed()) {\n return;\n }\n if (err.code < 100 || err.temporary === true) {\n this.emit('error', {\n type: 'refresh',\n channel: this.channel,\n error: err\n });\n this._refreshTimeout = setTimeout(() => this._refresh(), this._getRefreshRetryDelay());\n } else {\n this._setUnsubscribed(err.code, err.message, true);\n }\n }\n\n private _getRefreshRetryDelay() {\n return backoff(0, 10000, 20000);\n }\n\n private _failUnauthorized() {\n this._setUnsubscribed(unsubscribedCodes.unauthorized, 'unauthorized', true);\n }\n}\n", "/** EventMap */\nexport type EventMap = {\n [key: string]: (...args: any[]) => void\n}\n\n/** Typed event emitter. */\nexport interface TypedEventEmitter {\n addListener(event: E, listener: Events[E]): this\n on(event: E, listener: Events[E]): this\n once(event: E, listener: Events[E]): this\n prependListener(event: E, listener: Events[E]): this\n prependOnceListener(event: E, listener: Events[E]): this\n off(event: E, listener: Events[E]): this\n removeAllListeners(event?: E): this\n removeListener(event: E, listener: Events[E]): this\n emit(event: E, ...args: Parameters): boolean\n rawListeners(event: E): Events[E][]\n listeners(event: E): Events[E][]\n}\n\n/** Client events which can be emitted. */\nexport type ClientEvents = {\n /** called when client state changes */\n state: (ctx: StateContext) => void;\n /** called when client goes to connecting state */\n connecting: (ctx: ConnectingContext) => void;\n /** called when client goes to connected state */\n connected: (ctx: ConnectedContext) => void;\n /** called when client goes to disconnected state */\n disconnected: (ctx: DisconnectedContext) => void;\n\n // Async message coming from a server.\n message: (ctx: MessageContext) => void;\n // Listen to errors happening internally. \n error: (ctx: ErrorContext) => void;\n\n // Listen for server-side subscription events.\n subscribed: (ctx: ServerSubscribedContext) => void;\n subscribing: (ctx: ServerSubscribingContext) => void;\n unsubscribed: (ctx: ServerUnsubscribedContext) => void;\n publication: (ctx: ServerPublicationContext) => void;\n join: (ctx: ServerJoinContext) => void;\n leave: (ctx: ServerLeaveContext) => void;\n}\n\n/** State of client. */\nexport enum State {\n Disconnected = \"disconnected\",\n Connecting = \"connecting\",\n Connected = \"connected\"\n}\n\n/** Events of Subscription. */\nexport type SubscriptionEvents = {\n /** called when subscription state changes */\n state: (ctx: SubscriptionStateContext) => void;\n /** called when subscription state goes to subscribing */\n subscribing: (ctx: SubscribingContext) => void;\n /** called when subscription state goes to subscribed */\n subscribed: (ctx: SubscribedContext) => void;\n /** called when subscription state goes to unsubscribed */\n unsubscribed: (ctx: UnsubscribedContext) => void;\n\n /** called when publication from channel received */\n publication: (ctx: PublicationContext) => void;\n /** called when join event from channel received */\n join: (ctx: JoinContext) => void;\n /** called when leave event from channel received */\n leave: (ctx: LeaveContext) => void;\n\n /** listen to subscription errors happening internally */\n error: (ctx: SubscriptionErrorContext) => void;\n}\n\n/** State of Subscription */\nexport enum SubscriptionState {\n Unsubscribed = \"unsubscribed\",\n Subscribing = \"subscribing\",\n Subscribed = \"subscribed\"\n}\n\nexport type TransportName = 'websocket' | 'http_stream' | 'sse' | 'sockjs' | 'webtransport';\n\n/** TransportEndpoint allows configuring transport when using fallback mode */\nexport interface TransportEndpoint {\n /** transport to use */\n transport: TransportName;\n /** endpoint for a selected transport type */\n endpoint: string;\n}\n\n/** Options for Centrifuge client. */\nexport interface Options {\n /** allows enabling debug mode */\n debug: boolean;\n /** allows setting initial connection token (JWT) */\n token: string;\n /** allows setting function to get/refresh connection token */\n getToken: null | ((ctx: ConnectionTokenContext) => Promise);\n /** data to send to a server with connect command */\n data: any | null;\n /** allows setting function to get/renew connection data */\n getData: null | (() => Promise);\n /** name of client - it's not a unique name of each connection, it's sth to identify\n * from where client connected */\n name: string;\n /** version of client */\n version: string;\n /** minimum delay between reconnect attempts in milliseconds */\n minReconnectDelay: number;\n /** maximum delay between reconnect attempts in milliseconds */\n maxReconnectDelay: number;\n /** timeout for operations in milliseconds */\n timeout: number;\n /** maximum delay of server pings to detect broken connection in milliseconds */\n maxServerPingDelay: number;\n /** provide custom WebSocket constructor, useful for NodeJS env where WebSocket is not\n * available globally */\n websocket: any | null;\n /** provide shim for fetch implementation */\n fetch: any | null;\n /** provide shim for ReadableStream */\n readableStream: any | null;\n /** provide shim for EventSource object */\n eventsource: any | null;\n /** provide shim for SockJS object */\n sockjs: any | null;\n /** allows modifying options passed to SockJS constructor */\n sockjsOptions: SockjsOptions;\n /** which emulation endpoint to use */\n emulationEndpoint: string;\n /** EventTarget for network online/offline events, in browser environment \n * Centrifuge uses global window online/offline events automatically\n * by default. */\n networkEventTarget: EventTarget | null;\n}\n\nexport interface SockjsOptions {\n transports?: string[];\n timeout?: number;\n}\n\nexport interface StateContext {\n newState: State;\n oldState: State;\n}\n\nexport interface ConnectedContext {\n client: string;\n transport: string;\n data?: any;\n}\n\nexport interface ErrorContext {\n type: string;\n error: Error;\n transport?: string;\n}\n\nexport interface Error {\n code: number;\n message: string;\n}\n\nexport interface ConnectingContext {\n code: number;\n reason: string;\n}\n\nexport interface DisconnectedContext {\n code: number;\n reason: string;\n}\n\nexport interface MessageContext {\n data: any;\n}\n\nexport interface PublicationContext {\n // channel from which publication was received.\n channel: string;\n // data contains publication payload.\n data: any;\n // info is an optional ClientInfo object. It's appended to publication only if publication was\n // sent using client SDK's publish method. If publication was sent over server publish API\n // this info object is missing as we don't have publisher client context in that case.\n info?: ClientInfo;\n // offset may be set for channels where history Centrifugo feature is on. In this case it's an\n // incremental number assigned to publication by server broker (upon adding to history stream). \n offset?: number;\n // tags is an extra key-value attached to publication, tags may be set when calling server publish API. \n tags?: Record;\n}\n\nexport interface ClientInfo {\n // client is a globally unique identifier which server allocates for every connection.\n client: string;\n // user contains ID of authenticated user. Empty user means anonymous user. One user can have\n // many client connections.\n user: string;\n // connInfo is optional information attached to connection (during connection authentication).\n connInfo?: any;\n // chanInfo is optional information attached to subscription (during subscription authorization).\n chanInfo?: any;\n}\n\nexport interface JoinContext {\n channel: string;\n info: ClientInfo;\n}\n\nexport interface LeaveContext {\n channel: string;\n info: ClientInfo;\n}\n\nexport interface SubscriptionStateContext {\n channel: string;\n newState: SubscriptionState;\n oldState: SubscriptionState;\n}\n\nexport interface ServerSubscribedContext {\n /** channel of Subscription. */\n channel: string;\n /** Subscription is recoverable \u2013 i.e. can automatically recover missed messages */\n recoverable: boolean;\n /** Subscription is positioned \u2013 i.e. server tracks message loss on the way from PUB/SUB broker */\n positioned: boolean;\n /** streamPosition set when Subscription is recoverable or positioned. */\n streamPosition?: StreamPosition;\n /** wasRecovering is true when recovery was used in subscribe request. */\n wasRecovering: boolean;\n /** whether or not missed publications may be successfully recovered. */\n recovered: boolean;\n /** custom data for Subscription returned from server. */\n data?: any;\n}\n\nexport interface SubscribedContext {\n channel: string;\n recoverable: boolean;\n positioned: boolean;\n streamPosition?: StreamPosition;\n wasRecovering: boolean;\n recovered: boolean;\n data?: any;\n}\n\nexport interface SubscriptionErrorContext {\n channel: string;\n type: string;\n error: Error;\n}\n\nexport interface UnsubscribedContext {\n channel: string;\n code: number;\n reason: string;\n}\n\nexport interface ServerPublicationContext {\n // channel from which publication was received.\n channel: string;\n // data contains publication payload.\n data: any;\n // info is an optional ClientInfo object. It's appended to publication only if publication was\n // sent using client SDK's publish method. If publication was sent over server publish API\n // this info object is missing as we don't have publisher client context in that case.\n info?: ClientInfo;\n // offset may be set for channels where history Centrifugo feature is on. In this case it's an\n // incremental number assigned to publication by server broker (upon adding to history stream). \n offset?: number;\n // tags is an extra key-value attached to publication, tags may be set when calling server publish API. \n tags?: Record;\n}\n\nexport interface ServerJoinContext {\n channel: string;\n info: ClientInfo;\n}\n\nexport interface ServerLeaveContext {\n channel: string;\n info: ClientInfo;\n}\n\nexport interface ServerUnsubscribedContext {\n channel: string;\n}\n\nexport interface SubscribingContext {\n channel: string;\n code: number;\n reason: string;\n}\n\nexport interface ServerSubscribingContext {\n channel: string;\n}\n\nexport interface ConnectionTokenContext {\n}\n\nexport interface SubscriptionTokenContext {\n channel: string;\n}\n\nexport interface SubscriptionDataContext {\n channel: string;\n}\n\nexport interface PublishResult {\n}\n\nexport interface RpcResult {\n data: any;\n}\n\nexport interface PresenceResult {\n clients: Record;\n}\n\nexport interface PresenceStatsResult {\n numClients: number;\n numUsers: number;\n}\n\nexport interface HistoryResult {\n publications: PublicationContext[];\n offset: number;\n epoch: string;\n}\n\nexport interface HistoryOptions {\n limit?: number;\n since?: StreamPosition;\n reverse?: boolean;\n}\n\n/** SubscriptionOptions can customize Subscription. */\nexport interface SubscriptionOptions {\n /** allows setting initial subscription token (JWT) */\n token: string;\n /** allows setting function to get/refresh subscription token */\n getToken: null | ((ctx: SubscriptionTokenContext) => Promise);\n /** data to send to a server with subscribe command */\n data: any | null;\n /** allows setting function to get/renew subscription data */\n getData: null | ((ctx: SubscriptionDataContext) => Promise);\n /** force recovery on first subscribe from a provided StreamPosition. */\n since: StreamPosition | null;\n /** min delay between resubscribe attempts. */\n minResubscribeDelay: number;\n /** max delay between resubscribe attempts. */\n maxResubscribeDelay: number;\n /** ask server to make subscription positioned. */\n positioned: boolean;\n /** ask server to make subscription recoverable. */\n recoverable: boolean;\n /** ask server to send join/leave messages. */\n joinLeave: boolean;\n /** delta format to be used */\n delta: 'fossil';\n}\n\n/** Stream postion describes position of publication inside a stream. */\nexport interface StreamPosition {\n offset: number;\n epoch: string;\n}\n", "/** @internal */\nexport function startsWith(value, prefix) {\n return value.lastIndexOf(prefix, 0) === 0;\n}\n\n/** @internal */\nexport function isFunction(value) {\n if (value === undefined || value === null) {\n return false;\n }\n return typeof value === 'function';\n}\n\n/** @internal */\nexport function log(level: string, args) {\n if (globalThis.console) {\n const logger = globalThis.console[level];\n\n if (isFunction(logger)) {\n logger.apply(globalThis.console, args);\n }\n }\n}\n\nfunction randomInt(min: number, max: number) { // min and max included\n return Math.floor(Math.random() * (max - min + 1) + min);\n}\n\n/** @internal */\nexport function backoff(step: number, min: number, max: number) {\n // Full jitter technique, see:\n // https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/\n if (step > 31) { step = 31; }\n const interval = randomInt(0, Math.min(max, min * Math.pow(2, step)));\n return Math.min(max, min + interval);\n}\n\n/** @internal */\nexport function errorExists(data: any) {\n return 'error' in data && data.error !== null;\n}\n\n/** @internal */\nexport function ttlMilliseconds(ttl: number) {\n // https://stackoverflow.com/questions/12633405/what-is-the-maximum-delay-for-setinterval\n return Math.min(ttl * 1000, 2147483647);\n}\n", "/** @internal */\nexport class SockjsTransport {\n endpoint: string;\n options: any;\n _transport: any;\n\n constructor(endpoint: string, options: any) {\n this.endpoint = endpoint;\n this.options = options;\n this._transport = null;\n }\n\n name() {\n return 'sockjs';\n }\n\n subName() {\n return 'sockjs-' + this._transport.transport;\n }\n\n emulation() {\n return false;\n }\n\n supported() {\n return this.options.sockjs !== null;\n }\n\n initialize(_protocol: 'json', callbacks: any) {\n this._transport = new this.options.sockjs(this.endpoint, null, this.options.sockjsOptions);\n\n this._transport.onopen = () => {\n callbacks.onOpen();\n };\n\n this._transport.onerror = e => {\n callbacks.onError(e);\n };\n\n this._transport.onclose = closeEvent => {\n callbacks.onClose(closeEvent);\n };\n\n this._transport.onmessage = event => {\n callbacks.onMessage(event.data);\n };\n }\n\n close() {\n this._transport.close();\n }\n\n send(data: any) {\n this._transport.send(data);\n }\n}\n", "/** @internal */\nexport class WebsocketTransport {\n private _transport: any;\n private endpoint: string;\n private options: any;\n\n constructor(endpoint: string, options: any) {\n this.endpoint = endpoint;\n this.options = options;\n this._transport = null;\n }\n\n name() {\n return 'websocket';\n }\n\n subName() {\n return 'websocket';\n }\n\n emulation() {\n return false;\n }\n\n supported() {\n return this.options.websocket !== undefined && this.options.websocket !== null;\n }\n\n initialize(protocol: string, callbacks: any) {\n let subProtocol = '';\n if (protocol === 'protobuf') {\n subProtocol = 'centrifuge-protobuf';\n }\n if (subProtocol !== '') {\n this._transport = new this.options.websocket(this.endpoint, subProtocol);\n } else {\n this._transport = new this.options.websocket(this.endpoint);\n }\n if (protocol === 'protobuf') {\n this._transport.binaryType = 'arraybuffer';\n }\n\n this._transport.onopen = () => {\n callbacks.onOpen();\n };\n\n this._transport.onerror = e => {\n callbacks.onError(e);\n };\n\n this._transport.onclose = closeEvent => {\n callbacks.onClose(closeEvent);\n };\n\n this._transport.onmessage = event => {\n callbacks.onMessage(event.data);\n };\n }\n\n close() {\n this._transport.close();\n }\n\n send(data: any) {\n this._transport.send(data);\n }\n}\n", "/** @internal */\nexport class HttpStreamTransport {\n endpoint: string;\n options: any;\n _abortController: any | null;\n _utf8decoder: TextDecoder;\n _protocol: string;\n\n constructor(endpoint, options) {\n this.endpoint = endpoint;\n this.options = options;\n this._abortController = null;\n this._utf8decoder = new TextDecoder();\n this._protocol = 'json';\n }\n\n name() {\n return 'http_stream';\n }\n\n subName() {\n return 'http_stream';\n }\n\n emulation() {\n return true;\n }\n\n _handleErrors(response: any) {\n if (!response.ok) throw new Error(response.status);\n return response;\n }\n\n _fetchEventTarget(self, endpoint: string, options: object) {\n const eventTarget = new EventTarget();\n // fetch with connection timeout maybe? https://github.com/github/fetch/issues/175\n const fetchFunc = self.options.fetch;\n fetchFunc(endpoint, options)\n .then(self._handleErrors)\n .then(response => {\n eventTarget.dispatchEvent(new Event('open'));\n let jsonStreamBuf = '';\n let jsonStreamPos = 0;\n let protoStreamBuf = new Uint8Array();\n const reader = response.body.getReader();\n return new self.options.readableStream({\n start(controller) {\n function pump() {\n return reader.read().then(({ done, value }) => {\n // When no more data needs to be consumed, close the stream\n if (done) {\n eventTarget.dispatchEvent(new Event('close'));\n controller.close();\n return;\n }\n try {\n if (self._protocol === 'json') {\n jsonStreamBuf += self._utf8decoder.decode(value);\n while (jsonStreamPos < jsonStreamBuf.length) {\n if (jsonStreamBuf[jsonStreamPos] === '\\n') {\n const line = jsonStreamBuf.substring(0, jsonStreamPos);\n eventTarget.dispatchEvent(new MessageEvent('message', { data: line }));\n jsonStreamBuf = jsonStreamBuf.substring(jsonStreamPos + 1);\n jsonStreamPos = 0;\n } else {\n ++jsonStreamPos;\n }\n }\n } else {\n const mergedArray = new Uint8Array(protoStreamBuf.length + value.length);\n mergedArray.set(protoStreamBuf);\n mergedArray.set(value, protoStreamBuf.length);\n protoStreamBuf = mergedArray;\n\n while (true) {\n const result = self.options.decoder.decodeReply(protoStreamBuf);\n if (result.ok) {\n const data = protoStreamBuf.slice(0, result.pos);\n eventTarget.dispatchEvent(new MessageEvent('message', { data: data }));\n protoStreamBuf = protoStreamBuf.slice(result.pos);\n continue;\n }\n break;\n }\n }\n } catch (error) {\n // @ts-ignore - improve later.\n eventTarget.dispatchEvent(new Event('error', { detail: error }));\n eventTarget.dispatchEvent(new Event('close'));\n controller.close();\n return;\n }\n pump();\n }).catch(function (e) {\n // @ts-ignore - improve later.\n eventTarget.dispatchEvent(new Event('error', { detail: e }));\n eventTarget.dispatchEvent(new Event('close'));\n controller.close();\n return;\n });\n }\n return pump();\n }\n });\n })\n .catch(error => {\n // @ts-ignore - improve later.\n eventTarget.dispatchEvent(new Event('error', { detail: error }));\n eventTarget.dispatchEvent(new Event('close'));\n });\n return eventTarget;\n }\n\n supported() {\n return this.options.fetch !== null &&\n this.options.readableStream !== null &&\n typeof TextDecoder !== 'undefined' &&\n typeof AbortController !== 'undefined' &&\n typeof EventTarget !== 'undefined' &&\n typeof Event !== 'undefined' &&\n typeof MessageEvent !== 'undefined' &&\n typeof Error !== 'undefined';\n }\n\n initialize(protocol: string, callbacks: any, initialData: any) {\n this._protocol = protocol;\n this._abortController = new AbortController();\n let headers: any;\n let body: any;\n if (protocol === 'json') {\n headers = {\n 'Accept': 'application/json',\n 'Content-Type': 'application/json'\n };\n body = initialData;\n } else {\n headers = {\n 'Accept': 'application/octet-stream',\n 'Content-Type': 'application/octet-stream'\n };\n body = initialData;\n }\n\n const fetchOptions = {\n method: 'POST',\n headers: headers,\n body: body,\n mode: 'cors',\n credentials: 'same-origin',\n cache: 'no-cache',\n signal: this._abortController.signal\n }\n\n const eventTarget = this._fetchEventTarget(\n this,\n this.endpoint,\n fetchOptions\n );\n\n eventTarget.addEventListener('open', () => {\n callbacks.onOpen();\n });\n\n eventTarget.addEventListener('error', (e) => {\n this._abortController.abort();\n callbacks.onError(e);\n });\n\n eventTarget.addEventListener('close', () => {\n this._abortController.abort();\n callbacks.onClose({\n code: 4,\n reason: 'connection closed'\n });\n });\n\n eventTarget.addEventListener('message', (e: any) => {\n callbacks.onMessage(e.data);\n });\n }\n\n close() {\n this._abortController.abort();\n }\n\n send(data: any, session: string, node: string) {\n let headers: any;\n let body: any;\n const req = {\n session: session,\n node: node,\n data: data\n };\n if (this._protocol === 'json') {\n headers = {\n 'Content-Type': 'application/json'\n };\n body = JSON.stringify(req);\n } else {\n headers = {\n 'Content-Type': 'application/octet-stream'\n };\n body = this.options.encoder.encodeEmulationRequest(req);\n }\n\n const fetchFunc = this.options.fetch;\n const fetchOptions = {\n method: 'POST',\n headers: headers,\n body: body,\n mode: 'cors',\n credentials: 'same-origin',\n cache: 'no-cache'\n }\n fetchFunc(this.options.emulationEndpoint, fetchOptions);\n }\n}\n", "/** @internal */\nexport class SseTransport {\n endpoint: string;\n options: any;\n _protocol: string;\n _transport: any;\n _onClose: any;\n\n constructor(endpoint: string, options: any) {\n this.endpoint = endpoint;\n this.options = options;\n this._protocol = 'json';\n this._transport = null;\n this._onClose = null;\n }\n\n name() {\n return 'sse';\n }\n\n subName() {\n return 'sse';\n }\n\n emulation() {\n return true;\n }\n\n supported() {\n return this.options.eventsource !== null && this.options.fetch !== null;\n }\n\n initialize(_protocol: 'json', callbacks: any, initialData: any) {\n let url: any;\n if (globalThis && globalThis.document && globalThis.document.baseURI) {\n // Handle case when endpoint is relative, like //example.com/connection/sse\n url = new URL(this.endpoint, globalThis.document.baseURI);\n } else {\n url = new URL(this.endpoint);\n }\n url.searchParams.append('cf_connect', initialData);\n\n const eventsourceOptions = {}\n const eventSource = new this.options.eventsource(url.toString(), eventsourceOptions);\n this._transport = eventSource;\n\n const self = this;\n\n eventSource.onopen = function () {\n callbacks.onOpen();\n };\n\n eventSource.onerror = function (e) {\n eventSource.close();\n callbacks.onError(e);\n callbacks.onClose({\n code: 4,\n reason: 'connection closed'\n });\n };\n\n eventSource.onmessage = function (e) {\n callbacks.onMessage(e.data);\n };\n\n self._onClose = function () {\n callbacks.onClose({\n code: 4,\n reason: 'connection closed'\n });\n };\n }\n\n close() {\n this._transport.close();\n if (this._onClose !== null) {\n this._onClose();\n }\n }\n\n send(data: any, session: string, node: string) {\n const req = {\n session: session,\n node: node,\n data: data\n };\n const headers = {\n 'Content-Type': 'application/json'\n };\n const body = JSON.stringify(req);\n const fetchFunc = this.options.fetch;\n const fetchOptions = {\n method: 'POST',\n headers: headers,\n body: body,\n mode: 'cors',\n credentials: 'same-origin',\n cache: 'no-cache'\n }\n fetchFunc(this.options.emulationEndpoint, fetchOptions);\n }\n}\n", "/** @internal */\nexport class WebtransportTransport {\n private _transport: any;\n private _stream: any;\n private _writer: any;\n private endpoint: string;\n private options: any;\n _utf8decoder: TextDecoder;\n _protocol: string;\n\n constructor(endpoint: string, options: any) {\n this.endpoint = endpoint;\n this.options = options;\n this._transport = null;\n this._stream = null;\n this._writer = null;\n this._utf8decoder = new TextDecoder();\n this._protocol = 'json';\n }\n\n name() {\n return 'webtransport';\n }\n\n subName() {\n return 'webtransport';\n }\n\n emulation() {\n return false;\n }\n\n supported() {\n return this.options.webtransport !== undefined && this.options.webtransport !== null;\n }\n\n async initialize(protocol: string, callbacks: any) {\n let url: any;\n if (globalThis && globalThis.document && globalThis.document.baseURI) {\n // Handle case when endpoint is relative, like //example.com/connection/webtransport\n url = new URL(this.endpoint, globalThis.document.baseURI);\n } else {\n url = new URL(this.endpoint);\n }\n if (protocol === 'protobuf') {\n url.searchParams.append('cf_protocol', 'protobuf');\n }\n\n this._protocol = protocol;\n const eventTarget = new EventTarget();\n\n this._transport = new this.options.webtransport(url.toString());\n this._transport.closed.then(() => {\n callbacks.onClose({\n code: 4,\n reason: 'connection closed'\n });\n }).catch(() => {\n callbacks.onClose({\n code: 4,\n reason: 'connection closed'\n });\n });\n try {\n await this._transport.ready;\n } catch {\n this.close();\n return;\n }\n let stream: any;\n try {\n stream = await this._transport.createBidirectionalStream();\n } catch {\n this.close();\n return;\n }\n this._stream = stream;\n this._writer = this._stream.writable.getWriter();\n\n eventTarget.addEventListener('close', () => {\n callbacks.onClose({\n code: 4,\n reason: 'connection closed'\n });\n });\n\n eventTarget.addEventListener('message', (e: any) => {\n callbacks.onMessage(e.data);\n });\n\n this._startReading(eventTarget);\n\n callbacks.onOpen();\n }\n\n async _startReading(eventTarget: any) {\n const reader = this._stream.readable.getReader();\n let jsonStreamBuf = '';\n let jsonStreamPos = 0;\n let protoStreamBuf = new Uint8Array();\n try {\n while (true) {\n const { done, value } = await reader.read();\n if (value.length > 0) {\n if (this._protocol === 'json') {\n jsonStreamBuf += this._utf8decoder.decode(value);\n while (jsonStreamPos < jsonStreamBuf.length) {\n if (jsonStreamBuf[jsonStreamPos] === '\\n') {\n const line = jsonStreamBuf.substring(0, jsonStreamPos);\n eventTarget.dispatchEvent(new MessageEvent('message', { data: line }));\n jsonStreamBuf = jsonStreamBuf.substring(jsonStreamPos + 1);\n jsonStreamPos = 0;\n } else {\n ++jsonStreamPos;\n }\n }\n } else {\n const mergedArray = new Uint8Array(protoStreamBuf.length + value.length);\n mergedArray.set(protoStreamBuf);\n mergedArray.set(value, protoStreamBuf.length);\n protoStreamBuf = mergedArray;\n\n while (true) {\n const result = this.options.decoder.decodeReply(protoStreamBuf);\n if (result.ok) {\n const data = protoStreamBuf.slice(0, result.pos);\n eventTarget.dispatchEvent(new MessageEvent('message', { data: data }));\n protoStreamBuf = protoStreamBuf.slice(result.pos);\n continue;\n }\n break;\n }\n }\n }\n if (done) {\n break;\n }\n }\n } catch {\n eventTarget.dispatchEvent(new Event('close'));\n }\n }\n\n async close() {\n try {\n if (this._writer) {\n await this._writer.close();\n }\n this._transport.close();\n } catch (e) {\n // already closed.\n }\n }\n\n async send(data: any) {\n let binary: Uint8Array;\n if (this._protocol === 'json') {\n // Need extra \\n since WT is non-frame protocol. \n binary = new TextEncoder().encode(data + '\\n');\n } else {\n binary = data;\n }\n try {\n await this._writer.write(binary);\n } catch (e) {\n this.close();\n }\n }\n}\n", "/*\nCopyright 2014-2024 Dmitry Chestnykh (JavaScript port)\nCopyright 2007 D. Richard Hipp (original C version)\n\nFossil SCM delta compression algorithm, this is only the applyDelta part extracted\nfrom https://github.com/dchest/fossil-delta-js. The code was slightly modified\nto strip unnecessary parts. The copyright on top of this file is from the original\nrepo on Github licensed under Simplified BSD License.\n*/\n\n// We accept plain arrays of bytes or Uint8Array.\ntype ByteArray = number[] | Uint8Array;\n\n\nconst zValue = [\n -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1,\n -1, -1, -1, -1, -1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,\n 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, 36, -1, 37,\n 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,\n 57, 58, 59, 60, 61, 62, -1, -1, -1, 63, -1,\n];\n\n// Reader reads bytes, chars, ints from array.\nclass Reader {\n public a: ByteArray;\n public pos: number;\n\n constructor(array: ByteArray) {\n this.a = array; // source array\n this.pos = 0; // current position in array\n }\n\n haveBytes() {\n return this.pos < this.a.length;\n }\n\n getByte() {\n const b = this.a[this.pos];\n this.pos++;\n if (this.pos > this.a.length) throw new RangeError(\"out of bounds\");\n return b;\n }\n\n getChar() {\n return String.fromCharCode(this.getByte());\n }\n\n // Read base64-encoded unsigned integer.\n getInt() {\n let v = 0;\n let c: number;\n while (this.haveBytes() && (c = zValue[0x7f & this.getByte()]) >= 0) {\n v = (v << 6) + c;\n }\n this.pos--;\n return v >>> 0;\n }\n}\n\n// Write writes an array.\nclass Writer {\n private a: number[] = [];\n\n toByteArray(sourceType: T): T {\n if (Array.isArray(sourceType)) {\n return this.a as T;\n }\n return new Uint8Array(this.a) as T;\n }\n\n // Copy from array at start to end.\n putArray(a: ByteArray, start: number, end: number) {\n // TODO: optimize.\n for (let i = start; i < end; i++) this.a.push(a[i]);\n }\n}\n\n// Return a 32-bit checksum of the array.\nfunction checksum(arr: ByteArray): number {\n let sum0 = 0,\n sum1 = 0,\n sum2 = 0,\n sum3 = 0,\n z = 0,\n N = arr.length;\n //TODO measure if this unrolling is helpful.\n while (N >= 16) {\n sum0 = (sum0 + arr[z + 0]) | 0;\n sum1 = (sum1 + arr[z + 1]) | 0;\n sum2 = (sum2 + arr[z + 2]) | 0;\n sum3 = (sum3 + arr[z + 3]) | 0;\n\n sum0 = (sum0 + arr[z + 4]) | 0;\n sum1 = (sum1 + arr[z + 5]) | 0;\n sum2 = (sum2 + arr[z + 6]) | 0;\n sum3 = (sum3 + arr[z + 7]) | 0;\n\n sum0 = (sum0 + arr[z + 8]) | 0;\n sum1 = (sum1 + arr[z + 9]) | 0;\n sum2 = (sum2 + arr[z + 10]) | 0;\n sum3 = (sum3 + arr[z + 11]) | 0;\n\n sum0 = (sum0 + arr[z + 12]) | 0;\n sum1 = (sum1 + arr[z + 13]) | 0;\n sum2 = (sum2 + arr[z + 14]) | 0;\n sum3 = (sum3 + arr[z + 15]) | 0;\n\n z += 16;\n N -= 16;\n }\n while (N >= 4) {\n sum0 = (sum0 + arr[z + 0]) | 0;\n sum1 = (sum1 + arr[z + 1]) | 0;\n sum2 = (sum2 + arr[z + 2]) | 0;\n sum3 = (sum3 + arr[z + 3]) | 0;\n z += 4;\n N -= 4;\n }\n sum3 = (((((sum3 + (sum2 << 8)) | 0) + (sum1 << 16)) | 0) + (sum0 << 24)) | 0;\n switch (N) {\n //@ts-ignore fallthrough is needed.\n case 3:\n sum3 = (sum3 + (arr[z + 2] << 8)) | 0; /* falls through */\n //@ts-ignore fallthrough is needed.\n case 2:\n sum3 = (sum3 + (arr[z + 1] << 16)) | 0; /* falls through */\n case 1:\n sum3 = (sum3 + (arr[z + 0] << 24)) | 0; /* falls through */\n }\n return sum3 >>> 0;\n}\n\n/**\n * Apply a delta byte array to a source byte array, returning the target byte array.\n */\nexport function applyDelta(\n source: T,\n delta: T\n): T {\n let total = 0;\n const zDelta = new Reader(delta);\n const lenSrc = source.length;\n const lenDelta = delta.length;\n\n const limit = zDelta.getInt();\n if (zDelta.getChar() !== \"\\n\")\n throw new Error(\"size integer not terminated by '\\\\n'\");\n const zOut = new Writer();\n while (zDelta.haveBytes()) {\n const cnt = zDelta.getInt();\n let ofst: number;\n\n switch (zDelta.getChar()) {\n case \"@\":\n ofst = zDelta.getInt();\n if (zDelta.haveBytes() && zDelta.getChar() !== \",\")\n throw new Error(\"copy command not terminated by ','\");\n total += cnt;\n if (total > limit) throw new Error(\"copy exceeds output file size\");\n if (ofst + cnt > lenSrc)\n throw new Error(\"copy extends past end of input\");\n zOut.putArray(source, ofst, ofst + cnt);\n break;\n\n case \":\":\n total += cnt;\n if (total > limit)\n throw new Error(\n \"insert command gives an output larger than predicted\"\n );\n if (cnt > lenDelta)\n throw new Error(\"insert count exceeds size of delta\");\n zOut.putArray(zDelta.a, zDelta.pos, zDelta.pos + cnt);\n zDelta.pos += cnt;\n break;\n\n case \";\":\n {\n const out = zOut.toByteArray(source);\n if (cnt !== checksum(out))\n throw new Error(\"bad checksum\");\n if (total !== limit)\n throw new Error(\"generated size does not match predicted size\");\n return out;\n }\n default:\n throw new Error(\"unknown delta operator\");\n }\n }\n throw new Error(\"unterminated delta\");\n}\n", "import { applyDelta } from './fossil';\n\n/** @internal */\nexport class JsonCodec {\n name() {\n return 'json';\n }\n\n encodeCommands(commands: any[]): string {\n return commands.map(c => JSON.stringify(c)).join('\\n');\n }\n\n decodeReplies(data: string): any[] {\n return data.trim().split('\\n').map(r => JSON.parse(r));\n }\n\n applyDeltaIfNeeded(pub: any, prevValue: any) {\n let newData: any, newPrevValue: any;\n if (pub.delta) {\n // JSON string delta.\n const valueArray = applyDelta(prevValue, new TextEncoder().encode(pub.data));\n newData = JSON.parse(new TextDecoder().decode(valueArray))\n newPrevValue = valueArray;\n } else {\n // Full data as JSON string.\n newData = JSON.parse(pub.data);\n newPrevValue = new TextEncoder().encode(pub.data);\n }\n return { newData, newPrevValue }\n }\n}\n", "import { Subscription } from './subscription';\nimport {\n errorCodes, disconnectedCodes,\n connectingCodes, subscribingCodes\n} from './codes';\n\nimport { SockjsTransport } from './transport_sockjs';\nimport { WebsocketTransport } from './transport_websocket';\nimport { HttpStreamTransport } from './transport_http_stream';\nimport { SseTransport } from './transport_sse';\nimport { WebtransportTransport } from './transport_webtransport';\n\nimport { JsonCodec } from './json';\n\nimport {\n isFunction, log, startsWith, errorExists,\n backoff, ttlMilliseconds\n} from './utils';\n\nimport {\n State, Options, SubscriptionState, ClientEvents,\n TypedEventEmitter, RpcResult, SubscriptionOptions,\n HistoryOptions, HistoryResult, PublishResult,\n PresenceResult, PresenceStatsResult, SubscribedContext,\n TransportEndpoint,\n} from './types';\n\nimport EventEmitter from 'events';\n\nconst defaults: Options = {\n token: '',\n getToken: null,\n data: null,\n getData: null,\n debug: false,\n name: 'js',\n version: '',\n fetch: null,\n readableStream: null,\n websocket: null,\n eventsource: null,\n sockjs: null,\n sockjsOptions: {},\n emulationEndpoint: '/emulation',\n minReconnectDelay: 500,\n maxReconnectDelay: 20000,\n timeout: 5000,\n maxServerPingDelay: 10000,\n networkEventTarget: null,\n}\n\ninterface serverSubscription {\n offset: number;\n epoch: string;\n recoverable: boolean;\n}\n\nexport class UnauthorizedError extends Error {\n constructor(message: any) {\n super(message);\n this.name = this.constructor.name;\n }\n}\n\n/** Centrifuge is a Centrifuge/Centrifugo bidirectional client. */\nexport class Centrifuge extends (EventEmitter as new () => TypedEventEmitter) {\n state: State;\n private _transportIsOpen: boolean;\n private _endpoint: string | Array;\n private _emulation: boolean;\n private _transports: any[];\n private _currentTransportIndex: number;\n private _triedAllTransports: boolean;\n private _transportWasOpen: boolean;\n private _transport?: any;\n private _transportId: number;\n private _deviceWentOffline: boolean;\n private _transportClosed: boolean;\n private _reconnecting: boolean;\n private _reconnectTimeout?: null | ReturnType = null;\n private _reconnectAttempts: number;\n private _client: null;\n private _session: string;\n private _node: string;\n private _subs: Record;\n private _serverSubs: Record;\n private _commandId: number;\n private _commands: any[];\n private _batching: boolean;\n private _refreshRequired: boolean;\n private _refreshTimeout?: null | ReturnType = null;\n private _callbacks: Record;\n private _token: string;\n private _data: any;\n private _dispatchPromise: Promise;\n private _serverPing: number;\n private _serverPingTimeout?: null | ReturnType = null;\n private _sendPong: boolean;\n private _promises: Record;\n private _promiseId: number;\n private _networkEventsSet: boolean;\n\n private _debugEnabled: boolean;\n private _config: Options;\n protected _codec: any;\n\n static SubscriptionState: typeof SubscriptionState;\n static State: typeof State;\n static UnauthorizedError: typeof UnauthorizedError;\n\n /** Constructs Centrifuge client. Call connect() method to start connecting. */\n constructor(endpoint: string | Array, options?: Partial) {\n super();\n this.state = State.Disconnected;\n this._transportIsOpen = false;\n this._endpoint = endpoint;\n this._emulation = false;\n this._transports = [];\n this._currentTransportIndex = 0;\n this._triedAllTransports = false;\n this._transportWasOpen = false;\n this._transport = null;\n this._transportId = 0;\n this._deviceWentOffline = false;\n this._transportClosed = true;\n this._codec = new JsonCodec();\n this._reconnecting = false;\n this._reconnectTimeout = null;\n this._reconnectAttempts = 0;\n this._client = null;\n this._session = '';\n this._node = '';\n this._subs = {};\n this._serverSubs = {};\n this._commandId = 0;\n this._commands = [];\n this._batching = false;\n this._refreshRequired = false;\n this._refreshTimeout = null;\n this._callbacks = {};\n this._token = '';\n this._data = null;\n this._dispatchPromise = Promise.resolve();\n this._serverPing = 0;\n this._serverPingTimeout = null;\n this._sendPong = false;\n this._promises = {};\n this._promiseId = 0;\n this._debugEnabled = false;\n this._networkEventsSet = false;\n\n this._config = { ...defaults, ...options };\n this._configure();\n\n if (this._debugEnabled) {\n this.on('state', (ctx) => {\n this._debug('client state', ctx.oldState, '->', ctx.newState);\n });\n this.on('error', (ctx) => {\n this._debug('client error', ctx);\n });\n } else {\n // Avoid unhandled exception in EventEmitter for non-set error handler.\n this.on('error', function () { Function.prototype(); });\n }\n }\n\n /** newSubscription allocates new Subscription to a channel. Since server only allows \n * one subscription per channel per client this method throws if client already has \n * channel subscription in internal registry.\n * */\n newSubscription(channel: string, options?: Partial): Subscription {\n if (this.getSubscription(channel) !== null) {\n throw new Error('Subscription to the channel ' + channel + ' already exists');\n }\n const sub = new Subscription(this, channel, options);\n this._subs[channel] = sub;\n return sub;\n }\n\n /** getSubscription returns Subscription if it's registered in the internal \n * registry or null. */\n getSubscription(channel: string): Subscription | null {\n return this._getSub(channel);\n }\n\n /** removeSubscription allows removing Subcription from the internal registry. Subscrption \n * must be in unsubscribed state. */\n removeSubscription(sub: Subscription | null) {\n if (!sub) {\n return;\n }\n if (sub.state !== SubscriptionState.Unsubscribed) {\n sub.unsubscribe();\n }\n this._removeSubscription(sub);\n }\n\n /** Get a map with all current client-side subscriptions. */\n subscriptions(): Record {\n return this._subs;\n }\n\n /** ready returns a Promise which resolves upon client goes to Connected \n * state and rejects in case of client goes to Disconnected or Failed state.\n * Users can provide optional timeout in milliseconds. */\n ready(timeout?: number): Promise {\n if (this.state === State.Disconnected) {\n return Promise.reject({ code: errorCodes.clientDisconnected, message: 'client disconnected' });\n }\n if (this.state === State.Connected) {\n return Promise.resolve();\n }\n return new Promise((res, rej) => {\n const ctx: any = {\n resolve: res,\n reject: rej\n };\n if (timeout) {\n ctx.timeout = setTimeout(function () {\n rej({ code: errorCodes.timeout, message: 'timeout' });\n }, timeout);\n }\n this._promises[this._nextPromiseId()] = ctx;\n });\n }\n\n /** connect to a server. */\n connect() {\n if (this._isConnected()) {\n this._debug('connect called when already connected');\n return;\n }\n if (this._isConnecting()) {\n this._debug('connect called when already connecting');\n return;\n }\n this._debug('connect called');\n this._reconnectAttempts = 0;\n this._startConnecting();\n }\n\n /** disconnect from a server. */\n disconnect() {\n this._disconnect(disconnectedCodes.disconnectCalled, 'disconnect called', false);\n }\n\n /** setToken allows setting connection token. Or resetting used token to be empty. */\n setToken(token: string) {\n this._token = token;\n }\n\n /** send asynchronous data to a server (without any response from a server \n * expected, see rpc method if you need response). */\n send(data: any): Promise {\n const cmd = {\n send: {\n data: data\n }\n };\n\n const self = this;\n\n return this._methodCall().then(function () {\n const sent = self._transportSendCommands([cmd]); // can send message to server without id set\n if (!sent) {\n return Promise.reject(self._createErrorObject(errorCodes.transportWriteError, 'transport write error'));\n }\n return Promise.resolve();\n });\n }\n\n /** rpc to a server - i.e. a call which waits for a response with data. */\n rpc(method: string, data: any): Promise {\n const cmd = {\n rpc: {\n method: method,\n data: data\n }\n };\n\n const self = this;\n\n return this._methodCall().then(function () {\n return self._callPromise(cmd, function (reply: any) {\n return {\n 'data': reply.rpc.data\n };\n });\n });\n }\n\n /** publish data to a channel. */\n publish(channel: string, data: any): Promise {\n const cmd = {\n publish: {\n channel: channel,\n data: data\n }\n };\n\n const self = this;\n\n return this._methodCall().then(function () {\n return self._callPromise(cmd, function () {\n return {};\n });\n });\n }\n\n /** history for a channel. By default it does not return publications (only current\n * StreamPosition data) \u2013 provide an explicit limit > 0 to load publications.*/\n history(channel: string, options?: HistoryOptions): Promise {\n const cmd = {\n history: this._getHistoryRequest(channel, options)\n };\n\n const self = this;\n\n return this._methodCall().then(function () {\n return self._callPromise(cmd, function (reply: any) {\n const result = reply.history;\n const publications: any[] = [];\n if (result.publications) {\n for (let i = 0; i < result.publications.length; i++) {\n publications.push(self._getPublicationContext(channel, result.publications[i]));\n }\n }\n return {\n 'publications': publications,\n 'epoch': result.epoch || '',\n 'offset': result.offset || 0\n };\n });\n });\n }\n\n /** presence for a channel. */\n presence(channel: string): Promise {\n const cmd = {\n presence: {\n channel: channel\n }\n };\n\n const self = this;\n\n return this._methodCall().then(function () {\n return self._callPromise(cmd, function (reply: any) {\n const clients = reply.presence.presence;\n for (const clientId in clients) {\n if (clients.hasOwnProperty(clientId)) {\n const connInfo = clients[clientId]['conn_info'];\n const chanInfo = clients[clientId]['chan_info'];\n if (connInfo) {\n clients[clientId].connInfo = connInfo;\n }\n if (chanInfo) {\n clients[clientId].chanInfo = chanInfo;\n }\n }\n }\n return {\n 'clients': clients\n };\n });\n });\n }\n\n /** presence stats for a channel. */\n presenceStats(channel: string): Promise {\n const cmd = {\n 'presence_stats': {\n channel: channel\n }\n };\n\n const self = this;\n\n return this._methodCall().then(function () {\n return self._callPromise(cmd, function (reply: any) {\n const result = reply.presence_stats;\n return {\n 'numUsers': result.num_users,\n 'numClients': result.num_clients\n };\n });\n });\n }\n\n /** start command batching (collect into temporary buffer without sending to a server) \n * until stopBatching called.*/\n startBatching() {\n // start collecting messages without sending them to Centrifuge until flush\n // method called\n this._batching = true;\n }\n\n /** stop batching commands and flush collected commands to the \n * network (all in one request/frame).*/\n stopBatching() {\n const self = this;\n // Why so nested? Two levels here requred to deal with promise resolving queue.\n // In Subscription case we wait 2 futures before sending data to connection.\n // Otherwise _batching becomes false before batching decision has a chance to be executed.\n Promise.resolve().then(function () {\n Promise.resolve().then(function () {\n self._batching = false;\n self._flush();\n })\n })\n }\n\n private _debug(...args: any[]) {\n if (!this._debugEnabled) {\n return;\n }\n log('debug', args);\n }\n\n /** @internal */\n protected _formatOverride() {\n return;\n }\n\n private _configure() {\n if (!('Promise' in globalThis)) {\n throw new Error('Promise polyfill required');\n }\n\n if (!this._endpoint) {\n throw new Error('endpoint configuration required');\n }\n\n if (this._config.token !== null) {\n this._token = this._config.token;\n }\n\n if (this._config.data !== null) {\n this._data = this._config.data;\n }\n\n this._codec = new JsonCodec();\n this._formatOverride();\n\n if (this._config.debug === true ||\n (typeof localStorage !== 'undefined' && localStorage.getItem('centrifuge.debug'))) {\n this._debugEnabled = true;\n }\n\n this._debug('config', this._config);\n\n if (typeof this._endpoint === 'string') {\n // Single address.\n } else if (typeof this._endpoint === 'object' && this._endpoint instanceof Array) {\n this._transports = this._endpoint;\n this._emulation = true;\n for (const i in this._transports) {\n if (this._transports.hasOwnProperty(i)) {\n const transportConfig = this._transports[i];\n if (!transportConfig.endpoint || !transportConfig.transport) {\n throw new Error('malformed transport configuration');\n }\n const transportName = transportConfig.transport;\n if (['websocket', 'http_stream', 'sse', 'sockjs', 'webtransport'].indexOf(transportName) < 0) {\n throw new Error('unsupported transport name: ' + transportName);\n }\n }\n }\n } else {\n throw new Error('unsupported url configuration type: only string or array of objects are supported');\n }\n }\n\n private _setState(newState: State) {\n if (this.state !== newState) {\n this._reconnecting = false;\n const oldState = this.state;\n this.state = newState;\n this.emit('state', { newState, oldState });\n return true;\n }\n return false;\n }\n\n private _isDisconnected() {\n return this.state === State.Disconnected;\n }\n\n private _isConnecting() {\n return this.state === State.Connecting;\n }\n\n private _isConnected() {\n return this.state === State.Connected;\n }\n\n private _nextCommandId() {\n return ++this._commandId;\n }\n\n private _setNetworkEvents() {\n if (this._networkEventsSet) {\n return;\n }\n let eventTarget: EventTarget | null = null;\n if (this._config.networkEventTarget !== null) {\n eventTarget = this._config.networkEventTarget;\n } else if (typeof globalThis.addEventListener !== 'undefined') {\n eventTarget = globalThis as EventTarget;\n }\n if (eventTarget) {\n eventTarget.addEventListener('offline', () => {\n this._debug('offline event triggered');\n if (this.state === State.Connected || this.state === State.Connecting) {\n this._disconnect(connectingCodes.transportClosed, 'transport closed', true);\n this._deviceWentOffline = true;\n }\n });\n eventTarget.addEventListener('online', () => {\n this._debug('online event triggered');\n if (this.state !== State.Connecting) {\n return;\n }\n if (this._deviceWentOffline && !this._transportClosed) {\n // This is a workaround for mobile Safari where close callback may be\n // not issued upon device going to the flight mode. We know for sure\n // that transport close was called, so we start reconnecting. In this\n // case if the close callback will be issued for some reason after some\n // time \u2013 it will be ignored due to transport ID mismatch.\n this._deviceWentOffline = false;\n this._transportClosed = true;\n }\n this._clearReconnectTimeout();\n this._startReconnecting();\n });\n this._networkEventsSet = true;\n }\n }\n\n private _getReconnectDelay() {\n const delay = backoff(this._reconnectAttempts, this._config.minReconnectDelay, this._config.maxReconnectDelay);\n this._reconnectAttempts += 1;\n return delay;\n }\n\n private _clearOutgoingRequests() {\n // fire errbacks of registered outgoing calls.\n for (const id in this._callbacks) {\n if (this._callbacks.hasOwnProperty(id)) {\n const callbacks = this._callbacks[id];\n clearTimeout(callbacks.timeout);\n const errback = callbacks.errback;\n if (!errback) {\n continue;\n }\n errback({ error: this._createErrorObject(errorCodes.connectionClosed, 'connection closed') });\n }\n }\n this._callbacks = {};\n }\n\n private _clearConnectedState() {\n this._client = null;\n this._clearServerPingTimeout();\n this._clearRefreshTimeout();\n\n // fire events for client-side subscriptions.\n for (const channel in this._subs) {\n if (!this._subs.hasOwnProperty(channel)) {\n continue;\n }\n const sub = this._subs[channel];\n if (sub.state === SubscriptionState.Subscribed) {\n // @ts-ignore \u2013 we are hiding some symbols from public API autocompletion.\n sub._setSubscribing(subscribingCodes.transportClosed, 'transport closed');\n }\n }\n\n // fire events for server-side subscriptions.\n for (const channel in this._serverSubs) {\n if (this._serverSubs.hasOwnProperty(channel)) {\n this.emit('subscribing', { channel: channel });\n }\n }\n }\n\n private _handleWriteError(commands: any[]) {\n for (const command of commands) {\n const id = command.id;\n if (!(id in this._callbacks)) {\n continue;\n }\n const callbacks = this._callbacks[id];\n clearTimeout(this._callbacks[id].timeout);\n delete this._callbacks[id];\n const errback = callbacks.errback;\n errback({ error: this._createErrorObject(errorCodes.transportWriteError, 'transport write error') });\n }\n }\n\n private _transportSendCommands(commands: any[]) {\n if (!commands.length) {\n return true;\n }\n if (!this._transport) {\n return false\n }\n try {\n this._transport.send(this._codec.encodeCommands(commands), this._session, this._node);\n } catch (e) {\n this._debug('error writing commands', e);\n this._handleWriteError(commands);\n return false;\n }\n return true;\n }\n\n private _initializeTransport() {\n let websocket: any;\n if (this._config.websocket !== null) {\n websocket = this._config.websocket;\n } else {\n if (!(typeof globalThis.WebSocket !== 'function' && typeof globalThis.WebSocket !== 'object')) {\n websocket = globalThis.WebSocket;\n }\n }\n\n let sockjs = null;\n if (this._config.sockjs !== null) {\n sockjs = this._config.sockjs;\n } else {\n if (typeof globalThis.SockJS !== 'undefined') {\n sockjs = globalThis.SockJS;\n }\n }\n\n let eventsource: any = null;\n if (this._config.eventsource !== null) {\n eventsource = this._config.eventsource;\n } else {\n if (typeof globalThis.EventSource !== 'undefined') {\n eventsource = globalThis.EventSource;\n }\n }\n\n let fetchFunc: any = null;\n if (this._config.fetch !== null) {\n fetchFunc = this._config.fetch;\n } else {\n if (typeof globalThis.fetch !== 'undefined') {\n fetchFunc = globalThis.fetch;\n }\n }\n\n let readableStream: any = null;\n if (this._config.readableStream !== null) {\n readableStream = this._config.readableStream;\n } else {\n if (typeof globalThis.ReadableStream !== 'undefined') {\n readableStream = globalThis.ReadableStream;\n }\n }\n\n if (!this._emulation) {\n if (startsWith(this._endpoint, 'http')) {\n throw new Error('Provide explicit transport endpoints configuration in case of using HTTP (i.e. using array of TransportEndpoint instead of a single string), or use ws(s):// scheme in an endpoint if you aimed using WebSocket transport');\n } else {\n this._debug('client will use websocket');\n this._transport = new WebsocketTransport(this._endpoint as string, {\n websocket: websocket\n });\n if (!this._transport.supported()) {\n throw new Error('WebSocket not available');\n }\n }\n } else {\n if (this._currentTransportIndex >= this._transports.length) {\n this._triedAllTransports = true;\n this._currentTransportIndex = 0;\n }\n let count = 0;\n while (true) {\n if (count >= this._transports.length) {\n throw new Error('no supported transport found');\n }\n const transportConfig = this._transports[this._currentTransportIndex];\n const transportName = transportConfig.transport;\n const transportEndpoint = transportConfig.endpoint;\n\n if (transportName === 'websocket') {\n this._debug('trying websocket transport');\n this._transport = new WebsocketTransport(transportEndpoint, {\n websocket: websocket\n });\n if (!this._transport.supported()) {\n this._debug('websocket transport not available');\n this._currentTransportIndex++;\n count++;\n continue;\n }\n } else if (transportName === 'webtransport') {\n this._debug('trying webtransport transport');\n this._transport = new WebtransportTransport(transportEndpoint, {\n webtransport: globalThis.WebTransport,\n decoder: this._codec,\n encoder: this._codec\n });\n if (!this._transport.supported()) {\n this._debug('webtransport transport not available');\n this._currentTransportIndex++;\n count++;\n continue;\n }\n } else if (transportName === 'http_stream') {\n this._debug('trying http_stream transport');\n this._transport = new HttpStreamTransport(transportEndpoint, {\n fetch: fetchFunc,\n readableStream: readableStream,\n emulationEndpoint: this._config.emulationEndpoint,\n decoder: this._codec,\n encoder: this._codec\n });\n if (!this._transport.supported()) {\n this._debug('http_stream transport not available');\n this._currentTransportIndex++;\n count++;\n continue;\n }\n } else if (transportName === 'sse') {\n this._debug('trying sse transport');\n this._transport = new SseTransport(transportEndpoint, {\n eventsource: eventsource,\n fetch: fetchFunc,\n emulationEndpoint: this._config.emulationEndpoint,\n });\n if (!this._transport.supported()) {\n this._debug('sse transport not available');\n this._currentTransportIndex++;\n count++;\n continue;\n }\n } else if (transportName === 'sockjs') {\n this._debug('trying sockjs');\n this._transport = new SockjsTransport(transportEndpoint, {\n sockjs: sockjs,\n sockjsOptions: this._config.sockjsOptions\n });\n if (!this._transport.supported()) {\n this._debug('sockjs transport not available');\n this._currentTransportIndex++;\n count++;\n continue;\n }\n } else {\n throw new Error('unknown transport ' + transportName);\n }\n break;\n }\n }\n\n const self = this;\n const transport = this._transport;\n const transportId = this._nextTransportId();\n self._debug(\"id of transport\", transportId);\n let wasOpen = false;\n const initialCommands: any[] = [];\n\n if (this._transport.emulation()) {\n const connectCommand = self._sendConnect(true);\n initialCommands.push(connectCommand);\n }\n\n this._setNetworkEvents();\n\n const initialData = this._codec.encodeCommands(initialCommands);\n\n this._transportClosed = false;\n\n let connectTimeout: any;\n connectTimeout = setTimeout(function () {\n transport.close();\n }, this._config.timeout);\n\n this._transport.initialize(this._codec.name(), {\n onOpen: function () {\n if (connectTimeout) {\n clearTimeout(connectTimeout);\n connectTimeout = null;\n }\n if (self._transportId != transportId) {\n self._debug('open callback from non-actual transport');\n transport.close();\n return;\n }\n wasOpen = true;\n self._debug(transport.subName(), 'transport open');\n if (transport.emulation()) {\n return;\n }\n self._transportIsOpen = true;\n self._transportWasOpen = true;\n self.startBatching();\n self._sendConnect(false);\n self._sendSubscribeCommands();\n self.stopBatching();\n //@ts-ignore must be used only for debug and test purposes. Exposed only for non-emulation transport.\n self.emit('__centrifuge_debug:connect_frame_sent', {})\n },\n onError: function (e: any) {\n if (self._transportId != transportId) {\n self._debug('error callback from non-actual transport');\n return;\n }\n self._debug('transport level error', e);\n },\n onClose: function (closeEvent) {\n if (connectTimeout) {\n clearTimeout(connectTimeout);\n connectTimeout = null;\n }\n if (self._transportId != transportId) {\n self._debug('close callback from non-actual transport');\n return;\n }\n self._debug(transport.subName(), 'transport closed');\n self._transportClosed = true;\n self._transportIsOpen = false;\n\n let reason = 'connection closed';\n let needReconnect = true;\n let code = 0;\n\n if (closeEvent && 'code' in closeEvent && closeEvent.code) {\n code = closeEvent.code;\n }\n\n if (closeEvent && closeEvent.reason) {\n try {\n const advice = JSON.parse(closeEvent.reason);\n reason = advice.reason;\n needReconnect = advice.reconnect;\n } catch (e) {\n reason = closeEvent.reason;\n if ((code >= 3500 && code < 4000) || (code >= 4500 && code < 5000)) {\n needReconnect = false;\n }\n }\n }\n\n if (code < 3000) {\n if (code === 1009) {\n code = disconnectedCodes.messageSizeLimit;\n reason = 'message size limit exceeded';\n needReconnect = false;\n } else {\n code = connectingCodes.transportClosed;\n reason = 'transport closed';\n }\n if (self._emulation && !self._transportWasOpen) {\n self._currentTransportIndex++;\n if (self._currentTransportIndex >= self._transports.length) {\n self._triedAllTransports = true;\n self._currentTransportIndex = 0;\n }\n }\n } else {\n // Codes >= 3000 are sent from a server application level.\n self._transportWasOpen = true;\n }\n\n if (self._isConnecting() && !wasOpen) {\n self.emit('error', {\n type: 'transport',\n error: {\n code: errorCodes.transportClosed,\n message: 'transport closed'\n },\n transport: transport.name()\n });\n }\n\n self._reconnecting = false;\n self._disconnect(code, reason, needReconnect);\n },\n onMessage: function (data) {\n self._dataReceived(data);\n }\n }, initialData);\n //@ts-ignore must be used only for debug and test purposes.\n self.emit('__centrifuge_debug:transport_initialized', {})\n }\n\n private _sendConnect(skipSending: boolean): any {\n const connectCommand = this._constructConnectCommand();\n const self = this;\n this._call(connectCommand, skipSending).then(resolveCtx => {\n // @ts-ignore = improve later.\n const result = resolveCtx.reply.connect;\n self._connectResponse(result);\n // @ts-ignore - improve later.\n if (resolveCtx.next) {\n // @ts-ignore - improve later.\n resolveCtx.next();\n }\n }, rejectCtx => {\n self._connectError(rejectCtx.error);\n if (rejectCtx.next) {\n rejectCtx.next();\n }\n });\n return connectCommand;\n }\n\n private _startReconnecting() {\n this._debug('start reconnecting');\n if (!this._isConnecting()) {\n this._debug('stop reconnecting: client not in connecting state');\n return;\n }\n if (this._reconnecting) {\n this._debug('reconnect already in progress, return from reconnect routine');\n return;\n }\n if (this._transportClosed === false) {\n this._debug('waiting for transport close');\n return;\n }\n\n this._reconnecting = true;\n const self = this;\n const emptyToken = this._token === '';\n const needTokenRefresh = this._refreshRequired || (emptyToken && this._config.getToken !== null);\n if (!needTokenRefresh) {\n if (this._config.getData) {\n this._config.getData().then(function (data: any) {\n if (!self._isConnecting()) {\n return;\n }\n self._data = data;\n self._initializeTransport();\n })\n } else {\n this._initializeTransport();\n }\n return;\n }\n\n this._getToken().then(function (token: string) {\n if (!self._isConnecting()) {\n return;\n }\n if (token == null || token == undefined) {\n self._failUnauthorized();\n return;\n }\n self._token = token;\n self._debug('connection token refreshed');\n if (self._config.getData) {\n self._config.getData().then(function (data: any) {\n if (!self._isConnecting()) {\n return;\n }\n self._data = data;\n self._initializeTransport();\n })\n } else {\n self._initializeTransport();\n }\n }).catch(function (e) {\n if (!self._isConnecting()) {\n return;\n }\n if (e instanceof UnauthorizedError) {\n self._failUnauthorized();\n return;\n }\n self.emit('error', {\n 'type': 'connectToken',\n 'error': {\n code: errorCodes.clientConnectToken,\n message: e !== undefined ? e.toString() : ''\n }\n });\n const delay = self._getReconnectDelay();\n self._debug('error on connection token refresh, reconnect after ' + delay + ' milliseconds', e);\n self._reconnecting = false;\n self._reconnectTimeout = setTimeout(() => {\n self._startReconnecting();\n }, delay);\n });\n }\n\n private _connectError(err: any) {\n if (this.state !== State.Connecting) {\n return;\n }\n if (err.code === 109) { // token expired.\n // next connect attempt will try to refresh token.\n this._refreshRequired = true;\n }\n if (err.code < 100 || err.temporary === true || err.code === 109) {\n this.emit('error', {\n 'type': 'connect',\n 'error': err\n });\n this._debug('closing transport due to connect error');\n this._disconnect(err.code, err.message, true);\n } else {\n this._disconnect(err.code, err.message, false);\n }\n }\n\n private _scheduleReconnect() {\n if (!this._isConnecting()) {\n return;\n }\n let isInitialHandshake = false;\n if (this._emulation && !this._transportWasOpen && !this._triedAllTransports) {\n isInitialHandshake = true;\n }\n let delay = this._getReconnectDelay();\n if (isInitialHandshake) {\n delay = 0;\n }\n this._debug('reconnect after ' + delay + ' milliseconds');\n this._clearReconnectTimeout();\n this._reconnectTimeout = setTimeout(() => {\n this._startReconnecting();\n }, delay);\n }\n\n private _constructConnectCommand(): any {\n const req: any = {};\n\n if (this._token) {\n req.token = this._token;\n }\n if (this._data) {\n req.data = this._data;\n }\n if (this._config.name) {\n req.name = this._config.name;\n }\n if (this._config.version) {\n req.version = this._config.version;\n }\n\n const subs = {};\n let hasSubs = false;\n for (const channel in this._serverSubs) {\n if (this._serverSubs.hasOwnProperty(channel) && this._serverSubs[channel].recoverable) {\n hasSubs = true;\n const sub = {\n 'recover': true\n };\n if (this._serverSubs[channel].offset) {\n sub['offset'] = this._serverSubs[channel].offset;\n }\n if (this._serverSubs[channel].epoch) {\n sub['epoch'] = this._serverSubs[channel].epoch;\n }\n subs[channel] = sub;\n }\n }\n if (hasSubs) {\n req.subs = subs;\n }\n return {\n connect: req\n };\n }\n\n private _getHistoryRequest(channel: string, options?: HistoryOptions) {\n const req: any = {\n channel: channel\n };\n if (options !== undefined) {\n if (options.since) {\n req.since = {\n offset: options.since.offset\n };\n if (options.since.epoch) {\n req.since.epoch = options.since.epoch;\n }\n }\n if (options.limit !== undefined) {\n req.limit = options.limit;\n }\n if (options.reverse === true) {\n req.reverse = true;\n }\n }\n return req;\n }\n\n private _methodCall(): any {\n if (this._isConnected()) {\n return Promise.resolve();\n }\n return new Promise((res, rej) => {\n const timeout = setTimeout(function () {\n rej({ code: errorCodes.timeout, message: 'timeout' });\n }, this._config.timeout);\n this._promises[this._nextPromiseId()] = {\n timeout: timeout,\n resolve: res,\n reject: rej\n };\n });\n }\n\n private _callPromise(cmd: any, resultCB: any): any {\n return new Promise((resolve, reject) => {\n this._call(cmd, false).then(resolveCtx => {\n // @ts-ignore - improve later.\n resolve(resultCB(resolveCtx.reply));\n // @ts-ignore - improve later.\n if (resolveCtx.next) {\n // @ts-ignore - improve later.\n resolveCtx.next();\n }\n }, rejectCtx => {\n reject(rejectCtx.error);\n if (rejectCtx.next) {\n rejectCtx.next();\n }\n });\n });\n }\n\n private _dataReceived(data) {\n if (this._serverPing > 0) {\n this._waitServerPing();\n }\n const replies = this._codec.decodeReplies(data);\n // We have to guarantee order of events in replies processing - i.e. start processing\n // next reply only when we finished processing of current one. Without syncing things in\n // this way we could get wrong publication events order as reply promises resolve\n // on next loop tick so for loop continues before we finished emitting all reply events.\n this._dispatchPromise = this._dispatchPromise.then(() => {\n let finishDispatch;\n this._dispatchPromise = new Promise(resolve => {\n finishDispatch = resolve;\n });\n this._dispatchSynchronized(replies, finishDispatch);\n });\n }\n\n private _dispatchSynchronized(replies: any[], finishDispatch: any) {\n let p: Promise = Promise.resolve();\n for (const i in replies) {\n if (replies.hasOwnProperty(i)) {\n p = p.then(() => {\n return this._dispatchReply(replies[i]);\n });\n }\n }\n p = p.then(() => {\n finishDispatch();\n });\n }\n\n private _dispatchReply(reply: any) {\n let next: any;\n const p = new Promise(resolve => {\n next = resolve;\n });\n\n if (reply === undefined || reply === null) {\n this._debug('dispatch: got undefined or null reply');\n next();\n return p;\n }\n\n const id = reply.id;\n\n if (id && id > 0) {\n this._handleReply(reply, next);\n } else {\n if (!reply.push) {\n this._handleServerPing(next);\n } else {\n this._handlePush(reply.push, next);\n }\n }\n\n return p;\n }\n\n private _call(cmd: any, skipSending: boolean) {\n return new Promise((resolve, reject) => {\n cmd.id = this._nextCommandId();\n this._registerCall(cmd.id, resolve, reject);\n if (!skipSending) {\n this._addCommand(cmd);\n }\n });\n }\n\n private _startConnecting() {\n this._debug('start connecting');\n if (this._setState(State.Connecting)) {\n this.emit('connecting', { code: connectingCodes.connectCalled, reason: 'connect called' });\n }\n this._client = null;\n this._startReconnecting();\n }\n\n private _disconnect(code: number, reason: string, reconnect: boolean) {\n if (this._isDisconnected()) {\n return;\n }\n // we mark transport is closed right away, because _clearConnectedState will move subscriptions to subscribing state\n // if transport will still be open at this time, subscribe frames will be sent to closing transport\n this._transportIsOpen = false;\n const previousState = this.state;\n this._reconnecting = false;\n\n const ctx = {\n code: code,\n reason: reason\n };\n\n let needEvent = false;\n\n if (reconnect) {\n needEvent = this._setState(State.Connecting);\n } else {\n needEvent = this._setState(State.Disconnected);\n this._rejectPromises({ code: errorCodes.clientDisconnected, message: 'disconnected' });\n }\n\n this._clearOutgoingRequests();\n\n if (previousState === State.Connecting) {\n this._clearReconnectTimeout();\n }\n if (previousState === State.Connected) {\n this._clearConnectedState();\n }\n\n if (needEvent) {\n if (this._isConnecting()) {\n this.emit('connecting', ctx);\n } else {\n this.emit('disconnected', ctx);\n }\n }\n\n if (this._transport) {\n this._debug(\"closing existing transport\");\n const transport = this._transport;\n this._transport = null;\n transport.close(); // Close only after setting this._transport to null to avoid recursion when calling transport close().\n // Need to mark as closed here, because connect call may be sync called after disconnect,\n // transport onClose callback will not be called yet\n this._transportClosed = true;\n this._nextTransportId();\n } else {\n this._debug(\"no transport to close\");\n }\n this._scheduleReconnect();\n }\n\n private _failUnauthorized() {\n this._disconnect(disconnectedCodes.unauthorized, 'unauthorized', false);\n }\n\n private _getToken(): Promise {\n this._debug('get connection token');\n if (!this._config.getToken) {\n this.emit('error', {\n type: 'configuration',\n error: {\n code: errorCodes.badConfiguration,\n message: 'token expired but no getToken function set in the configuration'\n }\n });\n throw new UnauthorizedError('');\n }\n return this._config.getToken({});\n }\n\n private _refresh() {\n const clientId = this._client;\n const self = this;\n this._getToken().then(function (token) {\n if (clientId !== self._client) {\n return;\n }\n if (!token) {\n self._failUnauthorized();\n return;\n }\n self._token = token;\n self._debug('connection token refreshed');\n\n if (!self._isConnected()) {\n return;\n }\n\n const cmd = {\n refresh: { token: self._token }\n };\n\n self._call(cmd, false).then(resolveCtx => {\n // @ts-ignore - improve later.\n const result = resolveCtx.reply.refresh;\n self._refreshResponse(result);\n // @ts-ignore - improve later.\n if (resolveCtx.next) {\n // @ts-ignore - improve later.\n resolveCtx.next();\n }\n }, rejectCtx => {\n self._refreshError(rejectCtx.error);\n if (rejectCtx.next) {\n rejectCtx.next();\n }\n });\n }).catch(function (e) {\n if (!self._isConnected()) {\n return;\n }\n if (e instanceof UnauthorizedError) {\n self._failUnauthorized();\n return;\n }\n self.emit('error', {\n type: 'refreshToken',\n error: {\n code: errorCodes.clientRefreshToken,\n message: e !== undefined ? e.toString() : ''\n }\n });\n self._refreshTimeout = setTimeout(() => self._refresh(), self._getRefreshRetryDelay());\n });\n }\n\n private _refreshError(err: any) {\n if (err.code < 100 || err.temporary === true) {\n this.emit('error', {\n type: 'refresh',\n error: err\n });\n this._refreshTimeout = setTimeout(() => this._refresh(), this._getRefreshRetryDelay());\n } else {\n this._disconnect(err.code, err.message, false);\n }\n }\n\n private _getRefreshRetryDelay() {\n return backoff(0, 5000, 10000);\n }\n\n private _refreshResponse(result: any) {\n if (this._refreshTimeout) {\n clearTimeout(this._refreshTimeout);\n this._refreshTimeout = null;\n }\n if (result.expires) {\n this._client = result.client;\n this._refreshTimeout = setTimeout(() => this._refresh(), ttlMilliseconds(result.ttl));\n }\n }\n\n private _removeSubscription(sub: Subscription | null) {\n if (sub === null) {\n return;\n }\n delete this._subs[sub.channel];\n }\n\n protected _unsubscribe(sub: Subscription) {\n if (!this._transportIsOpen) {\n return Promise.resolve();\n }\n const req = {\n channel: sub.channel\n };\n const cmd = { unsubscribe: req };\n\n const self = this;\n\n const unsubscribePromise = new Promise((resolve, _) => {\n this._call(cmd, false).then(resolveCtx => {\n resolve()\n // @ts-ignore - improve later.\n if (resolveCtx.next) {\n // @ts-ignore - improve later.\n resolveCtx.next();\n }\n }, rejectCtx => {\n resolve()\n if (rejectCtx.next) {\n rejectCtx.next();\n }\n self._disconnect(connectingCodes.unsubscribeError, 'unsubscribe error', true);\n });\n });\n\n return unsubscribePromise;\n }\n\n private _getSub(channel: string) {\n const sub = this._subs[channel];\n if (!sub) {\n return null;\n }\n return sub;\n }\n\n private _isServerSub(channel: string) {\n return this._serverSubs[channel] !== undefined;\n }\n\n private _sendSubscribeCommands(): any[] {\n const commands: any[] = [];\n for (const channel in this._subs) {\n if (!this._subs.hasOwnProperty(channel)) {\n continue;\n }\n const sub = this._subs[channel];\n // @ts-ignore \u2013 we are hiding some symbols from public API autocompletion.\n if (sub._inflight === true) {\n continue;\n }\n if (sub.state === SubscriptionState.Subscribing) {\n // @ts-ignore \u2013 we are hiding some symbols from public API autocompletion.\n const cmd = sub._subscribe();\n if (cmd) {\n commands.push(cmd);\n }\n }\n }\n return commands;\n }\n\n private _connectResponse(result: any) {\n this._transportIsOpen = true;\n this._transportWasOpen = true;\n this._reconnectAttempts = 0;\n this._refreshRequired = false;\n\n if (this._isConnected()) {\n return;\n }\n\n this._client = result.client;\n this._setState(State.Connected);\n\n if (this._refreshTimeout) {\n clearTimeout(this._refreshTimeout);\n }\n if (result.expires) {\n this._refreshTimeout = setTimeout(() => this._refresh(), ttlMilliseconds(result.ttl));\n }\n\n this._session = result.session;\n this._node = result.node;\n\n this.startBatching();\n this._sendSubscribeCommands();\n this.stopBatching();\n\n const ctx: any = {\n client: result.client,\n transport: this._transport.subName()\n };\n if (result.data) {\n ctx.data = result.data;\n }\n\n this.emit('connected', ctx);\n\n this._resolvePromises();\n\n this._processServerSubs(result.subs || {});\n\n if (result.ping && result.ping > 0) {\n this._serverPing = result.ping * 1000;\n this._sendPong = result.pong === true;\n this._waitServerPing();\n } else {\n this._serverPing = 0;\n }\n }\n\n private _processServerSubs(subs: Record) {\n for (const channel in subs) {\n if (!subs.hasOwnProperty(channel)) {\n continue;\n }\n const sub = subs[channel];\n this._serverSubs[channel] = {\n 'offset': sub.offset,\n 'epoch': sub.epoch,\n 'recoverable': sub.recoverable || false\n };\n const subCtx = this._getSubscribeContext(channel, sub);\n this.emit('subscribed', subCtx);\n }\n\n for (const channel in subs) {\n if (!subs.hasOwnProperty(channel)) {\n continue;\n }\n const sub = subs[channel];\n if (sub.recovered) {\n const pubs = sub.publications;\n if (pubs && pubs.length > 0) {\n for (const i in pubs) {\n if (pubs.hasOwnProperty(i)) {\n this._handlePublication(channel, pubs[i]);\n }\n }\n }\n }\n }\n\n for (const channel in this._serverSubs) {\n if (!this._serverSubs.hasOwnProperty(channel)) {\n continue;\n }\n if (!subs[channel]) {\n this.emit('unsubscribed', { channel: channel });\n delete this._serverSubs[channel];\n }\n }\n }\n\n private _clearRefreshTimeout() {\n if (this._refreshTimeout !== null) {\n clearTimeout(this._refreshTimeout);\n this._refreshTimeout = null;\n }\n }\n\n private _clearReconnectTimeout() {\n if (this._reconnectTimeout !== null) {\n clearTimeout(this._reconnectTimeout);\n this._reconnectTimeout = null;\n }\n }\n\n private _clearServerPingTimeout() {\n if (this._serverPingTimeout !== null) {\n clearTimeout(this._serverPingTimeout);\n this._serverPingTimeout = null;\n }\n }\n\n private _waitServerPing() {\n if (this._config.maxServerPingDelay === 0) {\n return;\n }\n if (!this._isConnected()) {\n return;\n }\n this._clearServerPingTimeout();\n this._serverPingTimeout = setTimeout(() => {\n if (!this._isConnected()) {\n return;\n }\n this._disconnect(connectingCodes.noPing, 'no ping', true);\n }, this._serverPing + this._config.maxServerPingDelay);\n }\n\n private _getSubscribeContext(channel: string, result: any): SubscribedContext {\n const ctx: any = {\n channel: channel,\n positioned: false,\n recoverable: false,\n wasRecovering: false,\n recovered: false\n };\n if (result.recovered) {\n ctx.recovered = true;\n }\n if (result.positioned) {\n ctx.positioned = true;\n }\n if (result.recoverable) {\n ctx.recoverable = true;\n }\n if (result.was_recovering) {\n ctx.wasRecovering = true;\n }\n let epoch = '';\n if ('epoch' in result) {\n epoch = result.epoch;\n }\n let offset = 0;\n if ('offset' in result) {\n offset = result.offset;\n }\n if (ctx.positioned || ctx.recoverable) {\n ctx.streamPosition = {\n 'offset': offset,\n 'epoch': epoch\n };\n }\n if (result.data) {\n ctx.data = result.data;\n }\n return ctx;\n }\n\n private _handleReply(reply: any, next: any) {\n const id = reply.id;\n if (!(id in this._callbacks)) {\n next();\n return;\n }\n const callbacks = this._callbacks[id];\n clearTimeout(this._callbacks[id].timeout);\n delete this._callbacks[id];\n\n if (!errorExists(reply)) {\n const callback = callbacks.callback;\n if (!callback) {\n return;\n }\n callback({ reply, next });\n } else {\n const errback = callbacks.errback;\n if (!errback) {\n next();\n return;\n }\n const error = reply.error;\n errback({ error, next });\n }\n }\n\n private _handleJoin(channel: string, join: any) {\n const sub = this._getSub(channel);\n if (!sub) {\n if (this._isServerSub(channel)) {\n const ctx = { channel: channel, info: this._getJoinLeaveContext(join.info) };\n this.emit('join', ctx);\n }\n return;\n }\n // @ts-ignore \u2013 we are hiding some symbols from public API autocompletion.\n sub._handleJoin(join);\n }\n\n private _handleLeave(channel: string, leave: any) {\n const sub = this._getSub(channel);\n if (!sub) {\n if (this._isServerSub(channel)) {\n const ctx = { channel: channel, info: this._getJoinLeaveContext(leave.info) };\n this.emit('leave', ctx);\n }\n return;\n }\n // @ts-ignore \u2013 we are hiding some symbols from public API autocompletion.\n sub._handleLeave(leave);\n }\n\n private _handleUnsubscribe(channel: string, unsubscribe: any) {\n const sub = this._getSub(channel);\n if (!sub) {\n if (this._isServerSub(channel)) {\n delete this._serverSubs[channel];\n this.emit('unsubscribed', { channel: channel });\n }\n return;\n }\n if (unsubscribe.code < 2500) {\n // @ts-ignore \u2013 we are hiding some symbols from public API autocompletion.\n sub._setUnsubscribed(unsubscribe.code, unsubscribe.reason, false);\n } else {\n // @ts-ignore \u2013 we are hiding some symbols from public API autocompletion.\n sub._setSubscribing(unsubscribe.code, unsubscribe.reason);\n }\n }\n\n private _handleSubscribe(channel: string, sub: any) {\n this._serverSubs[channel] = {\n 'offset': sub.offset,\n 'epoch': sub.epoch,\n 'recoverable': sub.recoverable || false\n };\n this.emit('subscribed', this._getSubscribeContext(channel, sub));\n }\n\n private _handleDisconnect(disconnect: any) {\n const code = disconnect.code;\n let reconnect = true;\n if ((code >= 3500 && code < 4000) || (code >= 4500 && code < 5000)) {\n reconnect = false;\n }\n this._disconnect(code, disconnect.reason, reconnect);\n }\n\n private _getPublicationContext(channel: string, pub: any) {\n const ctx: any = {\n channel: channel,\n data: pub.data\n };\n if (pub.offset) {\n ctx.offset = pub.offset;\n }\n if (pub.info) {\n ctx.info = this._getJoinLeaveContext(pub.info);\n }\n if (pub.tags) {\n ctx.tags = pub.tags;\n }\n return ctx;\n }\n\n private _getJoinLeaveContext(clientInfo: any) {\n const info: any = {\n client: clientInfo.client,\n user: clientInfo.user\n };\n if (clientInfo.conn_info) {\n info.connInfo = clientInfo.conn_info;\n }\n if (clientInfo.chan_info) {\n info.chanInfo = clientInfo.chan_info;\n }\n return info;\n }\n\n private _handlePublication(channel: string, pub: any) {\n const sub = this._getSub(channel);\n if (!sub) {\n if (this._isServerSub(channel)) {\n const ctx = this._getPublicationContext(channel, pub);\n this.emit('publication', ctx);\n if (pub.offset !== undefined) {\n this._serverSubs[channel].offset = pub.offset;\n }\n }\n return;\n }\n // @ts-ignore \u2013 we are hiding some symbols from public API autocompletion.\n sub._handlePublication(pub);\n }\n\n private _handleMessage(message: any) {\n this.emit('message', { data: message.data });\n }\n\n private _handleServerPing(next: any) {\n if (this._sendPong) {\n const cmd = {};\n this._transportSendCommands([cmd]);\n }\n next();\n }\n\n private _handlePush(data: any, next: any) {\n const channel = data.channel;\n if (data.pub) {\n this._handlePublication(channel, data.pub);\n } else if (data.message) {\n this._handleMessage(data.message);\n } else if (data.join) {\n this._handleJoin(channel, data.join);\n } else if (data.leave) {\n this._handleLeave(channel, data.leave);\n } else if (data.unsubscribe) {\n this._handleUnsubscribe(channel, data.unsubscribe);\n } else if (data.subscribe) {\n this._handleSubscribe(channel, data.subscribe);\n } else if (data.disconnect) {\n this._handleDisconnect(data.disconnect);\n }\n next();\n }\n\n private _flush() {\n const commands = this._commands.slice(0);\n this._commands = [];\n this._transportSendCommands(commands);\n }\n\n private _createErrorObject(code: number, message: string, temporary?: boolean) {\n const errObject: any = {\n code: code,\n message: message\n };\n if (temporary) {\n errObject.temporary = true;\n }\n return errObject;\n }\n\n private _registerCall(id: number, callback: any, errback: any) {\n this._callbacks[id] = {\n callback: callback,\n errback: errback,\n timeout: null\n };\n this._callbacks[id].timeout = setTimeout(() => {\n delete this._callbacks[id];\n if (isFunction(errback)) {\n errback({ error: this._createErrorObject(errorCodes.timeout, 'timeout') });\n }\n }, this._config.timeout);\n }\n\n private _addCommand(command: any) {\n if (this._batching) {\n this._commands.push(command);\n } else {\n this._transportSendCommands([command]);\n }\n }\n\n private _nextPromiseId() {\n return ++this._promiseId;\n }\n\n private _nextTransportId() {\n return ++this._transportId;\n }\n\n private _resolvePromises() {\n for (const id in this._promises) {\n if (!this._promises.hasOwnProperty(id)) {\n continue;\n }\n if (this._promises[id].timeout) {\n clearTimeout(this._promises[id].timeout);\n }\n this._promises[id].resolve();\n delete this._promises[id];\n }\n }\n\n private _rejectPromises(err: any) {\n for (const id in this._promises) {\n if (!this._promises.hasOwnProperty(id)) {\n continue;\n }\n if (this._promises[id].timeout) {\n clearTimeout(this._promises[id].timeout);\n }\n this._promises[id].reject(err);\n delete this._promises[id];\n }\n }\n}\n\nCentrifuge.SubscriptionState = SubscriptionState;\nCentrifuge.State = State\nCentrifuge.UnauthorizedError = UnauthorizedError;\n", "/**\n * This file is the entrypoint of browser builds.\n */\nimport { Centrifuge } from './centrifuge'\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\n(globalThis as any).Centrifuge = Centrifuge\n"], "mappings": "yiBAAA,IAAAA,EAAAC,GAAA,CAAAC,GAAAC,IAAA,cAuBA,IAAIC,EAAI,OAAO,SAAY,SAAW,QAAU,KAC5CC,EAAeD,GAAK,OAAOA,EAAE,OAAU,WACvCA,EAAE,MACF,SAAsBE,EAAQC,EAAUC,EAAM,CAC9C,OAAO,SAAS,UAAU,MAAM,KAAKF,EAAQC,EAAUC,CAAI,CAC7D,EAEEC,EACAL,GAAK,OAAOA,EAAE,SAAY,WAC5BK,EAAiBL,EAAE,QACV,OAAO,sBAChBK,EAAiB,SAAwBH,EAAQ,CAC/C,OAAO,OAAO,oBAAoBA,CAAM,EACrC,OAAO,OAAO,sBAAsBA,CAAM,CAAC,CAChD,EAEAG,EAAiB,SAAwBH,EAAQ,CAC/C,OAAO,OAAO,oBAAoBA,CAAM,CAC1C,EAGF,SAASI,GAAmBC,EAAS,CAC/B,SAAW,QAAQ,MAAM,QAAQ,KAAKA,CAAO,CACnD,CAEA,IAAIC,EAAc,OAAO,OAAS,SAAqBC,EAAO,CAC5D,OAAOA,IAAUA,CACnB,EAEA,SAASC,GAAe,CACtBA,EAAa,KAAK,KAAK,IAAI,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AK,UACf,KAAK,UAAU,eAAeA,CAAE,IAGjC,KAAK,UAAUA,CAAE,EAAE,SACrB,aAAa,KAAK,UAAUA,CAAE,EAAE,OAAO,EAEzC,KAAK,UAAUA,CAAE,EAAE,QAAQ,EAC3B,OAAO,KAAK,UAAUA,CAAE,EAE5B,CAEQ,gBAAgBmC,EAAU,CAChC,QAAWnC,KAAM,KAAK,UACf,KAAK,UAAU,eAAeA,CAAE,IAGjC,KAAK,UAAUA,CAAE,EAAE,SACrB,aAAa,KAAK,UAAUA,CAAE,EAAE,OAAO,EAEzC,KAAK,UAAUA,CAAE,EAAE,OAAOmC,CAAG,EAC7B,OAAO,KAAK,UAAUnC,CAAE,EAE5B,CACF,EAEAlC,EAAW,kBAAoBuG,EAC/BvG,EAAW,MAAQwG,EACnBxG,EAAW,kBAAoBF,ECvzD9B,WAAmB,WAAa2G", "names": ["require_events", "__commonJSMin", "exports", "module", "R", "ReflectApply", "target", "receiver", "args", "ReflectOwnKeys", "ProcessEmitWarning", "warning", "NumberIsNaN", "value", "EventEmitter", "once", "defaultMaxListeners", "checkListener", "listener", "arg", "n", "_getMaxListeners", "that", "type", "i", "doError", "events", "er", "err", "handler", "len", "listeners", "arrayClone", "_addListener", "prepend", "m", "existing", "w", "onceWrapper", "_onceWrap", "state", "wrapped", "list", "position", "originalListener", "spliceOne", "keys", "key", "_listeners", "unwrap", "evlistener", "unwrapListeners", "emitter", "listenerCount", "arr", "copy", "index", "ret", "name", "resolve", "reject", "errorListener", "resolver", "eventTargetAgnosticAddListener", "addErrorHandlerIfEventEmitter", "flags", "wrapListener", "import_events", "State", "SubscriptionState", "startsWith", "value", "prefix", "isFunction", "log", "level", "args", "logger", "randomInt", "min", "max", "backoff", "step", "interval", "errorExists", "data", "ttlMilliseconds", "ttl", "Subscription", "EventEmitter", "centrifuge", "channel", "options", "ctx", "timeout", "res", "rej", "data", "self", "opts", "newState", "oldState", "result", "pubs", "ttlMilliseconds", "code", "reason", "getDataCtx", "token", "e", "UnauthorizedError", "req", "offset", "epoch", "cmd", "resolveCtx", "rejectCtx", "error", "sendUnsubscribe", "promise", "pub", "newData", "newPrevValue", "join", "info", "leave", "id", "err", "delay", "errContext", "backoff", "getToken", "msg", "SockjsTransport", "endpoint", "options", "_protocol", "callbacks", "e", "closeEvent", "event", "data", "WebsocketTransport", "endpoint", "options", "protocol", "callbacks", "subProtocol", "e", "closeEvent", "event", "data", "HttpStreamTransport", "endpoint", "options", "response", "self", "eventTarget", "fetchFunc", "jsonStreamBuf", "jsonStreamPos", "protoStreamBuf", "reader", "controller", "pump", "done", "value", "line", "mergedArray", "result", "data", "error", "e", "protocol", "callbacks", "initialData", "headers", "body", "fetchOptions", "session", "node", "req", "SseTransport", "endpoint", "options", "_protocol", "callbacks", "initialData", "url", "eventsourceOptions", "eventSource", "self", "e", "data", "session", "node", "req", "headers", "body", "fetchFunc", "fetchOptions", "WebtransportTransport", "endpoint", "options", "protocol", "callbacks", "url", "eventTarget", "stream", "e", "reader", "jsonStreamBuf", "jsonStreamPos", "protoStreamBuf", "done", "value", "line", "mergedArray", "result", "data", "binary", "zValue", "Reader", "array", "b", "v", "c", "Writer", "sourceType", "a", "start", "end", "i", "checksum", "arr", "sum0", "sum1", "sum2", "sum3", "z", "N", "applyDelta", "source", "delta", "total", "zDelta", "lenSrc", "lenDelta", "limit", "zOut", "cnt", "ofst", "out", "JsonCodec", "commands", "c", "data", "r", "pub", "prevValue", "newData", "newPrevValue", "valueArray", "applyDelta", "import_events", "defaults", "UnauthorizedError", "message", "Centrifuge", "EventEmitter", "endpoint", "options", "JsonCodec", "ctx", "channel", "sub", "Subscription", "timeout", "res", "rej", "token", "data", "cmd", "self", "method", "reply", "result", "publications", "i", "clients", "clientId", "connInfo", "chanInfo", "args", "log", "transportConfig", "transportName", "newState", "oldState", "eventTarget", "delay", "backoff", "id", "callbacks", "errback", "commands", "command", "e", "websocket", "sockjs", "eventsource", "fetchFunc", "readableStream", "count", "transportEndpoint", "WebsocketTransport", "WebtransportTransport", "HttpStreamTransport", "SseTransport", "SockjsTransport", "startsWith", "transport", "transportId", "wasOpen", "initialCommands", "connectCommand", "initialData", "connectTimeout", "closeEvent", "reason", "needReconnect", "code", "advice", "skipSending", "resolveCtx", "rejectCtx", "emptyToken", "err", "isInitialHandshake", "req", "subs", "hasSubs", "resultCB", "resolve", "reject", "replies", "finishDispatch", "p", "next", "reconnect", "previousState", "needEvent", "ttlMilliseconds", "_", "subCtx", "pubs", "epoch", "offset", "errorExists", "error", "callback", "join", "leave", "unsubscribe", "disconnect", "pub", "clientInfo", "info", "temporary", "errObject", "isFunction", "SubscriptionState", "State", "Centrifuge"] }