diff --git a/README.md b/README.md index 550cbe0..41e1e6a 100644 --- a/README.md +++ b/README.md @@ -1,33 +1,33 @@ -Asyngular JavaScript client +SocketCluster JavaScript client ====== -Client module for Asyngular. +Client module for SocketCluster. ## Setting up -You will need to install both ```asyngular-client``` and ```asyngular-server``` (https://github.com/SocketCluster/asyngular-server). +You will need to install both ```socketcluster-client``` and ```socketcluster-server``` (https://github.com/SocketCluster/socketcluster-server). To install this module: ```bash -npm install asyngular-client +npm install socketcluster-client ``` ## How to use -The asyngular-client script is called `asyngular-client.js` (located in the main asyngular-client directory). +The socketcluster-client script is called `socketcluster-client.js` (located in the main socketcluster-client directory). Embed it in your HTML page like this: ```html - + ``` \* Note that the src attribute may be different depending on how you setup your HTTP server. -Once you have embedded the client `asyngular-client.js` into your page, you will gain access to a global `asyngularClient` object. +Once you have embedded the client `socketcluster-client.js` into your page, you will gain access to a global `socketClusterClient` object. You may also use CommonJS `require` or ES6 module imports. ### Connect to a server ```js -let socket = asyngularClient.create({ +let socket = socketClusterClient.create({ hostname: 'localhost', port: 8000 }); @@ -138,19 +138,19 @@ let options = { rejectUnauthorized: false // Only necessary during debug if using a self-signed certificate }; // Initiate the connection to the server -let socket = asyngularClient.create(options); +let socket = socketClusterClient.create(options); ``` -For more detailed examples of how to use Asyngular, see `test/integration.js`. -Also, see tests from the `asyngular-server` module. +For more detailed examples of how to use SocketCluster, see `test/integration.js`. +Also, see tests from the `socketcluster-server` module. ### Connect Options -See all available options: https://asyngular.io/docs/api-asyngular-client/ +See all available options: https://socketcluster.io/ ```js let options = { - path: '/asyngular/', + path: '/socketcluster/', port: 8000, hostname: '127.0.0.1', autoConnect: true, @@ -177,8 +177,8 @@ let options = { ## Running the tests -- Clone this repo: `git clone git@github.com:SocketCluster/asyngular-client.git` -- Navigate to project directory: `cd asyngular-client` +- Clone this repo: `git clone git@github.com:SocketCluster/socketcluster-client.git` +- Navigate to project directory: `cd socketcluster-client` - Install all dependencies: `npm install` - Run the tests: `npm test` @@ -187,7 +187,7 @@ let options = { For compatibility with an existing SocketCluster server, set the `protocolVersion` to `1` and make sure that the `path` matches your old server path: ```js -let socket = asyngularClient.create({ +let socket = socketClusterClient.create({ protocolVersion: 1, path: '/socketcluster/' }); @@ -198,7 +198,7 @@ let socket = asyngularClient.create({ ### Install all dependencies ```bash -cd asyngular-client +cd socketcluster-client npm install -g gulp gulp-cli browserify uglify-es @@ -207,7 +207,7 @@ npm install ### Building -To build the Asyngular client: +To build the SocketCluster client: ```bash npm run build @@ -215,13 +215,13 @@ npm run build ## Change log -See the 'releases' section for changes: https://github.com/SocketCluster/asyngular-client/releases +See the 'releases' section for changes: https://github.com/SocketCluster/socketcluster-client/releases ## License (The MIT License) -Copyright (c) 2013-2019 Asyngular.io +Copyright (c) 2013-2019 SocketCluster.io Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: diff --git a/asyngular-client.min.js b/asyngular-client.min.js deleted file mode 100644 index 171452e..0000000 --- a/asyngular-client.min.js +++ /dev/null @@ -1,4 +0,0 @@ -/** - * Asyngular JavaScript client v6.2.4 - */ - !function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).asyngularClient=t()}}(function(){return function(){return function t(e,r,n){function o(s,a){if(!r[s]){if(!e[s]){var u="function"==typeof require&&require;if(!a&&u)return u(s,!0);if(i)return i(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var h=r[s]={exports:{}};e[s][0].call(h.exports,function(t){return o(e[s][1][t]||t)},h,h.exports,t,e,r,n)}return r[s].exports}for(var i="function"==typeof require&&require,s=0;s{if(this[t]>i)throw new m(`The ${t} value provided exceeded the maximum amount allowed`)};if(u("connectTimeout"),u("ackTimeout"),u("pingTimeout"),this.connectAttempts=0,this.isBatching=!1,this.batchOnHandshake=e.batchOnHandshake,this.batchOnHandshakeDuration=e.batchOnHandshakeDuration,this._batchingIntervalId=null,this._outboundBuffer=new h,this._channelMap={},this._channelEventDemux=new n,this._channelDataDemux=new n,this._receiverDemux=new n,this._procedureDemux=new n,this.options=e,this._cid=1,this.options.callIdGenerator=(()=>this._cid++),this.options.autoReconnect){null==this.options.autoReconnectOptions&&(this.options.autoReconnectOptions={});let t=this.options.autoReconnectOptions;null==t.initialDelay&&(t.initialDelay=1e4),null==t.randomness&&(t.randomness=1e4),null==t.multiplier&&(t.multiplier=1.5),null==t.maxDelay&&(t.maxDelay=6e4)}if(null==this.options.subscriptionRetryOptions&&(this.options.subscriptionRetryOptions={}),this.options.authEngine?this.auth=this.options.authEngine:this.auth=new s,this.options.codecEngine?this.codec=this.options.codecEngine:this.codec=a,this.options.protocol){let t=new m('The "protocol" option does not affect asyngular-client - If you want to utilize SSL/TLS, use "secure" option instead');this._onError(t)}this.options.query=e.query||{},"string"==typeof this.options.query&&(this.options.query=c.parse(this.options.query)),_&&this.disconnectOnUnload&&r.addEventListener&&r.removeEventListener&&this._handleBrowserUnload(),this.options.autoConnect&&this.connect()}k.prototype=Object.create(o.prototype),k.CONNECTING=k.prototype.CONNECTING=u.prototype.CONNECTING,k.OPEN=k.prototype.OPEN=u.prototype.OPEN,k.CLOSED=k.prototype.CLOSED=u.prototype.CLOSED,k.AUTHENTICATED=k.prototype.AUTHENTICATED="authenticated",k.UNAUTHENTICATED=k.prototype.UNAUTHENTICATED="unauthenticated",k.SUBSCRIBED=k.prototype.SUBSCRIBED=i.SUBSCRIBED,k.PENDING=k.prototype.PENDING=i.PENDING,k.UNSUBSCRIBED=k.prototype.UNSUBSCRIBED=i.UNSUBSCRIBED,k.ignoreStatuses=d.socketProtocolIgnoreStatuses,k.errorStatuses=d.socketProtocolErrorStatuses,Object.defineProperty(k.prototype,"isBufferingBatch",{get:function(){return this.transport.isBufferingBatch}}),k.prototype.getBackpressure=function(){return Math.max(this.getAllListenersBackpressure(),this.getAllReceiversBackpressure(),this.getAllProceduresBackpressure(),this.getAllChannelsBackpressure())},k.prototype._handleBrowserUnload=async function(){let t=()=>{this.disconnect()},e=!1;(async()=>{let n=this.listener("connecting").createConsumer();for(;;){if((await n.next()).done)break;e||(e=!0,r.addEventListener("beforeunload",t,!1))}})(),(async()=>{let n=this.listener("close").createConsumer();for(;;){if((await n.next()).done)break;e&&(e=!1,r.removeEventListener("beforeunload",t,!1))}})()},k.prototype._setAuthToken=function(t){this._changeToAuthenticatedState(t.token),(async()=>{try{await this.auth.saveToken(this.authTokenName,t.token,{})}catch(t){this._onError(t)}})()},k.prototype._removeAuthToken=function(){(async()=>{let t;try{t=await this.auth.removeToken(this.authTokenName)}catch(t){return void this._onError(t)}this.emit("removeAuthToken",{oldAuthToken:t})})(),this._changeToUnauthenticatedStateAndClearTokens()},k.prototype._privateDataHandlerMap={"#publish":function(t){let e=this._undecorateChannelName(t.channel);this.isSubscribed(e,!0)&&this._channelDataDemux.write(e,t.data)},"#kickOut":function(t){let e=this._undecorateChannelName(t.channel),r=this._channelMap[e];r&&(this.emit("kickOut",{channel:e,message:t.message}),this._channelEventDemux.write(`${e}/kickOut`,{message:t.message}),this._triggerChannelUnsubscribe(r))},"#setAuthToken":function(t){t&&this._setAuthToken(t)},"#removeAuthToken":function(t){this._removeAuthToken(t)}},k.prototype._privateRPCHandlerMap={"#setAuthToken":function(t,e){t?(this._setAuthToken(t),e.end()):e.error(new y("No token data provided by #setAuthToken event"))},"#removeAuthToken":function(t,e){this._removeAuthToken(t),e.end()}},k.prototype.getState=function(){return this.state},k.prototype.getBytesReceived=function(){return this.transport.getBytesReceived()},k.prototype.deauthenticate=async function(){(async()=>{let t;try{t=await this.auth.removeToken(this.authTokenName)}catch(t){return void this._onError(t)}this.emit("removeAuthToken",{oldAuthToken:t})})(),this.state!==this.CLOSED&&this.transmit("#removeAuthToken"),this._changeToUnauthenticatedStateAndClearTokens(),await f(0)},k.prototype.connect=function(){this.state===this.CLOSED&&(this.pendingReconnect=!1,this.pendingReconnectTimeout=null,clearTimeout(this._reconnectTimeoutRef),this.state=this.CONNECTING,this.emit("connecting",{}),this.transport&&this.transport.clearAllListeners(),this.transport=new u(this.auth,this.codec,this.options,this.wsOptions,{onOpen:t=>{this.state=this.OPEN,this._onOpen(t)},onOpenAbort:t=>{this.state!==this.CLOSED&&(this.state=this.CLOSED,this._destroy(t.code,t.reason,!0))},onClose:t=>{this.state!==this.CLOSED&&(this.state=this.CLOSED,this._destroy(t.code,t.reason))},onEvent:t=>{this.emit(t.event,t.data)},onError:t=>{this._onError(t.error)},onInboundInvoke:t=>{this._onInboundInvoke(t)},onInboundTransmit:t=>{this._onInboundTransmit(t.event,t.data)}}))},k.prototype.reconnect=function(t,e){this.disconnect(t,e),this.connect()},k.prototype.disconnect=function(t,e){if("number"!=typeof(t=t||1e3))throw new m("If specified, the code argument must be a number");let r=this.state===this.CONNECTING;r||this.state===this.OPEN?(this.state=this.CLOSED,this._destroy(t,e,r),this.transport.close(t,e)):(this.pendingReconnect=!1,this.pendingReconnectTimeout=null,clearTimeout(this._reconnectTimeoutRef))},k.prototype._changeToUnauthenticatedStateAndClearTokens=function(){if(this.authState!==this.UNAUTHENTICATED){let t=this.authState,e=this.authToken,r=this.signedAuthToken;this.authState=this.UNAUTHENTICATED,this.signedAuthToken=null,this.authToken=null;let n={oldAuthState:t,newAuthState:this.authState};this.emit("authStateChange",n),this.emit("deauthenticate",{oldSignedAuthToken:r,oldAuthToken:e})}},k.prototype._changeToAuthenticatedState=function(t){if(this.signedAuthToken=t,this.authToken=this._extractAuthTokenData(t),this.authState!==this.AUTHENTICATED){let e=this.authState;this.authState=this.AUTHENTICATED;let r={oldAuthState:e,newAuthState:this.authState,signedAuthToken:t,authToken:this.authToken};this.preparingPendingSubscriptions||this.processPendingSubscriptions(),this.emit("authStateChange",r)}this.emit("authenticate",{signedAuthToken:t,authToken:this.authToken})},k.prototype.decodeBase64=function(t){return p.from(t,"base64").toString("utf8")},k.prototype.encodeBase64=function(t){return p.from(t,"utf8").toString("base64")},k.prototype._extractAuthTokenData=function(t){let e=(t||"").split(".")[1];if(null!=e){let t=e;try{return t=this.decodeBase64(t),JSON.parse(t)}catch(e){return t}}return null},k.prototype.getAuthToken=function(){return this.authToken},k.prototype.getSignedAuthToken=function(){return this.signedAuthToken},k.prototype.authenticate=async function(t){let e;try{e=await this.invoke("#authenticate",t)}catch(t){throw"BadConnectionError"!==t.name&&"TimeoutError"!==t.name&&this._changeToUnauthenticatedStateAndClearTokens(),await f(0),t}return e&&null!=e.isAuthenticated?e.authError&&(e.authError=d.hydrateError(e.authError)):e={isAuthenticated:this.authState,authError:null},e.isAuthenticated?this._changeToAuthenticatedState(t):this._changeToUnauthenticatedStateAndClearTokens(),(async()=>{try{await this.auth.saveToken(this.authTokenName,t,{})}catch(t){this._onError(t)}})(),await f(0),e},k.prototype._tryReconnect=function(t){let e,r=this.connectAttempts++,n=this.options.autoReconnectOptions;if(null==t||r>0){let t=Math.round(n.initialDelay+(n.randomness||0)*Math.random());e=Math.round(t*Math.pow(n.multiplier,r))}else e=t;e>n.maxDelay&&(e=n.maxDelay),clearTimeout(this._reconnectTimeoutRef),this.pendingReconnect=!0,this.pendingReconnectTimeout=e,this._reconnectTimeoutRef=setTimeout(()=>{this.connect()},e)},k.prototype._onOpen=function(t){this.isBatching?this._startBatching():this.batchOnHandshake&&(this._startBatching(),setTimeout(()=>{this.isBatching||this._stopBatching()},this.batchOnHandshakeDuration)),this.preparingPendingSubscriptions=!0,t?(this.id=t.id,this.pingTimeout=t.pingTimeout,t.isAuthenticated?this._changeToAuthenticatedState(t.authToken):this._changeToUnauthenticatedStateAndClearTokens()):this._changeToUnauthenticatedStateAndClearTokens(),this.connectAttempts=0,this.options.autoSubscribeOnConnect&&this.processPendingSubscriptions(),this.emit("connect",{...t,processPendingSubscriptions:()=>{this.processPendingSubscriptions()}}),this.state===this.OPEN&&this._flushOutboundBuffer()},k.prototype._onError=function(t){this.emit("error",{error:t})},k.prototype._suspendSubscriptions=function(){Object.keys(this._channelMap).forEach(t=>{let e=this._channelMap[t];this._triggerChannelUnsubscribe(e,!0)})},k.prototype._abortAllPendingEventsDueToBadConnection=function(t){let e,r=this._outboundBuffer.head;for(;r;){e=r.next;let n=r.data;clearTimeout(n.timeout),delete n.timeout,r.detach(),r=e;let o=n.callback;if(o){delete n.callback;let e=`Event "${n.event}" was aborted due to a bad connection`,r=new v(e,t);o.call(n,r,n)}n.cid&&this.transport.cancelPendingResponse(n.cid)}},k.prototype._destroy=function(t,e,r){if(this.id=null,this._cancelBatching(),this.transport&&this.transport.clearAllListeners(),this.pendingReconnect=!1,this.pendingReconnectTimeout=null,clearTimeout(this._reconnectTimeoutRef),this._suspendSubscriptions(),r?this.emit("connectAbort",{code:t,reason:e}):this.emit("disconnect",{code:t,reason:e}),this.emit("close",{code:t,reason:e}),!k.ignoreStatuses[t]){let r;r=e?"Socket connection closed with status code "+t+" and reason: "+e:"Socket connection closed with status code "+t;let n=new g(k.errorStatuses[t]||r,t);this._onError(n)}this._abortAllPendingEventsDueToBadConnection(r?"connectAbort":"disconnect"),this.options.autoReconnect&&(4e3===t||4001===t||1005===t?this._tryReconnect(0):1e3!==t&&t<4500&&this._tryReconnect())},k.prototype._onInboundTransmit=function(t,e){let r=this._privateDataHandlerMap[t];r?r.call(this,e):this._receiverDemux.write(t,e)},k.prototype._onInboundInvoke=function(t){let{procedure:e,data:r}=t,n=this._privateRPCHandlerMap[e];n?n.call(this,r,t):this._procedureDemux.write(e,t)},k.prototype.decode=function(t){return this.transport.decode(t)},k.prototype.encode=function(t){return this.transport.encode(t)},k.prototype._flushOutboundBuffer=function(){let t,e=this._outboundBuffer.head;for(;e;){t=e.next;let r=e.data;e.detach(),this.transport.transmitObject(r),e=t}},k.prototype._handleEventAckTimeout=function(t,e){e&&e.detach(),delete t.timeout;let r=t.callback;if(r){delete t.callback;let e=new b(`Event response for "${t.event}" timed out`);r.call(t,e,t)}t.cid&&this.transport.cancelPendingResponse(t.cid)},k.prototype._processOutboundEvent=function(t,e,r,n){r=r||{},this.state===this.CLOSED&&this.connect();let o,i={event:t};o=n?new Promise((t,e)=>{i.callback=((r,n)=>{r?e(r):t(n)})}):Promise.resolve();let s=new h.Item;this.options.cloneData?i.data=l(e):i.data=e,s.data=i;let a=null==r.ackTimeout?this.ackTimeout:r.ackTimeout;return i.timeout=setTimeout(()=>{this._handleEventAckTimeout(i,s)},a),this._outboundBuffer.append(s),this.state===this.OPEN&&this._flushOutboundBuffer(),o},k.prototype.send=function(t){this.transport.send(t)},k.prototype.transmit=function(t,e,r){return this._processOutboundEvent(t,e,r)},k.prototype.invoke=function(t,e,r){return this._processOutboundEvent(t,e,r,!0)},k.prototype.transmitPublish=function(t,e){let r={channel:this._decorateChannelName(t),data:e};return this.transmit("#publish",r)},k.prototype.invokePublish=function(t,e){let r={channel:this._decorateChannelName(t),data:e};return this.invoke("#publish",r)},k.prototype._triggerChannelSubscribe=function(t,e){let r=t.name;if(t.state!==i.SUBSCRIBED){let n=t.state;t.state=i.SUBSCRIBED;let o={oldChannelState:n,newChannelState:t.state,subscriptionOptions:e};this._channelEventDemux.write(`${r}/subscribeStateChange`,o),this._channelEventDemux.write(`${r}/subscribe`,{subscriptionOptions:e}),this.emit("subscribeStateChange",{channel:r,...o}),this.emit("subscribe",{channel:r,subscriptionOptions:e})}},k.prototype._triggerChannelSubscribeFail=function(t,e,r){let n=e.name,o=!e.options.waitForAuth||this.authState===this.AUTHENTICATED;!!this._channelMap[n]&&o&&(delete this._channelMap[n],this._channelEventDemux.write(`${n}/subscribeFail`,{error:t,subscriptionOptions:r}),this.emit("subscribeFail",{error:t,channel:n,subscriptionOptions:r}))},k.prototype._cancelPendingSubscribeCallback=function(t){null!=t._pendingSubscriptionCid&&(this.transport.cancelPendingResponse(t._pendingSubscriptionCid),delete t._pendingSubscriptionCid)},k.prototype._decorateChannelName=function(t){return this.channelPrefix&&(t=this.channelPrefix+t),t},k.prototype._undecorateChannelName=function(t){return this.channelPrefix&&0===t.indexOf(this.channelPrefix)?t.replace(this.channelPrefix,""):t},k.prototype.startBatch=function(){this.transport.startBatch()},k.prototype.flushBatch=function(){this.transport.flushBatch()},k.prototype.cancelBatch=function(){this.transport.cancelBatch()},k.prototype._startBatching=function(){null==this._batchingIntervalId&&(this.startBatch(),this._batchingIntervalId=setInterval(()=>{this.flushBatch(),this.startBatch()},this.options.batchInterval))},k.prototype.startBatching=function(){this.isBatching=!0,this._startBatching()},k.prototype._stopBatching=function(){null!=this._batchingIntervalId&&clearInterval(this._batchingIntervalId),this._batchingIntervalId=null,this.flushBatch()},k.prototype.stopBatching=function(){this.isBatching=!1,this._stopBatching()},k.prototype._cancelBatching=function(){null!=this._batchingIntervalId&&clearInterval(this._batchingIntervalId),this._batchingIntervalId=null,this.cancelBatch()},k.prototype.cancelBatching=function(){this.isBatching=!1,this._cancelBatching()},k.prototype._trySubscribe=function(t){let e=!t.options.waitForAuth||this.authState===this.AUTHENTICATED;if(this.state===this.OPEN&&!this.preparingPendingSubscriptions&&null==t._pendingSubscriptionCid&&e){let e={noTimeout:!0},r={};t.options.waitForAuth&&(e.waitForAuth=!0,r.waitForAuth=e.waitForAuth),t.options.data&&(r.data=t.options.data),t._pendingSubscriptionCid=this.transport.invokeRaw("#subscribe",{channel:this._decorateChannelName(t.name),...r},e,e=>{if(e){if("BadConnectionError"===e.name)return;delete t._pendingSubscriptionCid,this._triggerChannelSubscribeFail(e,t,r)}else delete t._pendingSubscriptionCid,this._triggerChannelSubscribe(t,r)}),this.emit("subscribeRequest",{channel:t.name,subscriptionOptions:r})}},k.prototype.subscribe=function(t,e){e=e||{};let r=this._channelMap[t],n={waitForAuth:!!e.waitForAuth};return null!=e.priority&&(n.priority=e.priority),void 0!==e.data&&(n.data=e.data),r?e&&(r.options=n):(r={name:t,state:i.PENDING,options:n},this._channelMap[t]=r,this._trySubscribe(r)),new i(t,this,this._channelEventDemux,this._channelDataDemux)},k.prototype._triggerChannelUnsubscribe=function(t,e){let r=t.name;if(this._cancelPendingSubscribeCallback(t),t.state===i.SUBSCRIBED){let n={oldChannelState:t.state,newChannelState:e?i.PENDING:i.UNSUBSCRIBED};this._channelEventDemux.write(`${r}/subscribeStateChange`,n),this._channelEventDemux.write(`${r}/unsubscribe`,{}),this.emit("subscribeStateChange",{channel:r,...n}),this.emit("unsubscribe",{channel:r})}e?t.state=i.PENDING:delete this._channelMap[r]},k.prototype._tryUnsubscribe=function(t){if(this.state===this.OPEN){this._cancelPendingSubscribeCallback(t);let e=this._decorateChannelName(t.name);this.transport.transmit("#unsubscribe",e,{noTimeout:!0})}},k.prototype.unsubscribe=function(t){let e=this._channelMap[t];e&&(this._triggerChannelUnsubscribe(e),this._tryUnsubscribe(e))},k.prototype.receiver=function(t){return this._receiverDemux.stream(t)},k.prototype.closeReceiver=function(t){this._receiverDemux.close(t)},k.prototype.closeAllReceivers=function(){this._receiverDemux.closeAll()},k.prototype.killReceiver=function(t){this._receiverDemux.kill(t)},k.prototype.killAllReceivers=function(){this._receiverDemux.killAll()},k.prototype.killReceiverConsumer=function(t){this._receiverDemux.killConsumer(t)},k.prototype.getReceiverConsumerStats=function(t){return this._receiverDemux.getConsumerStats(t)},k.prototype.getReceiverConsumerStatsList=function(t){return this._receiverDemux.getConsumerStatsList(t)},k.prototype.getAllReceiversConsumerStatsList=function(){return this._receiverDemux.getConsumerStatsListAll()},k.prototype.getReceiverBackpressure=function(t){return this._receiverDemux.getBackpressure(t)},k.prototype.getAllReceiversBackpressure=function(){return this._receiverDemux.getBackpressureAll()},k.prototype.getReceiverConsumerBackpressure=function(t){return this._receiverDemux.getConsumerBackpressure(t)},k.prototype.hasReceiverConsumer=function(t,e){return this._receiverDemux.hasConsumer(t,e)},k.prototype.hasAnyReceiverConsumer=function(t){return this._receiverDemux.hasConsumerAll(t)},k.prototype.procedure=function(t){return this._procedureDemux.stream(t)},k.prototype.closeProcedure=function(t){this._procedureDemux.close(t)},k.prototype.closeAllProcedures=function(){this._procedureDemux.closeAll()},k.prototype.killProcedure=function(t){this._procedureDemux.kill(t)},k.prototype.killAllProcedures=function(){this._procedureDemux.killAll()},k.prototype.killProcedureConsumer=function(t){this._procedureDemux.killConsumer(t)},k.prototype.getProcedureConsumerStats=function(t){return this._procedureDemux.getConsumerStats(t)},k.prototype.getProcedureConsumerStatsList=function(t){return this._procedureDemux.getConsumerStatsList(t)},k.prototype.getAllProceduresConsumerStatsList=function(){return this._procedureDemux.getConsumerStatsListAll()},k.prototype.getProcedureBackpressure=function(t){return this._procedureDemux.getBackpressure(t)},k.prototype.getAllProceduresBackpressure=function(){return this._procedureDemux.getBackpressureAll()},k.prototype.getProcedureConsumerBackpressure=function(t){return this._procedureDemux.getConsumerBackpressure(t)},k.prototype.hasProcedureConsumer=function(t,e){return this._procedureDemux.hasConsumer(t,e)},k.prototype.hasAnyProcedureConsumer=function(t){return this._procedureDemux.hasConsumerAll(t)},k.prototype.channel=function(t){return this._channelMap[t],new i(t,this,this._channelEventDemux,this._channelDataDemux)},k.prototype.closeChannel=function(t){this.channelCloseOutput(t),this.channelCloseAllListeners(t)},k.prototype.closeAllChannelOutputs=function(){this._channelDataDemux.closeAll()},k.prototype.closeAllChannelListeners=function(){this._channelEventDemux.closeAll()},k.prototype.closeAllChannels=function(){this.closeAllChannelOutputs(),this.closeAllChannelListeners()},k.prototype.killChannel=function(t){this.channelKillOutput(t),this.channelKillAllListeners(t)},k.prototype.killAllChannelOutputs=function(){this._channelDataDemux.killAll()},k.prototype.killAllChannelListeners=function(){this._channelEventDemux.killAll()},k.prototype.killAllChannels=function(){this.killAllChannelOutputs(),this.killAllChannelListeners()},k.prototype.killChannelOutputConsumer=function(t){this._channelDataDemux.killConsumer(t)},k.prototype.killChannelListenerConsumer=function(t){this._channelEventDemux.killConsumer(t)},k.prototype.getChannelOutputConsumerStats=function(t){return this._channelDataDemux.getConsumerStats(t)},k.prototype.getChannelListenerConsumerStats=function(t){return this._channelEventDemux.getConsumerStats(t)},k.prototype.getAllChannelOutputsConsumerStatsList=function(){return this._channelDataDemux.getConsumerStatsListAll()},k.prototype.getAllChannelListenersConsumerStatsList=function(){return this._channelEventDemux.getConsumerStatsListAll()},k.prototype.getChannelBackpressure=function(t){return Math.max(this.channelGetOutputBackpressure(t),this.channelGetAllListenersBackpressure(t))},k.prototype.getAllChannelOutputsBackpressure=function(){return this._channelDataDemux.getBackpressureAll()},k.prototype.getAllChannelListenersBackpressure=function(){return this._channelEventDemux.getBackpressureAll()},k.prototype.getAllChannelsBackpressure=function(){return Math.max(this.getAllChannelOutputsBackpressure(),this.getAllChannelListenersBackpressure())},k.prototype.getChannelListenerConsumerBackpressure=function(t){return this._channelEventDemux.getConsumerBackpressure(t)},k.prototype.getChannelOutputConsumerBackpressure=function(t){return this._channelDataDemux.getConsumerBackpressure(t)},k.prototype.hasAnyChannelOutputConsumer=function(t){return this._channelDataDemux.hasConsumerAll(t)},k.prototype.hasAnyChannelListenerConsumer=function(t){return this._channelEventDemux.hasConsumerAll(t)},k.prototype.getChannelState=function(t){let e=this._channelMap[t];return e?e.state:i.UNSUBSCRIBED},k.prototype.getChannelOptions=function(t){let e=this._channelMap[t];return e?{...e.options}:{}},k.prototype._getAllChannelStreamNames=function(t){let e=this._channelEventDemux.getConsumerStatsListAll().filter(e=>0===e.stream.indexOf(`${t}/`)).reduce((t,e)=>(t[e.stream]=!0,t),{});return Object.keys(e)},k.prototype.channelCloseOutput=function(t){this._channelDataDemux.close(t)},k.prototype.channelCloseListener=function(t,e){this._channelEventDemux.close(`${t}/${e}`)},k.prototype.channelCloseAllListeners=function(t){this._getAllChannelStreamNames(t).forEach(t=>{this._channelEventDemux.close(t)})},k.prototype.channelKillOutput=function(t){this._channelDataDemux.kill(t)},k.prototype.channelKillListener=function(t,e){this._channelEventDemux.kill(`${t}/${e}`)},k.prototype.channelKillAllListeners=function(t){this._getAllChannelStreamNames(t).forEach(t=>{this._channelEventDemux.kill(t)})},k.prototype.channelGetOutputConsumerStatsList=function(t){return this._channelDataDemux.getConsumerStatsList(t)},k.prototype.channelGetListenerConsumerStatsList=function(t,e){return this._channelEventDemux.getConsumerStatsList(`${t}/${e}`)},k.prototype.channelGetAllListenersConsumerStatsList=function(t){return this._getAllChannelStreamNames(t).map(t=>this._channelEventDemux.getConsumerStatsList(t)).reduce((t,e)=>(e.forEach(e=>{t.push(e)}),t),[])},k.prototype.channelGetOutputBackpressure=function(t){return this._channelDataDemux.getBackpressure(t)},k.prototype.channelGetListenerBackpressure=function(t,e){return this._channelEventDemux.getBackpressure(`${t}/${e}`)},k.prototype.channelGetAllListenersBackpressure=function(t){let e=this._getAllChannelStreamNames(t).map(t=>this._channelEventDemux.getBackpressure(t));return Math.max(...e.concat(0))},k.prototype.channelHasOutputConsumer=function(t,e){return this._channelDataDemux.hasConsumer(t,e)},k.prototype.channelHasListenerConsumer=function(t,e,r){return this._channelEventDemux.hasConsumer(`${t}/${e}`,r)},k.prototype.channelHasAnyListenerConsumer=function(t,e){return this._getAllChannelStreamNames(t).some(t=>this._channelEventDemux.hasConsumer(t,e))},k.prototype.subscriptions=function(t){let e=[];return Object.keys(this._channelMap).forEach(r=>{(t||this._channelMap[r].state===i.SUBSCRIBED)&&e.push(r)}),e},k.prototype.isSubscribed=function(t,e){let r=this._channelMap[t];return e?!!r:!!r&&r.state===i.SUBSCRIBED},k.prototype.processPendingSubscriptions=function(){this.preparingPendingSubscriptions=!1;let t=[];Object.keys(this._channelMap).forEach(e=>{let r=this._channelMap[e];r.state===i.PENDING&&t.push(r)}),t.sort((t,e)=>{let r=t.options.priority||0,n=e.options.priority||0;return r>n?-1:r{this._trySubscribe(t)})},e.exports=k}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./auth":1,"./transport":4,"./wait":5,"ag-channel":7,"async-stream-emitter":9,"buffer/":11,"linked-list":15,"lodash.clonedeep":16,querystring:19,"sc-errors":21,"sc-formatter":22,"stream-demux":24}],3:[function(t,e){(function(r){const n=t("./clientsocket"),o=t("uuid"),i=t("sc-errors").InvalidArgumentsError;e.exports={create:function(t){if((t=t||{}).host&&!t.host.match(/[^:]+:\d{2,5}/))throw new i('The host option should include both the hostname and the port number in the format "hostname:port"');if(t.host&&t.hostname)throw new i('The host option should already include the hostname and the port number in the format "hostname:port" - Because of this, you should never use host and hostname options together');if(t.host&&t.port)throw new i('The host option should already include the hostname and the port number in the format "hostname:port" - Because of this, you should never use host and port options together');let e=r.location&&"https:"===location.protocol,s={clientId:o.v4(),port:function(t,e){let n=null==t.secure?e:t.secure;return t.port||(r.location&&location.port?location.port:n?443:80)}(t,e),hostname:r.location&&location.hostname||"localhost",secure:e};return Object.assign(s,t),new n(s)}}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./clientsocket":2,"sc-errors":21,uuid:25}],4:[function(t,e){(function(r){const n=t("ag-request"),o=t("querystring");let i,s;r.WebSocket?(i=r.WebSocket,s=function(t){return new i(t)}):(i=t("ws"),s=function(t,e){return new i(t,null,e)});const a=t("sc-errors"),u=a.TimeoutError,c=a.BadConnectionError;function h(t,e,r,n,o){this.state=this.CLOSED,this.auth=t,this.codec=e,this.options=r,this.wsOptions=n,this.protocolVersion=r.protocolVersion,this.connectTimeout=r.connectTimeout,this.pingTimeout=r.pingTimeout,this.pingTimeoutDisabled=!!r.pingTimeoutDisabled,this.callIdGenerator=r.callIdGenerator,this.authTokenName=r.authTokenName,this.isBufferingBatch=!1,this._pingTimeoutTicker=null,this._callbackMap={},this._batchBuffer=[],o||(o={}),this._onOpenHandler=o.onOpen||function(){},this._onOpenAbortHandler=o.onOpenAbort||function(){},this._onCloseHandler=o.onClose||function(){},this._onEventHandler=o.onEvent||function(){},this._onErrorHandler=o.onError||function(){},this._onInboundInvokeHandler=o.onInboundInvoke||function(){},this._onInboundTransmitHandler=o.onInboundTransmit||function(){},this.state=this.CONNECTING;let i=this.uri(),a=s(i,n);a.binaryType=this.options.binaryType,this.socket=a,a.onopen=(()=>{this._onOpen()}),a.onclose=(async t=>{let e;e=null==t.code?1005:t.code,this._destroy(e,t.reason)}),a.onmessage=(t=>{this._onMessage(t.data)}),a.onerror=(()=>{this.state===this.CONNECTING&&this._destroy(1006)}),this._connectTimeoutRef=setTimeout(()=>{this._destroy(4007),this.socket.close(4007)},this.connectTimeout),1===this.protocolVersion?this._handlePing=(t=>"#1"===t&&(this._resetPingTimeout(),this.socket.readyState===this.socket.OPEN&&this.send("#2"),!0)):this._handlePing=(t=>""===t&&(this._resetPingTimeout(),this.socket.readyState===this.socket.OPEN&&this.send(""),!0))}h.CONNECTING=h.prototype.CONNECTING="connecting",h.OPEN=h.prototype.OPEN="open",h.CLOSED=h.prototype.CLOSED="closed",h.prototype.uri=function(){let t,e=this.options.query||{},r=this.options.secure?"wss":"ws";if(this.options.timestampRequests&&(e[this.options.timestampParam]=(new Date).getTime()),(e=o.encode(e)).length&&(e="?"+e),this.options.host)t=this.options.host;else{let e="";this.options.port&&("wss"===r&&443!==this.options.port||"ws"===r&&80!==this.options.port)&&(e=":"+this.options.port),t=this.options.hostname+e}return r+"://"+t+this.options.path+e},h.prototype._onOpen=async function(){let t;clearTimeout(this._connectTimeoutRef),this._resetPingTimeout();try{t=await this._handshake()}catch(t){return null==t.statusCode&&(t.statusCode=4003),this._onError(t),this._destroy(t.statusCode,t.toString()),void this.socket.close(t.statusCode)}this.state=this.OPEN,t&&(this.pingTimeout=t.pingTimeout),this._resetPingTimeout(),this._onOpenHandler(t)},h.prototype._handshake=async function(){let t=await this.auth.loadToken(this.authTokenName),e=await this.invoke("#handshake",{authToken:t},{force:!0});return e&&(e.authToken=t,e.authError&&(e.authError=a.hydrateError(e.authError))),e},h.prototype._abortAllPendingEventsDueToBadConnection=function(t){Object.keys(this._callbackMap||{}).forEach(e=>{let r=this._callbackMap[e];delete this._callbackMap[e],clearTimeout(r.timeout),delete r.timeout;let n=`Event "${r.event}" was aborted due to a bad connection`,o=new c(n,t),i=r.callback;delete r.callback,i.call(r,o,r)})},h.prototype._destroy=function(t,e){a.socketProtocolErrorStatuses[t],!e&&a.socketProtocolErrorStatuses[t]&&(e=a.socketProtocolErrorStatuses[t]),delete this.socket.onopen,delete this.socket.onclose,delete this.socket.onmessage,delete this.socket.onerror,clearTimeout(this._connectTimeoutRef),clearTimeout(this._pingTimeoutTicker),this.state===this.OPEN?(this.state=this.CLOSED,this._abortAllPendingEventsDueToBadConnection("disconnect"),this._onCloseHandler({code:t,reason:e})):this.state===this.CONNECTING?(this.state=this.CLOSED,this._abortAllPendingEventsDueToBadConnection("connectAbort"),this._onOpenAbortHandler({code:t,reason:e})):this.state===this.CLOSED&&this._abortAllPendingEventsDueToBadConnection("connectAbort")},h.prototype._processInboundPacket=function(t,e){if(t&&null!=t.event)if(null==t.cid)this._onInboundTransmitHandler({...t});else{let e=new n(this,t.cid,t.event,t.data);this._onInboundInvokeHandler(e)}else if(t&&null!=t.rid){let e=this._callbackMap[t.rid];if(e&&(clearTimeout(e.timeout),delete e.timeout,delete this._callbackMap[t.rid],e.callback)){let r=a.hydrateError(t.error);e.callback(r,t.data)}}else this._onEventHandler({event:"raw",data:{message:e}})},h.prototype._onMessage=function(t){if(this._onEventHandler({event:"message",data:{message:t}}),this._handlePing(t))return;let e=this.decode(t);if(Array.isArray(e)){let r=e.length;for(let n=0;n{this._destroy(4e3),this.socket.close(4e3)},this.pingTimeout))},h.prototype.clearAllListeners=function(){this._onOpenHandler=function(){},this._onOpenAbortHandler=function(){},this._onCloseHandler=function(){},this._onEventHandler=function(){},this._onErrorHandler=function(){},this._onInboundInvokeHandler=function(){},this._onInboundTransmitHandler=function(){}},h.prototype.startBatch=function(){this.isBufferingBatch=!0,this._batchBuffer=[]},h.prototype.flushBatch=function(){if(this.isBufferingBatch=!1,!this._batchBuffer.length)return;let t=this.serializeObject(this._batchBuffer);this._batchBuffer=[],this.send(t)},h.prototype.cancelBatch=function(){this.isBufferingBatch=!1,this._batchBuffer=[]},h.prototype.getBytesReceived=function(){return this.socket.bytesReceived},h.prototype.close=function(t,e){this.state!==this.OPEN&&this.state!==this.CONNECTING||(t=t||1e3,this._destroy(t,e),this.socket.close(t,e))},h.prototype.transmitObject=function(t){let e={event:t.event,data:t.data};return t.callback&&(e.cid=t.cid=this.callIdGenerator(),this._callbackMap[t.cid]=t),this.sendObject(e),t.cid||null},h.prototype._handleEventAckTimeout=function(t){t.cid&&delete this._callbackMap[t.cid],delete t.timeout;let e=t.callback;if(e){delete t.callback;let r=new u(`Event response for "${t.event}" timed out`);e.call(t,r,t)}},h.prototype.transmit=function(t,e,r){return(this.state===this.OPEN||r.force)&&this.transmitObject({event:t,data:e}),Promise.resolve()},h.prototype.invokeRaw=function(t,e,r,n){let o={event:t,data:e,callback:n};r.noTimeout||(o.timeout=setTimeout(()=>{this._handleEventAckTimeout(o)},this.options.ackTimeout));let i=null;return(this.state===this.OPEN||r.force)&&(i=this.transmitObject(o)),i},h.prototype.invoke=function(t,e,r){return new Promise((n,o)=>{this.invokeRaw(t,e,r,(t,e)=>{t?o(t):n(e)})})},h.prototype.cancelPendingResponse=function(t){delete this._callbackMap[t]},h.prototype.decode=function(t){return this.codec.decode(t)},h.prototype.encode=function(t){return this.codec.encode(t)},h.prototype.send=function(t){this.socket.readyState!==this.socket.OPEN?this._destroy(1005):this.socket.send(t)},h.prototype.serializeObject=function(t){let e;try{e=this.encode(t)}catch(t){return this._onError(t),null}return e},h.prototype.sendObject=function(t){if(this.isBufferingBatch)return void this._batchBuffer.push(t);let e=this.serializeObject(t);null!=e&&this.send(e)},e.exports=h}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"ag-request":8,querystring:19,"sc-errors":21,ws:6}],5:[function(t,e){e.exports=function(t){return new Promise(e=>{setTimeout(()=>{e()},t)})}},{}],6:[function(t,e){let r;const n=(r="undefined"!=typeof WorkerGlobalScope?self:"undefined"!=typeof window&&window||function(){return this}()).WebSocket||r.MozWebSocket;function o(t,e){let r;return r=e?new n(t,e):new n(t)}n&&(o.prototype=n.prototype),e.exports=n?o:null},{}],7:[function(t,e){const r=t("consumable-stream");class n extends r{constructor(t,e,r,o){super(),this.PENDING=n.PENDING,this.SUBSCRIBED=n.SUBSCRIBED,this.UNSUBSCRIBED=n.UNSUBSCRIBED,this.name=t,this.client=e,this._eventDemux=r,this._dataStream=o.stream(this.name)}createConsumer(t){return this._dataStream.createConsumer(t)}listener(t){return this._eventDemux.stream(`${this.name}/${t}`)}close(){this.client.closeChannel(this.name)}kill(){this.client.killChannel(this.name)}killOutputConsumer(t){this.hasOutputConsumer(t)&&this.client.killChannelOutputConsumer(t)}killListenerConsumer(t){this.hasAnyListenerConsumer(t)&&this.client.killChannelListenerConsumer(t)}getOutputConsumerStats(t){if(this.hasOutputConsumer(t))return this.client.getChannelOutputConsumerStats(t)}getListenerConsumerStats(t){if(this.hasAnyListenerConsumer(t))return this.client.getChannelListenerConsumerStats(t)}getBackpressure(){return this.client.getChannelBackpressure(this.name)}getListenerConsumerBackpressure(t){return this.hasAnyListenerConsumer(t)?this.client.getChannelListenerConsumerBackpressure(t):0}getOutputConsumerBackpressure(t){return this.hasOutputConsumer(t)?this.client.getChannelOutputConsumerBackpressure(t):0}closeOutput(){this.client.channelCloseOutput(this.name)}closeListener(t){this.client.channelCloseListener(this.name,t)}closeAllListeners(){this.client.channelCloseAllListeners(this.name)}killOutput(){this.client.channelKillOutput(this.name)}killListener(t){this.client.channelKillListener(this.name,t)}killAllListeners(){this.client.channelKillAllListeners(this.name)}getOutputConsumerStatsList(){return this.client.channelGetOutputConsumerStatsList(this.name)}getListenerConsumerStatsList(t){return this.client.channelGetListenerConsumerStatsList(this.name,t)}getAllListenersConsumerStatsList(){return this.client.channelGetAllListenersConsumerStatsList(this.name)}getOutputBackpressure(){return this.client.channelGetOutputBackpressure(this.name)}getListenerBackpressure(t){return this.client.channelGetListenerBackpressure(this.name,t)}getAllListenersBackpressure(){return this.client.channelGetAllListenersBackpressure(this.name)}hasOutputConsumer(t){return this.client.channelHasOutputConsumer(this.name,t)}hasListenerConsumer(t,e){return this.client.channelHasListenerConsumer(this.name,t,e)}hasAnyListenerConsumer(t){return this.client.channelHasAnyListenerConsumer(this.name,t)}get state(){return this.client.getChannelState(this.name)}set state(t){throw new Error("Cannot directly set channel state")}get options(){return this.client.getChannelOptions(this.name)}set options(t){throw new Error("Cannot directly set channel options")}subscribe(t){this.client.subscribe(this.name,t)}unsubscribe(){this.client.unsubscribe(this.name)}isSubscribed(t){return this.client.isSubscribed(this.name,t)}transmitPublish(t){return this.client.transmitPublish(this.name,t)}invokePublish(t){return this.client.invokePublish(this.name,t)}}n.PENDING="pending",n.SUBSCRIBED="subscribed",n.UNSUBSCRIBED="unsubscribed",e.exports=n},{"consumable-stream":12}],8:[function(t,e){const r=t("sc-errors"),n=r.InvalidActionError;e.exports=function(t,e,o,i){this.socket=t,this.id=e,this.procedure=o,this.data=i,this.sent=!1,this._respond=((t,e)=>{if(this.sent)throw new n(`Response to request ${this.id} has already been sent`);this.sent=!0,this.socket.sendObject(t,e)}),this.end=((t,e)=>{let r={rid:this.id};void 0!==t&&(r.data=t),this._respond(r,e)}),this.error=((t,e)=>{let n={rid:this.id,error:r.dehydrateError(t)};this._respond(n,e)})}},{"sc-errors":21}],9:[function(t,e){const r=t("stream-demux");function n(){this._listenerDemux=new r}n.prototype.emit=function(t,e){this._listenerDemux.write(t,e)},n.prototype.listener=function(t){return this._listenerDemux.stream(t)},n.prototype.closeListener=function(t){this._listenerDemux.close(t)},n.prototype.closeAllListeners=function(){this._listenerDemux.closeAll()},n.prototype.getListenerConsumerStats=function(t){return this._listenerDemux.getConsumerStats(t)},n.prototype.getListenerConsumerStatsList=function(t){return this._listenerDemux.getConsumerStatsList(t)},n.prototype.getAllListenersConsumerStatsList=function(){return this._listenerDemux.getConsumerStatsListAll()},n.prototype.killListener=function(t){this._listenerDemux.kill(t)},n.prototype.killAllListeners=function(){this._listenerDemux.killAll()},n.prototype.killListenerConsumer=function(t){this._listenerDemux.killConsumer(t)},n.prototype.getListenerBackpressure=function(t){return this._listenerDemux.getBackpressure(t)},n.prototype.getAllListenersBackpressure=function(){return this._listenerDemux.getBackpressureAll()},n.prototype.getListenerConsumerBackpressure=function(t){return this._listenerDemux.getConsumerBackpressure(t)},n.prototype.hasListenerConsumer=function(t,e){return this._listenerDemux.hasConsumer(t,e)},n.prototype.hasAnyListenerConsumer=function(t){return this._listenerDemux.hasConsumerAll(t)},e.exports=n},{"stream-demux":24}],10:[function(t,e,r){"use strict";r.byteLength=function(t){var e=c(t),r=e[0],n=e[1];return 3*(r+n)/4-n},r.toByteArray=function(t){var e,r,n=c(t),s=n[0],a=n[1],u=new i(function(t,e,r){return 3*(e+r)/4-r}(0,s,a)),h=0,l=a>0?s-4:s;for(r=0;r>16&255,u[h++]=e>>8&255,u[h++]=255&e;2===a&&(e=o[t.charCodeAt(r)]<<2|o[t.charCodeAt(r+1)]>>4,u[h++]=255&e);1===a&&(e=o[t.charCodeAt(r)]<<10|o[t.charCodeAt(r+1)]<<4|o[t.charCodeAt(r+2)]>>2,u[h++]=e>>8&255,u[h++]=255&e);return u},r.fromByteArray=function(t){for(var e,r=t.length,o=r%3,i=[],s=0,a=r-o;sa?a:s+16383));1===o?(e=t[r-1],i.push(n[e>>2]+n[e<<4&63]+"==")):2===o&&(e=(t[r-2]<<8)+t[r-1],i.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return i.join("")};for(var n=[],o=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,u=s.length;a0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function h(t,e,r){for(var o,i,s=[],a=e;a>18&63]+n[i>>12&63]+n[i>>6&63]+n[63&i]);return s.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},{}],11:[function(t,e,r){(function(e){"use strict";var n=t("base64-js"),o=t("ieee754"),i="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;r.Buffer=e,r.SlowBuffer=function(t){+t!=t&&(t=0);return e.alloc(+t)},r.INSPECT_MAX_BYTES=50;var s=2147483647;function a(t){if(t>s)throw new RangeError('The value "'+t+'" is invalid for option "size"');var r=new Uint8Array(t);return Object.setPrototypeOf(r,e.prototype),r}function e(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return h(t)}return u(t,e,r)}function u(t,r,n){if("string"==typeof t)return function(t,r){"string"==typeof r&&""!==r||(r="utf8");if(!e.isEncoding(r))throw new TypeError("Unknown encoding: "+r);var n=0|f(t,r),o=a(n),i=o.write(t,r);i!==n&&(o=o.slice(0,i));return o}(t,r);if(ArrayBuffer.isView(t))return l(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(H(t,ArrayBuffer)||t&&H(t.buffer,ArrayBuffer))return function(t,r,n){if(r<0||t.byteLength=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return 0|t}function f(t,r){if(e.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||H(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var n=t.length,o=arguments.length>2&&!0===arguments[2];if(!o&&0===n)return 0;for(var i=!1;;)switch(r){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return U(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return R(t).length;default:if(i)return o?-1:U(t).length;r=(""+r).toLowerCase(),i=!0}}function d(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function m(t,r,n,o,i){if(0===t.length)return-1;if("string"==typeof n?(o=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),G(n=+n)&&(n=i?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(i)return-1;n=t.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof r&&(r=e.from(r,o)),e.isBuffer(r))return 0===r.length?-1:y(t,r,n,o,i);if("number"==typeof r)return r&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,r,n):Uint8Array.prototype.lastIndexOf.call(t,r,n):y(t,[r],n,o,i);throw new TypeError("val must be string, number or Buffer")}function y(t,e,r,n,o){var i,s=1,a=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;s=2,a/=2,u/=2,r/=2}function c(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(o){var h=-1;for(i=r;ia&&(r=a-u),i=r;i>=0;i--){for(var l=!0,p=0;po&&(n=o):n=o;var i=e.length;n>i/2&&(n=i/2);for(var s=0;s>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function w(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function C(t,e,r){r=Math.min(t.length,r);for(var n=[],o=e;o239?4:c>223?3:c>191?2:1;if(o+l<=r)switch(l){case 1:c<128&&(h=c);break;case 2:128==(192&(i=t[o+1]))&&(u=(31&c)<<6|63&i)>127&&(h=u);break;case 3:i=t[o+1],s=t[o+2],128==(192&i)&&128==(192&s)&&(u=(15&c)<<12|(63&i)<<6|63&s)>2047&&(u<55296||u>57343)&&(h=u);break;case 4:i=t[o+1],s=t[o+2],a=t[o+3],128==(192&i)&&128==(192&s)&&128==(192&a)&&(u=(15&c)<<18|(63&i)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(h=u)}null===h?(h=65533,l=1):h>65535&&(h-=65536,n.push(h>>>10&1023|55296),h=56320|1023&h),n.push(h),o+=l}return function(t){var e=t.length;if(e<=S)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return B(this,e,r);case"utf8":case"utf-8":return C(this,e,r);case"ascii":return T(this,e,r);case"latin1":case"binary":return A(this,e,r);case"base64":return w(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return O(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},e.prototype.toLocaleString=e.prototype.toString,e.prototype.equals=function(t){if(!e.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===e.compare(this,t)},e.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),""},i&&(e.prototype[i]=e.prototype.inspect),e.prototype.compare=function(t,r,n,o,i){if(H(t,Uint8Array)&&(t=e.from(t,t.offset,t.byteLength)),!e.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===r&&(r=0),void 0===n&&(n=t?t.length:0),void 0===o&&(o=0),void 0===i&&(i=this.length),r<0||n>t.length||o<0||i>this.length)throw new RangeError("out of range index");if(o>=i&&r>=n)return 0;if(o>=i)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,o>>>=0,i>>>=0,this===t)return 0;for(var s=i-o,a=n-r,u=Math.min(s,a),c=this.slice(o,i),h=t.slice(r,n),l=0;l>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return g(this,t,e,r);case"utf8":case"utf-8":return b(this,t,e,r);case"ascii":return v(this,t,e,r);case"latin1":case"binary":return _(this,t,e,r);case"base64":return k(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return E(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},e.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var S=4096;function T(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;on)&&(r=n);for(var o="",i=e;ir)throw new RangeError("Trying to access beyond buffer length")}function I(t,r,n,o,i,s){if(!e.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>i||rt.length)throw new RangeError("Index out of range")}function D(t,e,r,n){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function L(t,e,r,n,i){return e=+e,r>>>=0,i||D(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function N(t,e,r,n,i){return e=+e,r>>>=0,i||D(t,0,r,8),o.write(t,e,r,n,52,8),r+8}e.prototype.slice=function(t,r){var n=this.length;t=~~t,r=void 0===r?n:~~r,t<0?(t+=n)<0&&(t=0):t>n&&(t=n),r<0?(r+=n)<0&&(r=0):r>n&&(r=n),r>>=0,e>>>=0,r||x(t,e,this.length);for(var n=this[t],o=1,i=0;++i>>=0,e>>>=0,r||x(t,e,this.length);for(var n=this[t+--e],o=1;e>0&&(o*=256);)n+=this[t+--e]*o;return n},e.prototype.readUInt8=function(t,e){return t>>>=0,e||x(t,1,this.length),this[t]},e.prototype.readUInt16LE=function(t,e){return t>>>=0,e||x(t,2,this.length),this[t]|this[t+1]<<8},e.prototype.readUInt16BE=function(t,e){return t>>>=0,e||x(t,2,this.length),this[t]<<8|this[t+1]},e.prototype.readUInt32LE=function(t,e){return t>>>=0,e||x(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},e.prototype.readUInt32BE=function(t,e){return t>>>=0,e||x(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},e.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||x(t,e,this.length);for(var n=this[t],o=1,i=0;++i=(o*=128)&&(n-=Math.pow(2,8*e)),n},e.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||x(t,e,this.length);for(var n=e,o=1,i=this[t+--n];n>0&&(o*=256);)i+=this[t+--n]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*e)),i},e.prototype.readInt8=function(t,e){return t>>>=0,e||x(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},e.prototype.readInt16LE=function(t,e){t>>>=0,e||x(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},e.prototype.readInt16BE=function(t,e){t>>>=0,e||x(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},e.prototype.readInt32LE=function(t,e){return t>>>=0,e||x(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},e.prototype.readInt32BE=function(t,e){return t>>>=0,e||x(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},e.prototype.readFloatLE=function(t,e){return t>>>=0,e||x(t,4,this.length),o.read(this,t,!0,23,4)},e.prototype.readFloatBE=function(t,e){return t>>>=0,e||x(t,4,this.length),o.read(this,t,!1,23,4)},e.prototype.readDoubleLE=function(t,e){return t>>>=0,e||x(t,8,this.length),o.read(this,t,!0,52,8)},e.prototype.readDoubleBE=function(t,e){return t>>>=0,e||x(t,8,this.length),o.read(this,t,!1,52,8)},e.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||I(this,t,e,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n)||I(this,t,e,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},e.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||I(this,t,e,1,255,0),this[e]=255&t,e+1},e.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||I(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},e.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||I(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},e.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||I(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},e.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||I(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},e.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);I(this,t,e,r,o-1,-o)}var i=0,s=1,a=0;for(this[e]=255&t;++i>0)-a&255;return e+r},e.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);I(this,t,e,r,o-1,-o)}var i=r-1,s=1,a=0;for(this[e+i]=255&t;--i>=0&&(s*=256);)t<0&&0===a&&0!==this[e+i+1]&&(a=1),this[e+i]=(t/s>>0)-a&255;return e+r},e.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||I(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},e.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||I(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},e.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||I(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},e.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||I(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},e.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||I(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},e.prototype.writeFloatLE=function(t,e,r){return L(this,t,e,!0,r)},e.prototype.writeFloatBE=function(t,e,r){return L(this,t,e,!1,r)},e.prototype.writeDoubleLE=function(t,e,r){return N(this,t,e,!0,r)},e.prototype.writeDoubleBE=function(t,e,r){return N(this,t,e,!1,r)},e.prototype.copy=function(t,r,n,o){if(!e.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),o||0===o||(o=this.length),r>=t.length&&(r=t.length),r||(r=0),o>0&&o=this.length)throw new RangeError("Index out of range");if(o<0)throw new RangeError("sourceEnd out of bounds");o>this.length&&(o=this.length),t.length-r=0;--s)t[s+r]=this[s+n];else Uint8Array.prototype.set.call(t,this.subarray(n,o),r);return i},e.prototype.fill=function(t,r,n,o){if("string"==typeof t){if("string"==typeof r?(o=r,r=0,n=this.length):"string"==typeof n&&(o=n,n=this.length),void 0!==o&&"string"!=typeof o)throw new TypeError("encoding must be a string");if("string"==typeof o&&!e.isEncoding(o))throw new TypeError("Unknown encoding: "+o);if(1===t.length){var i=t.charCodeAt(0);("utf8"===o&&i<128||"latin1"===o)&&(t=i)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(r<0||this.length>>=0,n=void 0===n?this.length:n>>>0,t||(t=0),"number"==typeof t)for(s=r;s55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(s+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function R(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(P,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function M(t,e,r,n){for(var o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function H(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function G(t){return t!=t}}).call(this,t("buffer").Buffer)},{"base64-js":10,buffer:11,ieee754:13}],12:[function(t,e){e.exports=class{async next(t){let e=this.createConsumer(t),r=await e.next();return e.return(),r}async once(t){let e=await this.next(t);return e.done&&await new Promise(()=>{}),e.value}createConsumer(){throw new TypeError("Method must be overriden by subclass")}createConsumable(t){let e=this.createConsumer(t);return{[Symbol.asyncIterator]:()=>e}}[Symbol.asyncIterator](){return this.createConsumer()}}},{}],13:[function(t,e,r){r.read=function(t,e,r,n,o){var i,s,a=8*o-n-1,u=(1<>1,h=-7,l=r?o-1:0,p=r?-1:1,f=t[e+l];for(l+=p,i=f&(1<<-h)-1,f>>=-h,h+=a;h>0;i=256*i+t[e+l],l+=p,h-=8);for(s=i&(1<<-h)-1,i>>=-h,h+=n;h>0;s=256*s+t[e+l],l+=p,h-=8);if(0===i)i=1-c;else{if(i===u)return s?NaN:1/0*(f?-1:1);s+=Math.pow(2,n),i-=c}return(f?-1:1)*s*Math.pow(2,i-n)},r.write=function(t,e,r,n,o,i){var s,a,u,c=8*i-o-1,h=(1<>1,p=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,f=n?0:i-1,d=n?1:-1,m=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=h):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),(e+=s+l>=1?p/u:p*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=h?(a=0,s=h):s+l>=1?(a=(e*u-1)*Math.pow(2,o),s+=l):(a=e*Math.pow(2,l-1)*Math.pow(2,o),s=0));o>=8;t[r+f]=255&a,f+=d,a/=256,o-=8);for(s=s<0;t[r+f]=255&s,f+=d,s/=256,c-=8);t[r+f-d]|=128*m}},{}],14:[function(t,e){"use strict";var r="An argument without append, prepend, or detach methods was given to `List";function n(){if(arguments.length)return n.from(arguments)}var o=n.prototype;function i(){}n.of=function(){return n.from.call(this,arguments)},n.from=function(t){var e,r,n,o=new this;if(t&&(e=t.length))for(r=-1;++r-1},Ct.prototype.set=function(t,e){var r=this.__data__,n=Ot(r,t);return n<0?r.push([t,e]):r[n][1]=e,this},St.prototype.clear=function(){this.__data__={hash:new wt,map:new(lt||Ct),string:new wt}},St.prototype.delete=function(t){return Nt(this,t).delete(t)},St.prototype.get=function(t){return Nt(this,t).get(t)},St.prototype.has=function(t){return Nt(this,t).has(t)},St.prototype.set=function(t,e){return Nt(this,t).set(t,e),this},Tt.prototype.clear=function(){this.__data__=new Ct},Tt.prototype.delete=function(t){return this.__data__.delete(t)},Tt.prototype.get=function(t){return this.__data__.get(t)},Tt.prototype.has=function(t){return this.__data__.has(t)},Tt.prototype.set=function(t,e){var r=this.__data__;if(r instanceof Ct){var n=r.__data__;if(!lt||n.length<199)return n.push([t,e]),this;r=this.__data__=new St(n)}return r.set(t,e),this};var jt=at?$(at,Object):function(){return[]},Ut=function(t){return Z.call(t)};function Rt(t,e){return!!(e=null==e?n:e)&&("number"==typeof t||O.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=n}(t.length)&&!zt(t)}var qt=ut||function(){return!1};function zt(t){var e=Vt(t)?Z.call(t):"";return e==a||e==u}function Vt(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function Wt(t){return Ft(t)?At(t):function(t){if(!Mt(t))return ct(t);var e=[];for(var r in Object(t))X.call(t,r)&&"constructor"!=r&&e.push(r);return e}(t)}e.exports=function(t){return xt(t,!0,!0)}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],17:[function(t,e){"use strict";function r(t,e){return Object.prototype.hasOwnProperty.call(t,e)}e.exports=function(t,e,o,i){e=e||"&",o=o||"=";var s={};if("string"!=typeof t||0===t.length)return s;var a=/\+/g;t=t.split(e);var u=1e3;i&&"number"==typeof i.maxKeys&&(u=i.maxKeys);var c=t.length;u>0&&c>u&&(c=u);for(var h=0;h=0?(l=m.substr(0,y),p=m.substr(y+1)):(l=m,p=""),f=decodeURIComponent(l),d=decodeURIComponent(p),r(s,f)?n(s[f])?s[f].push(d):s[f]=[s[f],d]:s[f]=d}return s};var n=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)}},{}],18:[function(t,e){"use strict";var r=function(t){switch(typeof t){case"string":return t;case"boolean":return t?"true":"false";case"number":return isFinite(t)?t:"";default:return""}};e.exports=function(t,e,s,a){return e=e||"&",s=s||"=",null===t&&(t=void 0),"object"==typeof t?o(i(t),function(i){var a=encodeURIComponent(r(i))+s;return n(t[i])?o(t[i],function(t){return a+encodeURIComponent(r(t))}).join(e):a+encodeURIComponent(r(t[i]))}).join(e):a?encodeURIComponent(r(a))+s+encodeURIComponent(r(t)):""};var n=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function o(t,e){if(t.map)return t.map(e);for(var r=[],n=0;n>2],o+=r[(3&e[i])<<4|e[i+1]>>4],o+=r[(15&e[i+1])<<2|e[i+2]>>6],o+=r[63&e[i+2]];return n%3==2?o=o.substring(0,o.length-1)+"=":n%3==1&&(o=o.substring(0,o.length-2)+"=="),o}(n)};if(t.Buffer){if(n instanceof t.Buffer)return{base64:!0,data:n.toString("base64")};if(n&&"Buffer"===n.type&&Array.isArray(n.data))return{base64:!0,data:(t.Buffer.from?t.Buffer.from(n.data):new t.Buffer(n.data)).toString("base64")}}return n};e.exports.decode=function(t){if(null==t)return null;if("#1"===t||"#2"===t)return t;var e=t.toString();if(!n.test(e))return e;try{return JSON.parse(e)}catch(t){}return e},e.exports.encode=function(t){return"#1"===t||"#2"===t?t:JSON.stringify(t,o)}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],23:[function(t,e){const r=t("consumable-stream");e.exports=class extends r{constructor(t,e){super(),this.name=e,this._streamDemux=t}createConsumer(t){return this._streamDemux.createConsumer(this.name,t)}}},{"consumable-stream":12}],24:[function(t,e){const r=t("writable-consumable-stream"),n=t("./demuxed-consumable-stream");e.exports=class{constructor(){this._mainStream=new r}write(t,e){this._mainStream.write({stream:t,data:{value:e,done:!1}})}close(t,e){this._mainStream.write({stream:t,data:{value:e,done:!0}})}closeAll(t){this._mainStream.close(t)}writeToConsumer(t,e){this._mainStream.writeToConsumer(t,{consumerId:t,data:{value:e,done:!1}})}closeConsumer(t,e){this._mainStream.closeConsumer(t,{consumerId:t,data:{value:e,done:!0}})}getConsumerStats(t){return this._mainStream.getConsumerStats(t)}getConsumerStatsList(t){return this._mainStream.getConsumerStatsList().filter(e=>e.stream===t)}getConsumerStatsListAll(){return this._mainStream.getConsumerStatsList()}kill(t,e){let r=this.getConsumerStatsList(t),n=r.length;for(let t=0;tn&&(n=r.backpressure)}return n}getBackpressureAll(){return this._mainStream.getBackpressure()}getConsumerBackpressure(t){return this._mainStream.getConsumerBackpressure(t)}hasConsumer(t,e){let r=this._mainStream.getConsumerStats(e);return!!r&&r.stream===t}hasConsumerAll(t){return this._mainStream.hasConsumer(t)}createConsumer(t,e){let r=this._mainStream.createConsumer(e),n=r.next;r.next=async function(){for(;;){let e=await n.apply(this,arguments);if(e.value&&(e.value.stream===t||e.value.consumerId===this.id))return e.value.data.done&&this.return(),e.value.data;if(e.done)return e}};let o=r.getStats;r.getStats=function(){let e=o.apply(this,arguments);return e.stream=t,e};let i=r.applyBackpressure;r.applyBackpressure=function(e){!e.value||e.value.stream!==t&&e.value.consumerId!==this.id?e.done&&i.apply(this,arguments):i.apply(this,arguments)};let s=r.releaseBackpressure;return r.releaseBackpressure=function(e){!e.value||e.value.stream!==t&&e.value.consumerId!==this.id?e.done&&s.apply(this,arguments):s.apply(this,arguments)},r}stream(t){return new n(this,t)}}},{"./demuxed-consumable-stream":23,"writable-consumable-stream":31}],25:[function(t,e){var r=t("./v1"),n=t("./v4"),o=n;o.v1=r,o.v4=n,e.exports=o},{"./v1":28,"./v4":29}],26:[function(t,e){for(var r=[],n=0;n<256;++n)r[n]=(n+256).toString(16).substr(1);e.exports=function(t,e){var n=e||0,o=r;return[o[t[n++]],o[t[n++]],o[t[n++]],o[t[n++]],"-",o[t[n++]],o[t[n++]],"-",o[t[n++]],o[t[n++]],"-",o[t[n++]],o[t[n++]],"-",o[t[n++]],o[t[n++]],o[t[n++]],o[t[n++]],o[t[n++]],o[t[n++]]].join("")}},{}],27:[function(t,e){var r="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(r){var n=new Uint8Array(16);e.exports=function(){return r(n),n}}else{var o=new Array(16);e.exports=function(){for(var t,e=0;e<16;e++)0==(3&e)&&(t=4294967296*Math.random()),o[e]=t>>>((3&e)<<3)&255;return o}}},{}],28:[function(t,e){var r,n,o=t("./lib/rng"),i=t("./lib/bytesToUuid"),s=0,a=0;e.exports=function(t,e,u){var c=e&&u||0,h=e||[],l=(t=t||{}).node||r,p=void 0!==t.clockseq?t.clockseq:n;if(null==l||null==p){var f=o();null==l&&(l=r=[1|f[0],f[1],f[2],f[3],f[4],f[5]]),null==p&&(p=n=16383&(f[6]<<8|f[7]))}var d=void 0!==t.msecs?t.msecs:(new Date).getTime(),m=void 0!==t.nsecs?t.nsecs:a+1,y=d-s+(m-a)/1e4;if(y<0&&void 0===t.clockseq&&(p=p+1&16383),(y<0||d>s)&&void 0===t.nsecs&&(m=0),m>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");s=d,a=m,n=p;var g=(1e4*(268435455&(d+=122192928e5))+m)%4294967296;h[c++]=g>>>24&255,h[c++]=g>>>16&255,h[c++]=g>>>8&255,h[c++]=255&g;var b=d/4294967296*1e4&268435455;h[c++]=b>>>8&255,h[c++]=255&b,h[c++]=b>>>24&15|16,h[c++]=b>>>16&255,h[c++]=p>>>8|128,h[c++]=255&p;for(var v=0;v<6;++v)h[c+v]=l[v];return e||i(h)}},{"./lib/bytesToUuid":26,"./lib/rng":27}],29:[function(t,e){var r=t("./lib/rng"),n=t("./lib/bytesToUuid");e.exports=function(t,e,o){var i=e&&o||0;"string"==typeof t&&(e="binary"===t?new Array(16):null,t=null);var s=(t=t||{}).random||(t.rng||r)();if(s[6]=15&s[6]|64,s[8]=63&s[8]|128,e)for(var a=0;a<16;++a)e[i+a]=s[a];return e||n(s)}},{"./lib/bytesToUuid":26,"./lib/rng":27}],30:[function(t,e){e.exports=class{constructor(t,e,r,n){this.id=e,this._backpressure=0,this.stream=t,this.currentNode=r,this.timeout=n,this._isIterating=!1,this.stream.setConsumer(this.id,this)}getStats(){let t={id:this.id,backpressure:this._backpressure};return null!=this.timeout&&(t.timeout=this.timeout),t}resetBackpressure(){this._backpressure=0}applyBackpressure(t){this._backpressure++}releaseBackpressure(t){this._backpressure--}getBackpressure(){return this._backpressure}write(t){void 0!==this._timeoutId&&(clearTimeout(this._timeoutId),delete this._timeoutId),this.applyBackpressure(t),this._resolve&&(this._resolve(),delete this._resolve)}kill(t){void 0!==this._timeoutId&&(clearTimeout(this._timeoutId),delete this._timeoutId),this._isIterating?(this._killPacket={value:t,done:!0},this.applyBackpressure(this._killPacket)):(this.stream.removeConsumer(this.id),this.resetBackpressure()),this._resolve&&(this._resolve(),delete this._resolve)}async _waitForNextItem(t){return new Promise((e,r)=>{let n;if(this._resolve=e,void 0!==t){let e=new Error("Stream consumer iteration timed out");(async()=>{let o=function(t){let e,r=new Promise(r=>{e=setTimeout(r,t)});return{timeoutId:e,promise:r}}(t);n=o.timeoutId,await o.promise,e.name="TimeoutError",delete this._resolve,r(e)})()}this._timeoutId=n})}async next(){for(this._isIterating=!0,this.stream.setConsumer(this.id,this);;){if(!this.currentNode.next)try{await this._waitForNextItem(this.timeout)}catch(t){throw this._isIterating=!1,this.stream.removeConsumer(this.id),t}if(this._killPacket){this._isIterating=!1,this.stream.removeConsumer(this.id),this.resetBackpressure();let t=this._killPacket;return delete this._killPacket,t}if(this.currentNode=this.currentNode.next,this.releaseBackpressure(this.currentNode.data),!this.currentNode.consumerId||this.currentNode.consumerId===this.id)return this.currentNode.data.done&&(this._isIterating=!1,this.stream.removeConsumer(this.id)),this.currentNode.data}}return(){return delete this.currentNode,this._isIterating=!1,this.stream.removeConsumer(this.id),this.resetBackpressure(),{}}}},{}],31:[function(t,e){const r=t("consumable-stream"),n=t("./consumer");e.exports=class extends r{constructor(){super(),this.nextConsumerId=1,this._consumers={},this._tailNode={next:null,data:{value:void 0,done:!1}}}_write(t,e,r){let n={data:{value:t,done:e},next:null};r&&(n.consumerId=r),this._tailNode.next=n,this._tailNode=n;let o=Object.values(this._consumers),i=o.length;for(let t=0;tr&&(r=e)}return r}getConsumerBackpressure(t){let e=this._consumers[t];return e?e.getBackpressure():0}hasConsumer(t){return!!this._consumers[t]}setConsumer(t,e){this._consumers[t]=e,e.currentNode||(e.currentNode=this._tailNode)}removeConsumer(t){delete this._consumers[t]}getConsumerStats(t){let e=this._consumers[t];if(e)return e.getStats()}getConsumerStatsList(){let t=[],e=Object.values(this._consumers),r=e.length;for(let n=0;n asyngular-client.js && uglifyjs asyngular-client.js -o asyngular-client.min.js +browserify -s socketcluster index.js > socketcluster-client.js && uglifyjs socketcluster-client.js -o socketcluster-client.min.js diff --git a/gulp-build.sh b/gulp-build.sh index 7904e6d..965c255 100644 --- a/gulp-build.sh +++ b/gulp-build.sh @@ -3,7 +3,7 @@ SDK_VERSION=$(cat package.json | sed -n -e '/version/ s/.*: *"\([^"]*\).*/\1/p') echo "Building JavaScript SDK v$SDK_VERSION...\n" echo "Cleaning up old builds...\n" -rm -rf asyngular-client.js asyngular-client.min.js +rm -rf socketcluster-client.js socketcluster-client.min.js echo "Browser Release:" gulp browserify gulp minify diff --git a/gulpfile.js b/gulpfile.js index f22fae8..9ed0979 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -18,7 +18,7 @@ var VERSION = require('./package.json').version; // declaration added by browserify. var FULL_HEADER = ( '/**\n' + - ' * Asyngular JavaScript client v' + VERSION + '\n' + + ' * SocketCluster JavaScript client v' + VERSION + '\n' + ' */\n ' ); @@ -26,14 +26,14 @@ gulp.task('browserify', function (done) { var stream = browserify({ builtins: ['_process', 'events', 'buffer', 'querystring'], entries: 'index.js', - standalone: 'asyngularClient' + standalone: 'socketClusterClient' }) .ignore('_process') .require('./index.js', { - expose: 'asyngular-client' + expose: 'socketcluster-client' }) .bundle(); - return stream.pipe(source('asyngular-client.js')) + return stream.pipe(source('socketcluster-client.js')) .pipe(insert.prepend(FULL_HEADER)) .pipe(convertNewline({ newline: 'lf', @@ -43,7 +43,7 @@ gulp.task('browserify', function (done) { }); gulp.task('minify', function () { - return gulp.src(DIST + 'asyngular-client.js') + return gulp.src(DIST + 'socketcluster-client.js') .pipe(babel({ comments: false })) diff --git a/index.js b/index.js index f8c582a..7f31ea4 100644 --- a/index.js +++ b/index.js @@ -1,6 +1,6 @@ const AGClientSocket = require('./lib/clientsocket'); const factory = require('./lib/factory'); -const version = '6.2.4'; +const version = '15.0.0'; module.exports.factory = factory; module.exports.AGClientSocket = AGClientSocket; diff --git a/lib/clientsocket.js b/lib/clientsocket.js index 447b371..93bd172 100644 --- a/lib/clientsocket.js +++ b/lib/clientsocket.js @@ -24,7 +24,7 @@ function AGClientSocket(socketOptions) { AsyncStreamEmitter.call(this); let defaultOptions = { - path: '/asyngular/', + path: '/socketcluster/', secure: false, autoConnect: true, autoReconnect: true, @@ -33,7 +33,7 @@ function AGClientSocket(socketOptions) { ackTimeout: 10000, timestampRequests: false, timestampParam: 't', - authTokenName: 'asyngular.authToken', + authTokenName: 'socketcluster.authToken', binaryType: 'arraybuffer', batchOnHandshake: false, batchOnHandshakeDuration: 100, @@ -148,7 +148,7 @@ function AGClientSocket(socketOptions) { if (this.options.protocol) { let protocolOptionError = new InvalidArgumentsError( - 'The "protocol" option does not affect asyngular-client - ' + + 'The "protocol" option does not affect socketcluster-client - ' + 'If you want to utilize SSL/TLS, use "secure" option instead' ); this._onError(protocolOptionError); diff --git a/package.json b/package.json index 839144c..a563959 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { - "name": "asyngular-client", - "description": "Asyngular JavaScript client", - "version": "6.2.4", - "homepage": "https://asyngular.io/", + "name": "socketcluster-client", + "description": "SocketCluster JavaScript client", + "version": "15.0.0", + "homepage": "https://socketcluster.io/", "contributors": [ { "name": "Jonathan Gros-Dubois", @@ -11,7 +11,7 @@ ], "repository": { "type": "git", - "url": "git://github.com/SocketCluster/asyngular-client.git" + "url": "git://github.com/SocketCluster/socketcluster-client.git" }, "scripts": { "build": "gulp browserify; gulp minify", @@ -39,7 +39,7 @@ "devDependencies": { "@babel/core": "^7.7.4", "@babel/preset-env": "^7.7.4", - "asyngular-server": "^6.2.0", + "socketcluster-server": "^15.0.0", "babel-plugin-minify-dead-code-elimination": "^0.5.0", "browserify": "^16.2.3", "es-check": "^5.1.0", diff --git a/asyngular-client.js b/socketcluster-client.js similarity index 99% rename from asyngular-client.js rename to socketcluster-client.js index ee01648..f372491 100644 --- a/asyngular-client.js +++ b/socketcluster-client.js @@ -1,7 +1,7 @@ /** - * Asyngular JavaScript client v6.2.4 + * SocketCluster JavaScript client v15.0.0 */ - (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.asyngularClient = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i{if(this[t]>i)throw new m(`The ${t} value provided exceeded the maximum amount allowed`)};if(u("connectTimeout"),u("ackTimeout"),u("pingTimeout"),this.connectAttempts=0,this.isBatching=!1,this.batchOnHandshake=e.batchOnHandshake,this.batchOnHandshakeDuration=e.batchOnHandshakeDuration,this._batchingIntervalId=null,this._outboundBuffer=new h,this._channelMap={},this._channelEventDemux=new n,this._channelDataDemux=new n,this._receiverDemux=new n,this._procedureDemux=new n,this.options=e,this._cid=1,this.options.callIdGenerator=(()=>this._cid++),this.options.autoReconnect){null==this.options.autoReconnectOptions&&(this.options.autoReconnectOptions={});let t=this.options.autoReconnectOptions;null==t.initialDelay&&(t.initialDelay=1e4),null==t.randomness&&(t.randomness=1e4),null==t.multiplier&&(t.multiplier=1.5),null==t.maxDelay&&(t.maxDelay=6e4)}if(null==this.options.subscriptionRetryOptions&&(this.options.subscriptionRetryOptions={}),this.options.authEngine?this.auth=this.options.authEngine:this.auth=new s,this.options.codecEngine?this.codec=this.options.codecEngine:this.codec=a,this.options.protocol){let t=new m('The "protocol" option does not affect socketcluster-client - If you want to utilize SSL/TLS, use "secure" option instead');this._onError(t)}this.options.query=e.query||{},"string"==typeof this.options.query&&(this.options.query=c.parse(this.options.query)),_&&this.disconnectOnUnload&&r.addEventListener&&r.removeEventListener&&this._handleBrowserUnload(),this.options.autoConnect&&this.connect()}k.prototype=Object.create(o.prototype),k.CONNECTING=k.prototype.CONNECTING=u.prototype.CONNECTING,k.OPEN=k.prototype.OPEN=u.prototype.OPEN,k.CLOSED=k.prototype.CLOSED=u.prototype.CLOSED,k.AUTHENTICATED=k.prototype.AUTHENTICATED="authenticated",k.UNAUTHENTICATED=k.prototype.UNAUTHENTICATED="unauthenticated",k.SUBSCRIBED=k.prototype.SUBSCRIBED=i.SUBSCRIBED,k.PENDING=k.prototype.PENDING=i.PENDING,k.UNSUBSCRIBED=k.prototype.UNSUBSCRIBED=i.UNSUBSCRIBED,k.ignoreStatuses=d.socketProtocolIgnoreStatuses,k.errorStatuses=d.socketProtocolErrorStatuses,Object.defineProperty(k.prototype,"isBufferingBatch",{get:function(){return this.transport.isBufferingBatch}}),k.prototype.getBackpressure=function(){return Math.max(this.getAllListenersBackpressure(),this.getAllReceiversBackpressure(),this.getAllProceduresBackpressure(),this.getAllChannelsBackpressure())},k.prototype._handleBrowserUnload=async function(){let t=()=>{this.disconnect()},e=!1;(async()=>{let n=this.listener("connecting").createConsumer();for(;;){if((await n.next()).done)break;e||(e=!0,r.addEventListener("beforeunload",t,!1))}})(),(async()=>{let n=this.listener("close").createConsumer();for(;;){if((await n.next()).done)break;e&&(e=!1,r.removeEventListener("beforeunload",t,!1))}})()},k.prototype._setAuthToken=function(t){this._changeToAuthenticatedState(t.token),(async()=>{try{await this.auth.saveToken(this.authTokenName,t.token,{})}catch(t){this._onError(t)}})()},k.prototype._removeAuthToken=function(){(async()=>{let t;try{t=await this.auth.removeToken(this.authTokenName)}catch(t){return void this._onError(t)}this.emit("removeAuthToken",{oldAuthToken:t})})(),this._changeToUnauthenticatedStateAndClearTokens()},k.prototype._privateDataHandlerMap={"#publish":function(t){let e=this._undecorateChannelName(t.channel);this.isSubscribed(e,!0)&&this._channelDataDemux.write(e,t.data)},"#kickOut":function(t){let e=this._undecorateChannelName(t.channel),r=this._channelMap[e];r&&(this.emit("kickOut",{channel:e,message:t.message}),this._channelEventDemux.write(`${e}/kickOut`,{message:t.message}),this._triggerChannelUnsubscribe(r))},"#setAuthToken":function(t){t&&this._setAuthToken(t)},"#removeAuthToken":function(t){this._removeAuthToken(t)}},k.prototype._privateRPCHandlerMap={"#setAuthToken":function(t,e){t?(this._setAuthToken(t),e.end()):e.error(new y("No token data provided by #setAuthToken event"))},"#removeAuthToken":function(t,e){this._removeAuthToken(t),e.end()}},k.prototype.getState=function(){return this.state},k.prototype.getBytesReceived=function(){return this.transport.getBytesReceived()},k.prototype.deauthenticate=async function(){(async()=>{let t;try{t=await this.auth.removeToken(this.authTokenName)}catch(t){return void this._onError(t)}this.emit("removeAuthToken",{oldAuthToken:t})})(),this.state!==this.CLOSED&&this.transmit("#removeAuthToken"),this._changeToUnauthenticatedStateAndClearTokens(),await f(0)},k.prototype.connect=function(){this.state===this.CLOSED&&(this.pendingReconnect=!1,this.pendingReconnectTimeout=null,clearTimeout(this._reconnectTimeoutRef),this.state=this.CONNECTING,this.emit("connecting",{}),this.transport&&this.transport.clearAllListeners(),this.transport=new u(this.auth,this.codec,this.options,this.wsOptions,{onOpen:t=>{this.state=this.OPEN,this._onOpen(t)},onOpenAbort:t=>{this.state!==this.CLOSED&&(this.state=this.CLOSED,this._destroy(t.code,t.reason,!0))},onClose:t=>{this.state!==this.CLOSED&&(this.state=this.CLOSED,this._destroy(t.code,t.reason))},onEvent:t=>{this.emit(t.event,t.data)},onError:t=>{this._onError(t.error)},onInboundInvoke:t=>{this._onInboundInvoke(t)},onInboundTransmit:t=>{this._onInboundTransmit(t.event,t.data)}}))},k.prototype.reconnect=function(t,e){this.disconnect(t,e),this.connect()},k.prototype.disconnect=function(t,e){if("number"!=typeof(t=t||1e3))throw new m("If specified, the code argument must be a number");let r=this.state===this.CONNECTING;r||this.state===this.OPEN?(this.state=this.CLOSED,this._destroy(t,e,r),this.transport.close(t,e)):(this.pendingReconnect=!1,this.pendingReconnectTimeout=null,clearTimeout(this._reconnectTimeoutRef))},k.prototype._changeToUnauthenticatedStateAndClearTokens=function(){if(this.authState!==this.UNAUTHENTICATED){let t=this.authState,e=this.authToken,r=this.signedAuthToken;this.authState=this.UNAUTHENTICATED,this.signedAuthToken=null,this.authToken=null;let n={oldAuthState:t,newAuthState:this.authState};this.emit("authStateChange",n),this.emit("deauthenticate",{oldSignedAuthToken:r,oldAuthToken:e})}},k.prototype._changeToAuthenticatedState=function(t){if(this.signedAuthToken=t,this.authToken=this._extractAuthTokenData(t),this.authState!==this.AUTHENTICATED){let e=this.authState;this.authState=this.AUTHENTICATED;let r={oldAuthState:e,newAuthState:this.authState,signedAuthToken:t,authToken:this.authToken};this.preparingPendingSubscriptions||this.processPendingSubscriptions(),this.emit("authStateChange",r)}this.emit("authenticate",{signedAuthToken:t,authToken:this.authToken})},k.prototype.decodeBase64=function(t){return p.from(t,"base64").toString("utf8")},k.prototype.encodeBase64=function(t){return p.from(t,"utf8").toString("base64")},k.prototype._extractAuthTokenData=function(t){let e=(t||"").split(".")[1];if(null!=e){let t=e;try{return t=this.decodeBase64(t),JSON.parse(t)}catch(e){return t}}return null},k.prototype.getAuthToken=function(){return this.authToken},k.prototype.getSignedAuthToken=function(){return this.signedAuthToken},k.prototype.authenticate=async function(t){let e;try{e=await this.invoke("#authenticate",t)}catch(t){throw"BadConnectionError"!==t.name&&"TimeoutError"!==t.name&&this._changeToUnauthenticatedStateAndClearTokens(),await f(0),t}return e&&null!=e.isAuthenticated?e.authError&&(e.authError=d.hydrateError(e.authError)):e={isAuthenticated:this.authState,authError:null},e.isAuthenticated?this._changeToAuthenticatedState(t):this._changeToUnauthenticatedStateAndClearTokens(),(async()=>{try{await this.auth.saveToken(this.authTokenName,t,{})}catch(t){this._onError(t)}})(),await f(0),e},k.prototype._tryReconnect=function(t){let e,r=this.connectAttempts++,n=this.options.autoReconnectOptions;if(null==t||r>0){let t=Math.round(n.initialDelay+(n.randomness||0)*Math.random());e=Math.round(t*Math.pow(n.multiplier,r))}else e=t;e>n.maxDelay&&(e=n.maxDelay),clearTimeout(this._reconnectTimeoutRef),this.pendingReconnect=!0,this.pendingReconnectTimeout=e,this._reconnectTimeoutRef=setTimeout(()=>{this.connect()},e)},k.prototype._onOpen=function(t){this.isBatching?this._startBatching():this.batchOnHandshake&&(this._startBatching(),setTimeout(()=>{this.isBatching||this._stopBatching()},this.batchOnHandshakeDuration)),this.preparingPendingSubscriptions=!0,t?(this.id=t.id,this.pingTimeout=t.pingTimeout,t.isAuthenticated?this._changeToAuthenticatedState(t.authToken):this._changeToUnauthenticatedStateAndClearTokens()):this._changeToUnauthenticatedStateAndClearTokens(),this.connectAttempts=0,this.options.autoSubscribeOnConnect&&this.processPendingSubscriptions(),this.emit("connect",{...t,processPendingSubscriptions:()=>{this.processPendingSubscriptions()}}),this.state===this.OPEN&&this._flushOutboundBuffer()},k.prototype._onError=function(t){this.emit("error",{error:t})},k.prototype._suspendSubscriptions=function(){Object.keys(this._channelMap).forEach(t=>{let e=this._channelMap[t];this._triggerChannelUnsubscribe(e,!0)})},k.prototype._abortAllPendingEventsDueToBadConnection=function(t){let e,r=this._outboundBuffer.head;for(;r;){e=r.next;let n=r.data;clearTimeout(n.timeout),delete n.timeout,r.detach(),r=e;let o=n.callback;if(o){delete n.callback;let e=`Event "${n.event}" was aborted due to a bad connection`,r=new v(e,t);o.call(n,r,n)}n.cid&&this.transport.cancelPendingResponse(n.cid)}},k.prototype._destroy=function(t,e,r){if(this.id=null,this._cancelBatching(),this.transport&&this.transport.clearAllListeners(),this.pendingReconnect=!1,this.pendingReconnectTimeout=null,clearTimeout(this._reconnectTimeoutRef),this._suspendSubscriptions(),r?this.emit("connectAbort",{code:t,reason:e}):this.emit("disconnect",{code:t,reason:e}),this.emit("close",{code:t,reason:e}),!k.ignoreStatuses[t]){let r;r=e?"Socket connection closed with status code "+t+" and reason: "+e:"Socket connection closed with status code "+t;let n=new g(k.errorStatuses[t]||r,t);this._onError(n)}this._abortAllPendingEventsDueToBadConnection(r?"connectAbort":"disconnect"),this.options.autoReconnect&&(4e3===t||4001===t||1005===t?this._tryReconnect(0):1e3!==t&&t<4500&&this._tryReconnect())},k.prototype._onInboundTransmit=function(t,e){let r=this._privateDataHandlerMap[t];r?r.call(this,e):this._receiverDemux.write(t,e)},k.prototype._onInboundInvoke=function(t){let{procedure:e,data:r}=t,n=this._privateRPCHandlerMap[e];n?n.call(this,r,t):this._procedureDemux.write(e,t)},k.prototype.decode=function(t){return this.transport.decode(t)},k.prototype.encode=function(t){return this.transport.encode(t)},k.prototype._flushOutboundBuffer=function(){let t,e=this._outboundBuffer.head;for(;e;){t=e.next;let r=e.data;e.detach(),this.transport.transmitObject(r),e=t}},k.prototype._handleEventAckTimeout=function(t,e){e&&e.detach(),delete t.timeout;let r=t.callback;if(r){delete t.callback;let e=new b(`Event response for "${t.event}" timed out`);r.call(t,e,t)}t.cid&&this.transport.cancelPendingResponse(t.cid)},k.prototype._processOutboundEvent=function(t,e,r,n){r=r||{},this.state===this.CLOSED&&this.connect();let o,i={event:t};o=n?new Promise((t,e)=>{i.callback=((r,n)=>{r?e(r):t(n)})}):Promise.resolve();let s=new h.Item;this.options.cloneData?i.data=l(e):i.data=e,s.data=i;let a=null==r.ackTimeout?this.ackTimeout:r.ackTimeout;return i.timeout=setTimeout(()=>{this._handleEventAckTimeout(i,s)},a),this._outboundBuffer.append(s),this.state===this.OPEN&&this._flushOutboundBuffer(),o},k.prototype.send=function(t){this.transport.send(t)},k.prototype.transmit=function(t,e,r){return this._processOutboundEvent(t,e,r)},k.prototype.invoke=function(t,e,r){return this._processOutboundEvent(t,e,r,!0)},k.prototype.transmitPublish=function(t,e){let r={channel:this._decorateChannelName(t),data:e};return this.transmit("#publish",r)},k.prototype.invokePublish=function(t,e){let r={channel:this._decorateChannelName(t),data:e};return this.invoke("#publish",r)},k.prototype._triggerChannelSubscribe=function(t,e){let r=t.name;if(t.state!==i.SUBSCRIBED){let n=t.state;t.state=i.SUBSCRIBED;let o={oldChannelState:n,newChannelState:t.state,subscriptionOptions:e};this._channelEventDemux.write(`${r}/subscribeStateChange`,o),this._channelEventDemux.write(`${r}/subscribe`,{subscriptionOptions:e}),this.emit("subscribeStateChange",{channel:r,...o}),this.emit("subscribe",{channel:r,subscriptionOptions:e})}},k.prototype._triggerChannelSubscribeFail=function(t,e,r){let n=e.name,o=!e.options.waitForAuth||this.authState===this.AUTHENTICATED;!!this._channelMap[n]&&o&&(delete this._channelMap[n],this._channelEventDemux.write(`${n}/subscribeFail`,{error:t,subscriptionOptions:r}),this.emit("subscribeFail",{error:t,channel:n,subscriptionOptions:r}))},k.prototype._cancelPendingSubscribeCallback=function(t){null!=t._pendingSubscriptionCid&&(this.transport.cancelPendingResponse(t._pendingSubscriptionCid),delete t._pendingSubscriptionCid)},k.prototype._decorateChannelName=function(t){return this.channelPrefix&&(t=this.channelPrefix+t),t},k.prototype._undecorateChannelName=function(t){return this.channelPrefix&&0===t.indexOf(this.channelPrefix)?t.replace(this.channelPrefix,""):t},k.prototype.startBatch=function(){this.transport.startBatch()},k.prototype.flushBatch=function(){this.transport.flushBatch()},k.prototype.cancelBatch=function(){this.transport.cancelBatch()},k.prototype._startBatching=function(){null==this._batchingIntervalId&&(this.startBatch(),this._batchingIntervalId=setInterval(()=>{this.flushBatch(),this.startBatch()},this.options.batchInterval))},k.prototype.startBatching=function(){this.isBatching=!0,this._startBatching()},k.prototype._stopBatching=function(){null!=this._batchingIntervalId&&clearInterval(this._batchingIntervalId),this._batchingIntervalId=null,this.flushBatch()},k.prototype.stopBatching=function(){this.isBatching=!1,this._stopBatching()},k.prototype._cancelBatching=function(){null!=this._batchingIntervalId&&clearInterval(this._batchingIntervalId),this._batchingIntervalId=null,this.cancelBatch()},k.prototype.cancelBatching=function(){this.isBatching=!1,this._cancelBatching()},k.prototype._trySubscribe=function(t){let e=!t.options.waitForAuth||this.authState===this.AUTHENTICATED;if(this.state===this.OPEN&&!this.preparingPendingSubscriptions&&null==t._pendingSubscriptionCid&&e){let e={noTimeout:!0},r={};t.options.waitForAuth&&(e.waitForAuth=!0,r.waitForAuth=e.waitForAuth),t.options.data&&(r.data=t.options.data),t._pendingSubscriptionCid=this.transport.invokeRaw("#subscribe",{channel:this._decorateChannelName(t.name),...r},e,e=>{if(e){if("BadConnectionError"===e.name)return;delete t._pendingSubscriptionCid,this._triggerChannelSubscribeFail(e,t,r)}else delete t._pendingSubscriptionCid,this._triggerChannelSubscribe(t,r)}),this.emit("subscribeRequest",{channel:t.name,subscriptionOptions:r})}},k.prototype.subscribe=function(t,e){e=e||{};let r=this._channelMap[t],n={waitForAuth:!!e.waitForAuth};return null!=e.priority&&(n.priority=e.priority),void 0!==e.data&&(n.data=e.data),r?e&&(r.options=n):(r={name:t,state:i.PENDING,options:n},this._channelMap[t]=r,this._trySubscribe(r)),new i(t,this,this._channelEventDemux,this._channelDataDemux)},k.prototype._triggerChannelUnsubscribe=function(t,e){let r=t.name;if(this._cancelPendingSubscribeCallback(t),t.state===i.SUBSCRIBED){let n={oldChannelState:t.state,newChannelState:e?i.PENDING:i.UNSUBSCRIBED};this._channelEventDemux.write(`${r}/subscribeStateChange`,n),this._channelEventDemux.write(`${r}/unsubscribe`,{}),this.emit("subscribeStateChange",{channel:r,...n}),this.emit("unsubscribe",{channel:r})}e?t.state=i.PENDING:delete this._channelMap[r]},k.prototype._tryUnsubscribe=function(t){if(this.state===this.OPEN){this._cancelPendingSubscribeCallback(t);let e=this._decorateChannelName(t.name);this.transport.transmit("#unsubscribe",e,{noTimeout:!0})}},k.prototype.unsubscribe=function(t){let e=this._channelMap[t];e&&(this._triggerChannelUnsubscribe(e),this._tryUnsubscribe(e))},k.prototype.receiver=function(t){return this._receiverDemux.stream(t)},k.prototype.closeReceiver=function(t){this._receiverDemux.close(t)},k.prototype.closeAllReceivers=function(){this._receiverDemux.closeAll()},k.prototype.killReceiver=function(t){this._receiverDemux.kill(t)},k.prototype.killAllReceivers=function(){this._receiverDemux.killAll()},k.prototype.killReceiverConsumer=function(t){this._receiverDemux.killConsumer(t)},k.prototype.getReceiverConsumerStats=function(t){return this._receiverDemux.getConsumerStats(t)},k.prototype.getReceiverConsumerStatsList=function(t){return this._receiverDemux.getConsumerStatsList(t)},k.prototype.getAllReceiversConsumerStatsList=function(){return this._receiverDemux.getConsumerStatsListAll()},k.prototype.getReceiverBackpressure=function(t){return this._receiverDemux.getBackpressure(t)},k.prototype.getAllReceiversBackpressure=function(){return this._receiverDemux.getBackpressureAll()},k.prototype.getReceiverConsumerBackpressure=function(t){return this._receiverDemux.getConsumerBackpressure(t)},k.prototype.hasReceiverConsumer=function(t,e){return this._receiverDemux.hasConsumer(t,e)},k.prototype.hasAnyReceiverConsumer=function(t){return this._receiverDemux.hasConsumerAll(t)},k.prototype.procedure=function(t){return this._procedureDemux.stream(t)},k.prototype.closeProcedure=function(t){this._procedureDemux.close(t)},k.prototype.closeAllProcedures=function(){this._procedureDemux.closeAll()},k.prototype.killProcedure=function(t){this._procedureDemux.kill(t)},k.prototype.killAllProcedures=function(){this._procedureDemux.killAll()},k.prototype.killProcedureConsumer=function(t){this._procedureDemux.killConsumer(t)},k.prototype.getProcedureConsumerStats=function(t){return this._procedureDemux.getConsumerStats(t)},k.prototype.getProcedureConsumerStatsList=function(t){return this._procedureDemux.getConsumerStatsList(t)},k.prototype.getAllProceduresConsumerStatsList=function(){return this._procedureDemux.getConsumerStatsListAll()},k.prototype.getProcedureBackpressure=function(t){return this._procedureDemux.getBackpressure(t)},k.prototype.getAllProceduresBackpressure=function(){return this._procedureDemux.getBackpressureAll()},k.prototype.getProcedureConsumerBackpressure=function(t){return this._procedureDemux.getConsumerBackpressure(t)},k.prototype.hasProcedureConsumer=function(t,e){return this._procedureDemux.hasConsumer(t,e)},k.prototype.hasAnyProcedureConsumer=function(t){return this._procedureDemux.hasConsumerAll(t)},k.prototype.channel=function(t){return this._channelMap[t],new i(t,this,this._channelEventDemux,this._channelDataDemux)},k.prototype.closeChannel=function(t){this.channelCloseOutput(t),this.channelCloseAllListeners(t)},k.prototype.closeAllChannelOutputs=function(){this._channelDataDemux.closeAll()},k.prototype.closeAllChannelListeners=function(){this._channelEventDemux.closeAll()},k.prototype.closeAllChannels=function(){this.closeAllChannelOutputs(),this.closeAllChannelListeners()},k.prototype.killChannel=function(t){this.channelKillOutput(t),this.channelKillAllListeners(t)},k.prototype.killAllChannelOutputs=function(){this._channelDataDemux.killAll()},k.prototype.killAllChannelListeners=function(){this._channelEventDemux.killAll()},k.prototype.killAllChannels=function(){this.killAllChannelOutputs(),this.killAllChannelListeners()},k.prototype.killChannelOutputConsumer=function(t){this._channelDataDemux.killConsumer(t)},k.prototype.killChannelListenerConsumer=function(t){this._channelEventDemux.killConsumer(t)},k.prototype.getChannelOutputConsumerStats=function(t){return this._channelDataDemux.getConsumerStats(t)},k.prototype.getChannelListenerConsumerStats=function(t){return this._channelEventDemux.getConsumerStats(t)},k.prototype.getAllChannelOutputsConsumerStatsList=function(){return this._channelDataDemux.getConsumerStatsListAll()},k.prototype.getAllChannelListenersConsumerStatsList=function(){return this._channelEventDemux.getConsumerStatsListAll()},k.prototype.getChannelBackpressure=function(t){return Math.max(this.channelGetOutputBackpressure(t),this.channelGetAllListenersBackpressure(t))},k.prototype.getAllChannelOutputsBackpressure=function(){return this._channelDataDemux.getBackpressureAll()},k.prototype.getAllChannelListenersBackpressure=function(){return this._channelEventDemux.getBackpressureAll()},k.prototype.getAllChannelsBackpressure=function(){return Math.max(this.getAllChannelOutputsBackpressure(),this.getAllChannelListenersBackpressure())},k.prototype.getChannelListenerConsumerBackpressure=function(t){return this._channelEventDemux.getConsumerBackpressure(t)},k.prototype.getChannelOutputConsumerBackpressure=function(t){return this._channelDataDemux.getConsumerBackpressure(t)},k.prototype.hasAnyChannelOutputConsumer=function(t){return this._channelDataDemux.hasConsumerAll(t)},k.prototype.hasAnyChannelListenerConsumer=function(t){return this._channelEventDemux.hasConsumerAll(t)},k.prototype.getChannelState=function(t){let e=this._channelMap[t];return e?e.state:i.UNSUBSCRIBED},k.prototype.getChannelOptions=function(t){let e=this._channelMap[t];return e?{...e.options}:{}},k.prototype._getAllChannelStreamNames=function(t){let e=this._channelEventDemux.getConsumerStatsListAll().filter(e=>0===e.stream.indexOf(`${t}/`)).reduce((t,e)=>(t[e.stream]=!0,t),{});return Object.keys(e)},k.prototype.channelCloseOutput=function(t){this._channelDataDemux.close(t)},k.prototype.channelCloseListener=function(t,e){this._channelEventDemux.close(`${t}/${e}`)},k.prototype.channelCloseAllListeners=function(t){this._getAllChannelStreamNames(t).forEach(t=>{this._channelEventDemux.close(t)})},k.prototype.channelKillOutput=function(t){this._channelDataDemux.kill(t)},k.prototype.channelKillListener=function(t,e){this._channelEventDemux.kill(`${t}/${e}`)},k.prototype.channelKillAllListeners=function(t){this._getAllChannelStreamNames(t).forEach(t=>{this._channelEventDemux.kill(t)})},k.prototype.channelGetOutputConsumerStatsList=function(t){return this._channelDataDemux.getConsumerStatsList(t)},k.prototype.channelGetListenerConsumerStatsList=function(t,e){return this._channelEventDemux.getConsumerStatsList(`${t}/${e}`)},k.prototype.channelGetAllListenersConsumerStatsList=function(t){return this._getAllChannelStreamNames(t).map(t=>this._channelEventDemux.getConsumerStatsList(t)).reduce((t,e)=>(e.forEach(e=>{t.push(e)}),t),[])},k.prototype.channelGetOutputBackpressure=function(t){return this._channelDataDemux.getBackpressure(t)},k.prototype.channelGetListenerBackpressure=function(t,e){return this._channelEventDemux.getBackpressure(`${t}/${e}`)},k.prototype.channelGetAllListenersBackpressure=function(t){let e=this._getAllChannelStreamNames(t).map(t=>this._channelEventDemux.getBackpressure(t));return Math.max(...e.concat(0))},k.prototype.channelHasOutputConsumer=function(t,e){return this._channelDataDemux.hasConsumer(t,e)},k.prototype.channelHasListenerConsumer=function(t,e,r){return this._channelEventDemux.hasConsumer(`${t}/${e}`,r)},k.prototype.channelHasAnyListenerConsumer=function(t,e){return this._getAllChannelStreamNames(t).some(t=>this._channelEventDemux.hasConsumer(t,e))},k.prototype.subscriptions=function(t){let e=[];return Object.keys(this._channelMap).forEach(r=>{(t||this._channelMap[r].state===i.SUBSCRIBED)&&e.push(r)}),e},k.prototype.isSubscribed=function(t,e){let r=this._channelMap[t];return e?!!r:!!r&&r.state===i.SUBSCRIBED},k.prototype.processPendingSubscriptions=function(){this.preparingPendingSubscriptions=!1;let t=[];Object.keys(this._channelMap).forEach(e=>{let r=this._channelMap[e];r.state===i.PENDING&&t.push(r)}),t.sort((t,e)=>{let r=t.options.priority||0,n=e.options.priority||0;return r>n?-1:r{this._trySubscribe(t)})},e.exports=k}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./auth":1,"./transport":4,"./wait":5,"ag-channel":7,"async-stream-emitter":9,"buffer/":11,"linked-list":15,"lodash.clonedeep":16,querystring:19,"sc-errors":21,"sc-formatter":22,"stream-demux":24}],3:[function(t,e){(function(r){const n=t("./clientsocket"),o=t("uuid"),i=t("sc-errors").InvalidArgumentsError;e.exports={create:function(t){if((t=t||{}).host&&!t.host.match(/[^:]+:\d{2,5}/))throw new i('The host option should include both the hostname and the port number in the format "hostname:port"');if(t.host&&t.hostname)throw new i('The host option should already include the hostname and the port number in the format "hostname:port" - Because of this, you should never use host and hostname options together');if(t.host&&t.port)throw new i('The host option should already include the hostname and the port number in the format "hostname:port" - Because of this, you should never use host and port options together');let e=r.location&&"https:"===location.protocol,s={clientId:o.v4(),port:function(t,e){let n=null==t.secure?e:t.secure;return t.port||(r.location&&location.port?location.port:n?443:80)}(t,e),hostname:r.location&&location.hostname||"localhost",secure:e};return Object.assign(s,t),new n(s)}}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./clientsocket":2,"sc-errors":21,uuid:25}],4:[function(t,e){(function(r){const n=t("ag-request"),o=t("querystring");let i,s;r.WebSocket?(i=r.WebSocket,s=function(t){return new i(t)}):(i=t("ws"),s=function(t,e){return new i(t,null,e)});const a=t("sc-errors"),u=a.TimeoutError,c=a.BadConnectionError;function h(t,e,r,n,o){this.state=this.CLOSED,this.auth=t,this.codec=e,this.options=r,this.wsOptions=n,this.protocolVersion=r.protocolVersion,this.connectTimeout=r.connectTimeout,this.pingTimeout=r.pingTimeout,this.pingTimeoutDisabled=!!r.pingTimeoutDisabled,this.callIdGenerator=r.callIdGenerator,this.authTokenName=r.authTokenName,this.isBufferingBatch=!1,this._pingTimeoutTicker=null,this._callbackMap={},this._batchBuffer=[],o||(o={}),this._onOpenHandler=o.onOpen||function(){},this._onOpenAbortHandler=o.onOpenAbort||function(){},this._onCloseHandler=o.onClose||function(){},this._onEventHandler=o.onEvent||function(){},this._onErrorHandler=o.onError||function(){},this._onInboundInvokeHandler=o.onInboundInvoke||function(){},this._onInboundTransmitHandler=o.onInboundTransmit||function(){},this.state=this.CONNECTING;let i=this.uri(),a=s(i,n);a.binaryType=this.options.binaryType,this.socket=a,a.onopen=(()=>{this._onOpen()}),a.onclose=(async t=>{let e;e=null==t.code?1005:t.code,this._destroy(e,t.reason)}),a.onmessage=(t=>{this._onMessage(t.data)}),a.onerror=(()=>{this.state===this.CONNECTING&&this._destroy(1006)}),this._connectTimeoutRef=setTimeout(()=>{this._destroy(4007),this.socket.close(4007)},this.connectTimeout),1===this.protocolVersion?this._handlePing=(t=>"#1"===t&&(this._resetPingTimeout(),this.socket.readyState===this.socket.OPEN&&this.send("#2"),!0)):this._handlePing=(t=>""===t&&(this._resetPingTimeout(),this.socket.readyState===this.socket.OPEN&&this.send(""),!0))}h.CONNECTING=h.prototype.CONNECTING="connecting",h.OPEN=h.prototype.OPEN="open",h.CLOSED=h.prototype.CLOSED="closed",h.prototype.uri=function(){let t,e=this.options.query||{},r=this.options.secure?"wss":"ws";if(this.options.timestampRequests&&(e[this.options.timestampParam]=(new Date).getTime()),(e=o.encode(e)).length&&(e="?"+e),this.options.host)t=this.options.host;else{let e="";this.options.port&&("wss"===r&&443!==this.options.port||"ws"===r&&80!==this.options.port)&&(e=":"+this.options.port),t=this.options.hostname+e}return r+"://"+t+this.options.path+e},h.prototype._onOpen=async function(){let t;clearTimeout(this._connectTimeoutRef),this._resetPingTimeout();try{t=await this._handshake()}catch(t){return null==t.statusCode&&(t.statusCode=4003),this._onError(t),this._destroy(t.statusCode,t.toString()),void this.socket.close(t.statusCode)}this.state=this.OPEN,t&&(this.pingTimeout=t.pingTimeout),this._resetPingTimeout(),this._onOpenHandler(t)},h.prototype._handshake=async function(){let t=await this.auth.loadToken(this.authTokenName),e=await this.invoke("#handshake",{authToken:t},{force:!0});return e&&(e.authToken=t,e.authError&&(e.authError=a.hydrateError(e.authError))),e},h.prototype._abortAllPendingEventsDueToBadConnection=function(t){Object.keys(this._callbackMap||{}).forEach(e=>{let r=this._callbackMap[e];delete this._callbackMap[e],clearTimeout(r.timeout),delete r.timeout;let n=`Event "${r.event}" was aborted due to a bad connection`,o=new c(n,t),i=r.callback;delete r.callback,i.call(r,o,r)})},h.prototype._destroy=function(t,e){a.socketProtocolErrorStatuses[t],!e&&a.socketProtocolErrorStatuses[t]&&(e=a.socketProtocolErrorStatuses[t]),delete this.socket.onopen,delete this.socket.onclose,delete this.socket.onmessage,delete this.socket.onerror,clearTimeout(this._connectTimeoutRef),clearTimeout(this._pingTimeoutTicker),this.state===this.OPEN?(this.state=this.CLOSED,this._abortAllPendingEventsDueToBadConnection("disconnect"),this._onCloseHandler({code:t,reason:e})):this.state===this.CONNECTING?(this.state=this.CLOSED,this._abortAllPendingEventsDueToBadConnection("connectAbort"),this._onOpenAbortHandler({code:t,reason:e})):this.state===this.CLOSED&&this._abortAllPendingEventsDueToBadConnection("connectAbort")},h.prototype._processInboundPacket=function(t,e){if(t&&null!=t.event)if(null==t.cid)this._onInboundTransmitHandler({...t});else{let e=new n(this,t.cid,t.event,t.data);this._onInboundInvokeHandler(e)}else if(t&&null!=t.rid){let e=this._callbackMap[t.rid];if(e&&(clearTimeout(e.timeout),delete e.timeout,delete this._callbackMap[t.rid],e.callback)){let r=a.hydrateError(t.error);e.callback(r,t.data)}}else this._onEventHandler({event:"raw",data:{message:e}})},h.prototype._onMessage=function(t){if(this._onEventHandler({event:"message",data:{message:t}}),this._handlePing(t))return;let e=this.decode(t);if(Array.isArray(e)){let r=e.length;for(let n=0;n{this._destroy(4e3),this.socket.close(4e3)},this.pingTimeout))},h.prototype.clearAllListeners=function(){this._onOpenHandler=function(){},this._onOpenAbortHandler=function(){},this._onCloseHandler=function(){},this._onEventHandler=function(){},this._onErrorHandler=function(){},this._onInboundInvokeHandler=function(){},this._onInboundTransmitHandler=function(){}},h.prototype.startBatch=function(){this.isBufferingBatch=!0,this._batchBuffer=[]},h.prototype.flushBatch=function(){if(this.isBufferingBatch=!1,!this._batchBuffer.length)return;let t=this.serializeObject(this._batchBuffer);this._batchBuffer=[],this.send(t)},h.prototype.cancelBatch=function(){this.isBufferingBatch=!1,this._batchBuffer=[]},h.prototype.getBytesReceived=function(){return this.socket.bytesReceived},h.prototype.close=function(t,e){this.state!==this.OPEN&&this.state!==this.CONNECTING||(t=t||1e3,this._destroy(t,e),this.socket.close(t,e))},h.prototype.transmitObject=function(t){let e={event:t.event,data:t.data};return t.callback&&(e.cid=t.cid=this.callIdGenerator(),this._callbackMap[t.cid]=t),this.sendObject(e),t.cid||null},h.prototype._handleEventAckTimeout=function(t){t.cid&&delete this._callbackMap[t.cid],delete t.timeout;let e=t.callback;if(e){delete t.callback;let r=new u(`Event response for "${t.event}" timed out`);e.call(t,r,t)}},h.prototype.transmit=function(t,e,r){return(this.state===this.OPEN||r.force)&&this.transmitObject({event:t,data:e}),Promise.resolve()},h.prototype.invokeRaw=function(t,e,r,n){let o={event:t,data:e,callback:n};r.noTimeout||(o.timeout=setTimeout(()=>{this._handleEventAckTimeout(o)},this.options.ackTimeout));let i=null;return(this.state===this.OPEN||r.force)&&(i=this.transmitObject(o)),i},h.prototype.invoke=function(t,e,r){return new Promise((n,o)=>{this.invokeRaw(t,e,r,(t,e)=>{t?o(t):n(e)})})},h.prototype.cancelPendingResponse=function(t){delete this._callbackMap[t]},h.prototype.decode=function(t){return this.codec.decode(t)},h.prototype.encode=function(t){return this.codec.encode(t)},h.prototype.send=function(t){this.socket.readyState!==this.socket.OPEN?this._destroy(1005):this.socket.send(t)},h.prototype.serializeObject=function(t){let e;try{e=this.encode(t)}catch(t){return this._onError(t),null}return e},h.prototype.sendObject=function(t){if(this.isBufferingBatch)return void this._batchBuffer.push(t);let e=this.serializeObject(t);null!=e&&this.send(e)},e.exports=h}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"ag-request":8,querystring:19,"sc-errors":21,ws:6}],5:[function(t,e){e.exports=function(t){return new Promise(e=>{setTimeout(()=>{e()},t)})}},{}],6:[function(t,e){let r;const n=(r="undefined"!=typeof WorkerGlobalScope?self:"undefined"!=typeof window&&window||function(){return this}()).WebSocket||r.MozWebSocket;function o(t,e){let r;return r=e?new n(t,e):new n(t)}n&&(o.prototype=n.prototype),e.exports=n?o:null},{}],7:[function(t,e){const r=t("consumable-stream");class n extends r{constructor(t,e,r,o){super(),this.PENDING=n.PENDING,this.SUBSCRIBED=n.SUBSCRIBED,this.UNSUBSCRIBED=n.UNSUBSCRIBED,this.name=t,this.client=e,this._eventDemux=r,this._dataStream=o.stream(this.name)}createConsumer(t){return this._dataStream.createConsumer(t)}listener(t){return this._eventDemux.stream(`${this.name}/${t}`)}close(){this.client.closeChannel(this.name)}kill(){this.client.killChannel(this.name)}killOutputConsumer(t){this.hasOutputConsumer(t)&&this.client.killChannelOutputConsumer(t)}killListenerConsumer(t){this.hasAnyListenerConsumer(t)&&this.client.killChannelListenerConsumer(t)}getOutputConsumerStats(t){if(this.hasOutputConsumer(t))return this.client.getChannelOutputConsumerStats(t)}getListenerConsumerStats(t){if(this.hasAnyListenerConsumer(t))return this.client.getChannelListenerConsumerStats(t)}getBackpressure(){return this.client.getChannelBackpressure(this.name)}getListenerConsumerBackpressure(t){return this.hasAnyListenerConsumer(t)?this.client.getChannelListenerConsumerBackpressure(t):0}getOutputConsumerBackpressure(t){return this.hasOutputConsumer(t)?this.client.getChannelOutputConsumerBackpressure(t):0}closeOutput(){this.client.channelCloseOutput(this.name)}closeListener(t){this.client.channelCloseListener(this.name,t)}closeAllListeners(){this.client.channelCloseAllListeners(this.name)}killOutput(){this.client.channelKillOutput(this.name)}killListener(t){this.client.channelKillListener(this.name,t)}killAllListeners(){this.client.channelKillAllListeners(this.name)}getOutputConsumerStatsList(){return this.client.channelGetOutputConsumerStatsList(this.name)}getListenerConsumerStatsList(t){return this.client.channelGetListenerConsumerStatsList(this.name,t)}getAllListenersConsumerStatsList(){return this.client.channelGetAllListenersConsumerStatsList(this.name)}getOutputBackpressure(){return this.client.channelGetOutputBackpressure(this.name)}getListenerBackpressure(t){return this.client.channelGetListenerBackpressure(this.name,t)}getAllListenersBackpressure(){return this.client.channelGetAllListenersBackpressure(this.name)}hasOutputConsumer(t){return this.client.channelHasOutputConsumer(this.name,t)}hasListenerConsumer(t,e){return this.client.channelHasListenerConsumer(this.name,t,e)}hasAnyListenerConsumer(t){return this.client.channelHasAnyListenerConsumer(this.name,t)}get state(){return this.client.getChannelState(this.name)}set state(t){throw new Error("Cannot directly set channel state")}get options(){return this.client.getChannelOptions(this.name)}set options(t){throw new Error("Cannot directly set channel options")}subscribe(t){this.client.subscribe(this.name,t)}unsubscribe(){this.client.unsubscribe(this.name)}isSubscribed(t){return this.client.isSubscribed(this.name,t)}transmitPublish(t){return this.client.transmitPublish(this.name,t)}invokePublish(t){return this.client.invokePublish(this.name,t)}}n.PENDING="pending",n.SUBSCRIBED="subscribed",n.UNSUBSCRIBED="unsubscribed",e.exports=n},{"consumable-stream":12}],8:[function(t,e){const r=t("sc-errors"),n=r.InvalidActionError;e.exports=function(t,e,o,i){this.socket=t,this.id=e,this.procedure=o,this.data=i,this.sent=!1,this._respond=((t,e)=>{if(this.sent)throw new n(`Response to request ${this.id} has already been sent`);this.sent=!0,this.socket.sendObject(t,e)}),this.end=((t,e)=>{let r={rid:this.id};void 0!==t&&(r.data=t),this._respond(r,e)}),this.error=((t,e)=>{let n={rid:this.id,error:r.dehydrateError(t)};this._respond(n,e)})}},{"sc-errors":21}],9:[function(t,e){const r=t("stream-demux");function n(){this._listenerDemux=new r}n.prototype.emit=function(t,e){this._listenerDemux.write(t,e)},n.prototype.listener=function(t){return this._listenerDemux.stream(t)},n.prototype.closeListener=function(t){this._listenerDemux.close(t)},n.prototype.closeAllListeners=function(){this._listenerDemux.closeAll()},n.prototype.getListenerConsumerStats=function(t){return this._listenerDemux.getConsumerStats(t)},n.prototype.getListenerConsumerStatsList=function(t){return this._listenerDemux.getConsumerStatsList(t)},n.prototype.getAllListenersConsumerStatsList=function(){return this._listenerDemux.getConsumerStatsListAll()},n.prototype.killListener=function(t){this._listenerDemux.kill(t)},n.prototype.killAllListeners=function(){this._listenerDemux.killAll()},n.prototype.killListenerConsumer=function(t){this._listenerDemux.killConsumer(t)},n.prototype.getListenerBackpressure=function(t){return this._listenerDemux.getBackpressure(t)},n.prototype.getAllListenersBackpressure=function(){return this._listenerDemux.getBackpressureAll()},n.prototype.getListenerConsumerBackpressure=function(t){return this._listenerDemux.getConsumerBackpressure(t)},n.prototype.hasListenerConsumer=function(t,e){return this._listenerDemux.hasConsumer(t,e)},n.prototype.hasAnyListenerConsumer=function(t){return this._listenerDemux.hasConsumerAll(t)},e.exports=n},{"stream-demux":24}],10:[function(t,e,r){"use strict";r.byteLength=function(t){var e=c(t),r=e[0],n=e[1];return 3*(r+n)/4-n},r.toByteArray=function(t){var e,r,n=c(t),s=n[0],a=n[1],u=new i(function(t,e,r){return 3*(e+r)/4-r}(0,s,a)),h=0,l=a>0?s-4:s;for(r=0;r>16&255,u[h++]=e>>8&255,u[h++]=255&e;2===a&&(e=o[t.charCodeAt(r)]<<2|o[t.charCodeAt(r+1)]>>4,u[h++]=255&e);1===a&&(e=o[t.charCodeAt(r)]<<10|o[t.charCodeAt(r+1)]<<4|o[t.charCodeAt(r+2)]>>2,u[h++]=e>>8&255,u[h++]=255&e);return u},r.fromByteArray=function(t){for(var e,r=t.length,o=r%3,i=[],s=0,a=r-o;sa?a:s+16383));1===o?(e=t[r-1],i.push(n[e>>2]+n[e<<4&63]+"==")):2===o&&(e=(t[r-2]<<8)+t[r-1],i.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return i.join("")};for(var n=[],o=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,u=s.length;a0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function h(t,e,r){for(var o,i,s=[],a=e;a>18&63]+n[i>>12&63]+n[i>>6&63]+n[63&i]);return s.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},{}],11:[function(t,e,r){(function(e){"use strict";var n=t("base64-js"),o=t("ieee754"),i="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;r.Buffer=e,r.SlowBuffer=function(t){+t!=t&&(t=0);return e.alloc(+t)},r.INSPECT_MAX_BYTES=50;var s=2147483647;function a(t){if(t>s)throw new RangeError('The value "'+t+'" is invalid for option "size"');var r=new Uint8Array(t);return Object.setPrototypeOf(r,e.prototype),r}function e(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return h(t)}return u(t,e,r)}function u(t,r,n){if("string"==typeof t)return function(t,r){"string"==typeof r&&""!==r||(r="utf8");if(!e.isEncoding(r))throw new TypeError("Unknown encoding: "+r);var n=0|f(t,r),o=a(n),i=o.write(t,r);i!==n&&(o=o.slice(0,i));return o}(t,r);if(ArrayBuffer.isView(t))return l(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(M(t,ArrayBuffer)||t&&M(t.buffer,ArrayBuffer))return function(t,r,n){if(r<0||t.byteLength=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return 0|t}function f(t,r){if(e.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||M(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var n=t.length,o=arguments.length>2&&!0===arguments[2];if(!o&&0===n)return 0;for(var i=!1;;)switch(r){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return j(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return U(t).length;default:if(i)return o?-1:j(t).length;r=(""+r).toLowerCase(),i=!0}}function d(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function m(t,r,n,o,i){if(0===t.length)return-1;if("string"==typeof n?(o=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),H(n=+n)&&(n=i?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(i)return-1;n=t.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof r&&(r=e.from(r,o)),e.isBuffer(r))return 0===r.length?-1:y(t,r,n,o,i);if("number"==typeof r)return r&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,r,n):Uint8Array.prototype.lastIndexOf.call(t,r,n):y(t,[r],n,o,i);throw new TypeError("val must be string, number or Buffer")}function y(t,e,r,n,o){var i,s=1,a=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;s=2,a/=2,u/=2,r/=2}function c(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(o){var h=-1;for(i=r;ia&&(r=a-u),i=r;i>=0;i--){for(var l=!0,p=0;po&&(n=o):n=o;var i=e.length;n>i/2&&(n=i/2);for(var s=0;s>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function w(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function C(t,e,r){r=Math.min(t.length,r);for(var n=[],o=e;o239?4:c>223?3:c>191?2:1;if(o+l<=r)switch(l){case 1:c<128&&(h=c);break;case 2:128==(192&(i=t[o+1]))&&(u=(31&c)<<6|63&i)>127&&(h=u);break;case 3:i=t[o+1],s=t[o+2],128==(192&i)&&128==(192&s)&&(u=(15&c)<<12|(63&i)<<6|63&s)>2047&&(u<55296||u>57343)&&(h=u);break;case 4:i=t[o+1],s=t[o+2],a=t[o+3],128==(192&i)&&128==(192&s)&&128==(192&a)&&(u=(15&c)<<18|(63&i)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(h=u)}null===h?(h=65533,l=1):h>65535&&(h-=65536,n.push(h>>>10&1023|55296),h=56320|1023&h),n.push(h),o+=l}return function(t){var e=t.length;if(e<=S)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return B(this,e,r);case"utf8":case"utf-8":return C(this,e,r);case"ascii":return T(this,e,r);case"latin1":case"binary":return A(this,e,r);case"base64":return w(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return O(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},e.prototype.toLocaleString=e.prototype.toString,e.prototype.equals=function(t){if(!e.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===e.compare(this,t)},e.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),""},i&&(e.prototype[i]=e.prototype.inspect),e.prototype.compare=function(t,r,n,o,i){if(M(t,Uint8Array)&&(t=e.from(t,t.offset,t.byteLength)),!e.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===r&&(r=0),void 0===n&&(n=t?t.length:0),void 0===o&&(o=0),void 0===i&&(i=this.length),r<0||n>t.length||o<0||i>this.length)throw new RangeError("out of range index");if(o>=i&&r>=n)return 0;if(o>=i)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,o>>>=0,i>>>=0,this===t)return 0;for(var s=i-o,a=n-r,u=Math.min(s,a),c=this.slice(o,i),h=t.slice(r,n),l=0;l>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return g(this,t,e,r);case"utf8":case"utf-8":return b(this,t,e,r);case"ascii":return v(this,t,e,r);case"latin1":case"binary":return _(this,t,e,r);case"base64":return k(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return E(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},e.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var S=4096;function T(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;on)&&(r=n);for(var o="",i=e;ir)throw new RangeError("Trying to access beyond buffer length")}function I(t,r,n,o,i,s){if(!e.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>i||rt.length)throw new RangeError("Index out of range")}function D(t,e,r,n){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function L(t,e,r,n,i){return e=+e,r>>>=0,i||D(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function N(t,e,r,n,i){return e=+e,r>>>=0,i||D(t,0,r,8),o.write(t,e,r,n,52,8),r+8}e.prototype.slice=function(t,r){var n=this.length;t=~~t,r=void 0===r?n:~~r,t<0?(t+=n)<0&&(t=0):t>n&&(t=n),r<0?(r+=n)<0&&(r=0):r>n&&(r=n),r>>=0,e>>>=0,r||x(t,e,this.length);for(var n=this[t],o=1,i=0;++i>>=0,e>>>=0,r||x(t,e,this.length);for(var n=this[t+--e],o=1;e>0&&(o*=256);)n+=this[t+--e]*o;return n},e.prototype.readUInt8=function(t,e){return t>>>=0,e||x(t,1,this.length),this[t]},e.prototype.readUInt16LE=function(t,e){return t>>>=0,e||x(t,2,this.length),this[t]|this[t+1]<<8},e.prototype.readUInt16BE=function(t,e){return t>>>=0,e||x(t,2,this.length),this[t]<<8|this[t+1]},e.prototype.readUInt32LE=function(t,e){return t>>>=0,e||x(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},e.prototype.readUInt32BE=function(t,e){return t>>>=0,e||x(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},e.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||x(t,e,this.length);for(var n=this[t],o=1,i=0;++i=(o*=128)&&(n-=Math.pow(2,8*e)),n},e.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||x(t,e,this.length);for(var n=e,o=1,i=this[t+--n];n>0&&(o*=256);)i+=this[t+--n]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*e)),i},e.prototype.readInt8=function(t,e){return t>>>=0,e||x(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},e.prototype.readInt16LE=function(t,e){t>>>=0,e||x(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},e.prototype.readInt16BE=function(t,e){t>>>=0,e||x(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},e.prototype.readInt32LE=function(t,e){return t>>>=0,e||x(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},e.prototype.readInt32BE=function(t,e){return t>>>=0,e||x(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},e.prototype.readFloatLE=function(t,e){return t>>>=0,e||x(t,4,this.length),o.read(this,t,!0,23,4)},e.prototype.readFloatBE=function(t,e){return t>>>=0,e||x(t,4,this.length),o.read(this,t,!1,23,4)},e.prototype.readDoubleLE=function(t,e){return t>>>=0,e||x(t,8,this.length),o.read(this,t,!0,52,8)},e.prototype.readDoubleBE=function(t,e){return t>>>=0,e||x(t,8,this.length),o.read(this,t,!1,52,8)},e.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||I(this,t,e,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n)||I(this,t,e,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},e.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||I(this,t,e,1,255,0),this[e]=255&t,e+1},e.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||I(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},e.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||I(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},e.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||I(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},e.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||I(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},e.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);I(this,t,e,r,o-1,-o)}var i=0,s=1,a=0;for(this[e]=255&t;++i>0)-a&255;return e+r},e.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);I(this,t,e,r,o-1,-o)}var i=r-1,s=1,a=0;for(this[e+i]=255&t;--i>=0&&(s*=256);)t<0&&0===a&&0!==this[e+i+1]&&(a=1),this[e+i]=(t/s>>0)-a&255;return e+r},e.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||I(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},e.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||I(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},e.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||I(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},e.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||I(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},e.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||I(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},e.prototype.writeFloatLE=function(t,e,r){return L(this,t,e,!0,r)},e.prototype.writeFloatBE=function(t,e,r){return L(this,t,e,!1,r)},e.prototype.writeDoubleLE=function(t,e,r){return N(this,t,e,!0,r)},e.prototype.writeDoubleBE=function(t,e,r){return N(this,t,e,!1,r)},e.prototype.copy=function(t,r,n,o){if(!e.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),o||0===o||(o=this.length),r>=t.length&&(r=t.length),r||(r=0),o>0&&o=this.length)throw new RangeError("Index out of range");if(o<0)throw new RangeError("sourceEnd out of bounds");o>this.length&&(o=this.length),t.length-r=0;--s)t[s+r]=this[s+n];else Uint8Array.prototype.set.call(t,this.subarray(n,o),r);return i},e.prototype.fill=function(t,r,n,o){if("string"==typeof t){if("string"==typeof r?(o=r,r=0,n=this.length):"string"==typeof n&&(o=n,n=this.length),void 0!==o&&"string"!=typeof o)throw new TypeError("encoding must be a string");if("string"==typeof o&&!e.isEncoding(o))throw new TypeError("Unknown encoding: "+o);if(1===t.length){var i=t.charCodeAt(0);("utf8"===o&&i<128||"latin1"===o)&&(t=i)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(r<0||this.length>>=0,n=void 0===n?this.length:n>>>0,t||(t=0),"number"==typeof t)for(s=r;s55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(s+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function U(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(P,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function R(t,e,r,n){for(var o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function M(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function H(t){return t!=t}var G=function(){for(var t=new Array(256),e=0;e<16;++e)for(var r=16*e,n=0;n<16;++n)t[r+n]="0123456789abcdef"[e]+"0123456789abcdef"[n];return t}()}).call(this,t("buffer").Buffer)},{"base64-js":10,buffer:11,ieee754:13}],12:[function(t,e){e.exports=class{async next(t){let e=this.createConsumer(t),r=await e.next();return e.return(),r}async once(t){let e=await this.next(t);return e.done&&await new Promise(()=>{}),e.value}createConsumer(){throw new TypeError("Method must be overriden by subclass")}createConsumable(t){let e=this.createConsumer(t);return{[Symbol.asyncIterator]:()=>e}}[Symbol.asyncIterator](){return this.createConsumer()}}},{}],13:[function(t,e,r){r.read=function(t,e,r,n,o){var i,s,a=8*o-n-1,u=(1<>1,h=-7,l=r?o-1:0,p=r?-1:1,f=t[e+l];for(l+=p,i=f&(1<<-h)-1,f>>=-h,h+=a;h>0;i=256*i+t[e+l],l+=p,h-=8);for(s=i&(1<<-h)-1,i>>=-h,h+=n;h>0;s=256*s+t[e+l],l+=p,h-=8);if(0===i)i=1-c;else{if(i===u)return s?NaN:1/0*(f?-1:1);s+=Math.pow(2,n),i-=c}return(f?-1:1)*s*Math.pow(2,i-n)},r.write=function(t,e,r,n,o,i){var s,a,u,c=8*i-o-1,h=(1<>1,p=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,f=n?0:i-1,d=n?1:-1,m=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=h):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),(e+=s+l>=1?p/u:p*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=h?(a=0,s=h):s+l>=1?(a=(e*u-1)*Math.pow(2,o),s+=l):(a=e*Math.pow(2,l-1)*Math.pow(2,o),s=0));o>=8;t[r+f]=255&a,f+=d,a/=256,o-=8);for(s=s<0;t[r+f]=255&s,f+=d,s/=256,c-=8);t[r+f-d]|=128*m}},{}],14:[function(t,e){"use strict";var r="An argument without append, prepend, or detach methods was given to `List";function n(){if(arguments.length)return n.from(arguments)}var o=n.prototype;function i(){}n.of=function(){return n.from.call(this,arguments)},n.from=function(t){var e,r,n,o=new this;if(t&&(e=t.length))for(r=-1;++r-1},Ct.prototype.set=function(t,e){var r=this.__data__,n=Ot(r,t);return n<0?r.push([t,e]):r[n][1]=e,this},St.prototype.clear=function(){this.__data__={hash:new wt,map:new(lt||Ct),string:new wt}},St.prototype.delete=function(t){return Nt(this,t).delete(t)},St.prototype.get=function(t){return Nt(this,t).get(t)},St.prototype.has=function(t){return Nt(this,t).has(t)},St.prototype.set=function(t,e){return Nt(this,t).set(t,e),this},Tt.prototype.clear=function(){this.__data__=new Ct},Tt.prototype.delete=function(t){return this.__data__.delete(t)},Tt.prototype.get=function(t){return this.__data__.get(t)},Tt.prototype.has=function(t){return this.__data__.has(t)},Tt.prototype.set=function(t,e){var r=this.__data__;if(r instanceof Ct){var n=r.__data__;if(!lt||n.length<199)return n.push([t,e]),this;r=this.__data__=new St(n)}return r.set(t,e),this};var jt=at?$(at,Object):function(){return[]},Ut=function(t){return Z.call(t)};function Rt(t,e){return!!(e=null==e?n:e)&&("number"==typeof t||O.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=n}(t.length)&&!zt(t)}var qt=ut||function(){return!1};function zt(t){var e=Vt(t)?Z.call(t):"";return e==a||e==u}function Vt(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function Wt(t){return Ft(t)?At(t):function(t){if(!Mt(t))return ct(t);var e=[];for(var r in Object(t))X.call(t,r)&&"constructor"!=r&&e.push(r);return e}(t)}e.exports=function(t){return xt(t,!0,!0)}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],17:[function(t,e){"use strict";function r(t,e){return Object.prototype.hasOwnProperty.call(t,e)}e.exports=function(t,e,o,i){e=e||"&",o=o||"=";var s={};if("string"!=typeof t||0===t.length)return s;var a=/\+/g;t=t.split(e);var u=1e3;i&&"number"==typeof i.maxKeys&&(u=i.maxKeys);var c=t.length;u>0&&c>u&&(c=u);for(var h=0;h=0?(l=m.substr(0,y),p=m.substr(y+1)):(l=m,p=""),f=decodeURIComponent(l),d=decodeURIComponent(p),r(s,f)?n(s[f])?s[f].push(d):s[f]=[s[f],d]:s[f]=d}return s};var n=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)}},{}],18:[function(t,e){"use strict";var r=function(t){switch(typeof t){case"string":return t;case"boolean":return t?"true":"false";case"number":return isFinite(t)?t:"";default:return""}};e.exports=function(t,e,s,a){return e=e||"&",s=s||"=",null===t&&(t=void 0),"object"==typeof t?o(i(t),function(i){var a=encodeURIComponent(r(i))+s;return n(t[i])?o(t[i],function(t){return a+encodeURIComponent(r(t))}).join(e):a+encodeURIComponent(r(t[i]))}).join(e):a?encodeURIComponent(r(a))+s+encodeURIComponent(r(t)):""};var n=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function o(t,e){if(t.map)return t.map(e);for(var r=[],n=0;n>2],o+=r[(3&e[i])<<4|e[i+1]>>4],o+=r[(15&e[i+1])<<2|e[i+2]>>6],o+=r[63&e[i+2]];return n%3==2?o=o.substring(0,o.length-1)+"=":n%3==1&&(o=o.substring(0,o.length-2)+"=="),o}(n)};if(t.Buffer){if(n instanceof t.Buffer)return{base64:!0,data:n.toString("base64")};if(n&&"Buffer"===n.type&&Array.isArray(n.data))return{base64:!0,data:(t.Buffer.from?t.Buffer.from(n.data):new t.Buffer(n.data)).toString("base64")}}return n};e.exports.decode=function(t){if(null==t)return null;if("#1"===t||"#2"===t)return t;var e=t.toString();if(!n.test(e))return e;try{return JSON.parse(e)}catch(t){}return e},e.exports.encode=function(t){return"#1"===t||"#2"===t?t:JSON.stringify(t,o)}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],23:[function(t,e){const r=t("consumable-stream");e.exports=class extends r{constructor(t,e){super(),this.name=e,this._streamDemux=t}createConsumer(t){return this._streamDemux.createConsumer(this.name,t)}}},{"consumable-stream":12}],24:[function(t,e){const r=t("writable-consumable-stream"),n=t("./demuxed-consumable-stream");e.exports=class{constructor(){this._mainStream=new r}write(t,e){this._mainStream.write({stream:t,data:{value:e,done:!1}})}close(t,e){this._mainStream.write({stream:t,data:{value:e,done:!0}})}closeAll(t){this._mainStream.close(t)}writeToConsumer(t,e){this._mainStream.writeToConsumer(t,{consumerId:t,data:{value:e,done:!1}})}closeConsumer(t,e){this._mainStream.closeConsumer(t,{consumerId:t,data:{value:e,done:!0}})}getConsumerStats(t){return this._mainStream.getConsumerStats(t)}getConsumerStatsList(t){return this._mainStream.getConsumerStatsList().filter(e=>e.stream===t)}getConsumerStatsListAll(){return this._mainStream.getConsumerStatsList()}kill(t,e){let r=this.getConsumerStatsList(t),n=r.length;for(let t=0;tn&&(n=r.backpressure)}return n}getBackpressureAll(){return this._mainStream.getBackpressure()}getConsumerBackpressure(t){return this._mainStream.getConsumerBackpressure(t)}hasConsumer(t,e){let r=this._mainStream.getConsumerStats(e);return!!r&&r.stream===t}hasConsumerAll(t){return this._mainStream.hasConsumer(t)}createConsumer(t,e){let r=this._mainStream.createConsumer(e),n=r.next;r.next=async function(){for(;;){let e=await n.apply(this,arguments);if(e.value&&(e.value.stream===t||e.value.consumerId===this.id))return e.value.data.done&&this.return(),e.value.data;if(e.done)return e}};let o=r.getStats;r.getStats=function(){let e=o.apply(this,arguments);return e.stream=t,e};let i=r.applyBackpressure;r.applyBackpressure=function(e){!e.value||e.value.stream!==t&&e.value.consumerId!==this.id?e.done&&i.apply(this,arguments):i.apply(this,arguments)};let s=r.releaseBackpressure;return r.releaseBackpressure=function(e){!e.value||e.value.stream!==t&&e.value.consumerId!==this.id?e.done&&s.apply(this,arguments):s.apply(this,arguments)},r}stream(t){return new n(this,t)}}},{"./demuxed-consumable-stream":23,"writable-consumable-stream":31}],25:[function(t,e){var r=t("./v1"),n=t("./v4"),o=n;o.v1=r,o.v4=n,e.exports=o},{"./v1":28,"./v4":29}],26:[function(t,e){for(var r=[],n=0;n<256;++n)r[n]=(n+256).toString(16).substr(1);e.exports=function(t,e){var n=e||0,o=r;return[o[t[n++]],o[t[n++]],o[t[n++]],o[t[n++]],"-",o[t[n++]],o[t[n++]],"-",o[t[n++]],o[t[n++]],"-",o[t[n++]],o[t[n++]],"-",o[t[n++]],o[t[n++]],o[t[n++]],o[t[n++]],o[t[n++]],o[t[n++]]].join("")}},{}],27:[function(t,e){var r="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(r){var n=new Uint8Array(16);e.exports=function(){return r(n),n}}else{var o=new Array(16);e.exports=function(){for(var t,e=0;e<16;e++)0==(3&e)&&(t=4294967296*Math.random()),o[e]=t>>>((3&e)<<3)&255;return o}}},{}],28:[function(t,e){var r,n,o=t("./lib/rng"),i=t("./lib/bytesToUuid"),s=0,a=0;e.exports=function(t,e,u){var c=e&&u||0,h=e||[],l=(t=t||{}).node||r,p=void 0!==t.clockseq?t.clockseq:n;if(null==l||null==p){var f=o();null==l&&(l=r=[1|f[0],f[1],f[2],f[3],f[4],f[5]]),null==p&&(p=n=16383&(f[6]<<8|f[7]))}var d=void 0!==t.msecs?t.msecs:(new Date).getTime(),m=void 0!==t.nsecs?t.nsecs:a+1,y=d-s+(m-a)/1e4;if(y<0&&void 0===t.clockseq&&(p=p+1&16383),(y<0||d>s)&&void 0===t.nsecs&&(m=0),m>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");s=d,a=m,n=p;var g=(1e4*(268435455&(d+=122192928e5))+m)%4294967296;h[c++]=g>>>24&255,h[c++]=g>>>16&255,h[c++]=g>>>8&255,h[c++]=255&g;var b=d/4294967296*1e4&268435455;h[c++]=b>>>8&255,h[c++]=255&b,h[c++]=b>>>24&15|16,h[c++]=b>>>16&255,h[c++]=p>>>8|128,h[c++]=255&p;for(var v=0;v<6;++v)h[c+v]=l[v];return e||i(h)}},{"./lib/bytesToUuid":26,"./lib/rng":27}],29:[function(t,e){var r=t("./lib/rng"),n=t("./lib/bytesToUuid");e.exports=function(t,e,o){var i=e&&o||0;"string"==typeof t&&(e="binary"===t?new Array(16):null,t=null);var s=(t=t||{}).random||(t.rng||r)();if(s[6]=15&s[6]|64,s[8]=63&s[8]|128,e)for(var a=0;a<16;++a)e[i+a]=s[a];return e||n(s)}},{"./lib/bytesToUuid":26,"./lib/rng":27}],30:[function(t,e){e.exports=class{constructor(t,e,r,n){this.id=e,this._backpressure=0,this.stream=t,this.currentNode=r,this.timeout=n,this._isIterating=!1,this.stream.setConsumer(this.id,this)}getStats(){let t={id:this.id,backpressure:this._backpressure};return null!=this.timeout&&(t.timeout=this.timeout),t}resetBackpressure(){this._backpressure=0}applyBackpressure(t){this._backpressure++}releaseBackpressure(t){this._backpressure--}getBackpressure(){return this._backpressure}write(t){void 0!==this._timeoutId&&(clearTimeout(this._timeoutId),delete this._timeoutId),this.applyBackpressure(t),this._resolve&&(this._resolve(),delete this._resolve)}kill(t){void 0!==this._timeoutId&&(clearTimeout(this._timeoutId),delete this._timeoutId),this._isIterating?(this._killPacket={value:t,done:!0},this.applyBackpressure(this._killPacket)):(this.stream.removeConsumer(this.id),this.resetBackpressure()),this._resolve&&(this._resolve(),delete this._resolve)}async _waitForNextItem(t){return new Promise((e,r)=>{let n;if(this._resolve=e,void 0!==t){let e=new Error("Stream consumer iteration timed out");(async()=>{let o=function(t){let e,r=new Promise(r=>{e=setTimeout(r,t)});return{timeoutId:e,promise:r}}(t);n=o.timeoutId,await o.promise,e.name="TimeoutError",delete this._resolve,r(e)})()}this._timeoutId=n})}async next(){for(this._isIterating=!0,this.stream.setConsumer(this.id,this);;){if(!this.currentNode.next)try{await this._waitForNextItem(this.timeout)}catch(t){throw this._isIterating=!1,this.stream.removeConsumer(this.id),t}if(this._killPacket){this._isIterating=!1,this.stream.removeConsumer(this.id),this.resetBackpressure();let t=this._killPacket;return delete this._killPacket,t}if(this.currentNode=this.currentNode.next,this.releaseBackpressure(this.currentNode.data),!this.currentNode.consumerId||this.currentNode.consumerId===this.id)return this.currentNode.data.done&&(this._isIterating=!1,this.stream.removeConsumer(this.id)),this.currentNode.data}}return(){return delete this.currentNode,this._isIterating=!1,this.stream.removeConsumer(this.id),this.resetBackpressure(),{}}}},{}],31:[function(t,e){const r=t("consumable-stream"),n=t("./consumer");e.exports=class extends r{constructor(){super(),this.nextConsumerId=1,this._consumers={},this._tailNode={next:null,data:{value:void 0,done:!1}}}_write(t,e,r){let n={data:{value:t,done:e},next:null};r&&(n.consumerId=r),this._tailNode.next=n,this._tailNode=n;let o=Object.values(this._consumers),i=o.length;for(let t=0;tr&&(r=e)}return r}getConsumerBackpressure(t){let e=this._consumers[t];return e?e.getBackpressure():0}hasConsumer(t){return!!this._consumers[t]}setConsumer(t,e){this._consumers[t]=e,e.currentNode||(e.currentNode=this._tailNode)}removeConsumer(t){delete this._consumers[t]}getConsumerStats(t){let e=this._consumers[t];if(e)return e.getStats()}getConsumerStatsList(){let t=[],e=Object.values(this._consumers),r=e.length;for(let n=0;n { @@ -168,14 +168,14 @@ describe('Integration tests', function () { describe('Authentication', function () { it('Should not send back error if JWT is not provided in handshake', async function () { - client = asyngularClient.create(clientOptions); + client = socketClusterClient.create(clientOptions); let event = await client.listener('connect').once(); assert.equal(event.authError === undefined, true); }); it('Should be authenticated on connect if previous JWT token is present', async function () { - global.localStorage.setItem('asyngular.authToken', validSignedAuthTokenBob); - client = asyngularClient.create(clientOptions); + global.localStorage.setItem('socketcluster.authToken', validSignedAuthTokenBob); + client = socketClusterClient.create(clientOptions); let event = await client.listener('connect').once(); assert.equal(client.authState, 'authenticated'); @@ -184,8 +184,8 @@ describe('Integration tests', function () { }); it('Should send back error if JWT is invalid during handshake', async function () { - global.localStorage.setItem('asyngular.authToken', validSignedAuthTokenBob); - client = asyngularClient.create(clientOptions); + global.localStorage.setItem('socketcluster.authToken', validSignedAuthTokenBob); + client = socketClusterClient.create(clientOptions); let event = await client.listener('connect').once(); assert.notEqual(event, null); @@ -218,8 +218,8 @@ describe('Integration tests', function () { }); it('Should allow switching between users', async function () { - global.localStorage.setItem('asyngular.authToken', validSignedAuthTokenBob); - client = asyngularClient.create(clientOptions); + global.localStorage.setItem('socketcluster.authToken', validSignedAuthTokenBob); + client = socketClusterClient.create(clientOptions); let authenticateTriggered = false; let authStateChangeTriggered = false; @@ -251,7 +251,7 @@ describe('Integration tests', function () { it('If token engine signing is synchronous, authentication can be captured using the authenticate event', async function () { let port = 8509; - let customServer = asyngularServer.listen(port, { + let customServer = socketClusterServer.listen(port, { authKey: serverOptions.authKey, authSignAsync: false }); @@ -263,7 +263,7 @@ describe('Integration tests', function () { await customServer.listener('ready').once(); - client = asyngularClient.create({ + client = socketClusterClient.create({ hostname: clientOptions.hostname, port: port }); @@ -285,7 +285,7 @@ describe('Integration tests', function () { it('If token engine signing is asynchronous, authentication can be captured using the authenticate event', async function () { let port = 8510; - let customServer = asyngularServer.listen(port, { + let customServer = socketClusterServer.listen(port, { authKey: serverOptions.authKey, authSignAsync: true }); @@ -297,7 +297,7 @@ describe('Integration tests', function () { await customServer.listener('ready').once(); - client = asyngularClient.create({ + client = socketClusterClient.create({ hostname: clientOptions.hostname, port: port }); @@ -319,7 +319,7 @@ describe('Integration tests', function () { it('If token verification is synchronous, authentication can be captured using the authenticate event', async function () { let port = 8511; - customServer = asyngularServer.listen(port, { + customServer = socketClusterServer.listen(port, { authKey: serverOptions.authKey, authVerifyAsync: false }); @@ -331,7 +331,7 @@ describe('Integration tests', function () { await customServer.listener('ready').once(); - client = asyngularClient.create({ + client = socketClusterClient.create({ hostname: clientOptions.hostname, port: port }); @@ -362,7 +362,7 @@ describe('Integration tests', function () { }); it('Should start out in pending authState and switch to unauthenticated if no token exists', async function () { - client = asyngularClient.create(clientOptions); + client = socketClusterClient.create(clientOptions); assert.equal(client.authState, 'unauthenticated'); (async () => { @@ -374,8 +374,8 @@ describe('Integration tests', function () { }); it('Should deal with auth engine errors related to saveToken function', async function () { - global.localStorage.setItem('asyngular.authToken', validSignedAuthTokenBob); - client = asyngularClient.create(clientOptions); + global.localStorage.setItem('socketcluster.authToken', validSignedAuthTokenBob); + client = socketClusterClient.create(clientOptions); let caughtError; @@ -418,7 +418,7 @@ describe('Integration tests', function () { }); it('Should gracefully handle authenticate abortion due to disconnection', async function () { - client = asyngularClient.create(clientOptions); + client = socketClusterClient.create(clientOptions); await client.listener('connect').once(); @@ -435,7 +435,7 @@ describe('Integration tests', function () { }); it('Should go through the correct sequence of authentication state changes when dealing with disconnections; part 1', async function () { - client = asyngularClient.create(clientOptions); + client = socketClusterClient.create(clientOptions); let expectedAuthStateChanges = [ 'unauthenticated->authenticated' @@ -483,8 +483,8 @@ describe('Integration tests', function () { }); it('Should go through the correct sequence of authentication state changes when dealing with disconnections; part 2', async function () { - global.localStorage.setItem('asyngular.authToken', validSignedAuthTokenBob); - client = asyngularClient.create(clientOptions); + global.localStorage.setItem('socketcluster.authToken', validSignedAuthTokenBob); + client = socketClusterClient.create(clientOptions); let expectedAuthStateChanges = [ 'unauthenticated->authenticated', @@ -524,8 +524,8 @@ describe('Integration tests', function () { }); it('Should go through the correct sequence of authentication state changes when dealing with disconnections; part 3', async function () { - global.localStorage.setItem('asyngular.authToken', validSignedAuthTokenBob); - client = asyngularClient.create(clientOptions); + global.localStorage.setItem('socketcluster.authToken', validSignedAuthTokenBob); + client = socketClusterClient.create(clientOptions); let expectedAuthStateChanges = [ 'unauthenticated->authenticated', @@ -558,8 +558,8 @@ describe('Integration tests', function () { }); it('Should go through the correct sequence of authentication state changes when authenticating as a user while already authenticated as another user', async function () { - global.localStorage.setItem('asyngular.authToken', validSignedAuthTokenBob); - client = asyngularClient.create(clientOptions); + global.localStorage.setItem('socketcluster.authToken', validSignedAuthTokenBob); + client = socketClusterClient.create(clientOptions); let expectedAuthStateChanges = [ 'unauthenticated->authenticated' @@ -609,7 +609,7 @@ describe('Integration tests', function () { }); it('Should wait for socket to be authenticated before subscribing to waitForAuth channel', async function () { - client = asyngularClient.create(clientOptions); + client = socketClusterClient.create(clientOptions); let privateChannel = client.subscribe('priv', {waitForAuth: true}); assert.equal(privateChannel.state, 'pending'); @@ -638,8 +638,8 @@ describe('Integration tests', function () { }); it('Subscriptions (including those with waitForAuth option) should have priority over the authenticate action', async function () { - global.localStorage.setItem('asyngular.authToken', validSignedAuthTokenBob); - client = asyngularClient.create(clientOptions); + global.localStorage.setItem('socketcluster.authToken', validSignedAuthTokenBob); + client = socketClusterClient.create(clientOptions); let expectedAuthStateChanges = [ 'unauthenticated->authenticated', @@ -714,7 +714,7 @@ describe('Integration tests', function () { }); it('Should trigger the close event if the socket disconnects in the middle of the handshake phase', async function () { - client = asyngularClient.create(clientOptions); + client = socketClusterClient.create(clientOptions); let aborted = false; let diconnected = false; let closed = false; @@ -744,7 +744,7 @@ describe('Integration tests', function () { }); it('Should trigger the close event if the socket disconnects after the handshake phase', async function () { - client = asyngularClient.create(clientOptions); + client = socketClusterClient.create(clientOptions); let aborted = false; let diconnected = false; let closed = false; @@ -780,7 +780,7 @@ describe('Integration tests', function () { describe('Transmitting remote events', function () { it('Should not throw error on socket if ackTimeout elapses before response to event is sent back', async function () { - client = asyngularClient.create(clientOptions); + client = socketClusterClient.create(clientOptions); let caughtError; let clientError; @@ -818,7 +818,7 @@ describe('Integration tests', function () { let lastServerMessage = null; beforeEach('Setup publisher client', async function () { - publisherClient = asyngularClient.create(clientOptions); + publisherClient = socketClusterClient.create(clientOptions); server.removeMiddleware(server.MIDDLEWARE_INBOUND); server.setMiddleware(server.MIDDLEWARE_INBOUND, async (middlewareStream) => { @@ -836,7 +836,7 @@ describe('Integration tests', function () { }); it('Should receive transmitted publish messages if subscribed to channel', async function () { - client = asyngularClient.create(clientOptions); + client = socketClusterClient.create(clientOptions); let channel = client.subscribe('foo'); await channel.listener('subscribe').once(); @@ -864,7 +864,7 @@ describe('Integration tests', function () { }); it('Should receive invoked publish messages if subscribed to channel', async function () { - client = asyngularClient.create(clientOptions); + client = socketClusterClient.create(clientOptions); let channel = client.subscribe('bar'); await channel.listener('subscribe').once(); @@ -897,7 +897,7 @@ describe('Integration tests', function () { describe('Reconnecting socket', function () { it('Should disconnect socket with code 1000 and reconnect', async function () { - client = asyngularClient.create(clientOptions); + client = socketClusterClient.create(clientOptions); await client.listener('connect').once(); @@ -919,7 +919,7 @@ describe('Integration tests', function () { }); it('Should disconnect socket with custom code and data when socket.reconnect() is called with arguments', async function () { - client = asyngularClient.create(clientOptions); + client = socketClusterClient.create(clientOptions); await client.listener('connect').once(); @@ -942,7 +942,7 @@ describe('Integration tests', function () { describe('Order of events', function () { it('Should trigger unsubscribe event on channel before disconnect event', async function () { - client = asyngularClient.create(clientOptions); + client = socketClusterClient.create(clientOptions); let hasUnsubscribed = false; let fooChannel = client.subscribe('foo'); @@ -965,7 +965,7 @@ describe('Integration tests', function () { }); it('Should not invoke subscribeFail event if connection is aborted', async function () { - client = asyngularClient.create(clientOptions); + client = socketClusterClient.create(clientOptions); let hasSubscribeFailed = false; let gotBadConnectionError = false; let wasConnected = false; @@ -1005,7 +1005,7 @@ describe('Integration tests', function () { }); it('Should resolve invoke Promise with BadConnectionError before triggering the disconnect event', async function () { - client = asyngularClient.create(clientOptions); + client = socketClusterClient.create(clientOptions); let messageList = []; let clientState = client.state; @@ -1054,7 +1054,7 @@ describe('Integration tests', function () { } })(); - client = asyngularClient.create(clientOptions); + client = socketClusterClient.create(clientOptions); let clientError; @@ -1110,7 +1110,7 @@ describe('Integration tests', function () { }); it('Should correctly handle multiple successive connect and disconnect calls', async function () { - client = asyngularClient.create(clientOptions); + client = socketClusterClient.create(clientOptions); let eventList = []; @@ -1228,7 +1228,7 @@ describe('Integration tests', function () { describe('Ping/pong', function () { it('Should disconnect if ping is not received before timeout', async function () { clientOptions.connectTimeout = 500; - client = asyngularClient.create(clientOptions); + client = socketClusterClient.create(clientOptions); assert.equal(client.pingTimeout, 500); @@ -1267,7 +1267,7 @@ describe('Integration tests', function () { it('Should not disconnect if ping is not received before timeout when pingTimeoutDisabled is true', async function () { clientOptions.connectTimeout = 500; clientOptions.pingTimeoutDisabled = true; - client = asyngularClient.create(clientOptions); + client = socketClusterClient.create(clientOptions); assert.equal(client.pingTimeout, 500); @@ -1285,7 +1285,7 @@ describe('Integration tests', function () { describe('Consumable streams', function () { it('Should be able to get the stats list of consumers and check if consumers exist on specific channels', async function () { - client = asyngularClient.create(clientOptions); + client = socketClusterClient.create(clientOptions); let fooChannel = client.channel('foo'); (async () => { @@ -1327,7 +1327,7 @@ describe('Integration tests', function () { }); it('Should be able to check the listener backpressure for specific channels', async function () { - client = asyngularClient.create(clientOptions); + client = socketClusterClient.create(clientOptions); let fooChannel = client.channel('foo'); let barChannel = client.channel('bar'); @@ -1374,7 +1374,7 @@ describe('Integration tests', function () { }); it('Should be able to kill and close channels and backpressure should update accordingly', async function () { - client = asyngularClient.create(clientOptions); + client = socketClusterClient.create(clientOptions); await client.listener('connect').once(); @@ -1463,7 +1463,7 @@ describe('Integration tests', function () { describe('Utilities', function () { it('Can encode a string to base64 and then decode it back to utf8', async function () { - client = asyngularClient.create(clientOptions); + client = socketClusterClient.create(clientOptions); let encodedString = client.encodeBase64('This is a string'); assert.equal(encodedString, 'VGhpcyBpcyBhIHN0cmluZw=='); let decodedString = client.decodeBase64(encodedString);