Socket
Socket
Sign inDemoInstall

graphql-ws

Package Overview
Dependencies
0
Maintainers
1
Versions
103
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 5.6.3 to 5.6.4

6

lib/common.d.ts

@@ -14,2 +14,8 @@ /**

/**
* The deprecated subprotocol used by [subscriptions-transport-ws](https://github.com/apollographql/subscriptions-transport-ws).
*
* @private
*/
export declare const DEPRECATED_GRAPHQL_WS_PROTOCOL = "graphql-ws";
/**
* `graphql-ws` expected and standard close codes of the [GraphQL over WebSocket Protocol](/PROTOCOL.md).

@@ -16,0 +22,0 @@ *

8

lib/common.js

@@ -8,3 +8,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.stringifyMessage = exports.parseMessage = exports.isMessage = exports.MessageType = exports.CloseCode = exports.GRAPHQL_TRANSPORT_WS_PROTOCOL = void 0;
exports.stringifyMessage = exports.parseMessage = exports.isMessage = exports.MessageType = exports.CloseCode = exports.DEPRECATED_GRAPHQL_WS_PROTOCOL = exports.GRAPHQL_TRANSPORT_WS_PROTOCOL = void 0;
const utils_1 = require("./utils");

@@ -18,2 +18,8 @@ /**

/**
* The deprecated subprotocol used by [subscriptions-transport-ws](https://github.com/apollographql/subscriptions-transport-ws).
*
* @private
*/
exports.DEPRECATED_GRAPHQL_WS_PROTOCOL = 'graphql-ws';
/**
* `graphql-ws` expected and standard close codes of the [GraphQL over WebSocket Protocol](/PROTOCOL.md).

@@ -20,0 +26,0 @@ *

10

lib/use/fastify-websocket.js

@@ -117,7 +117,7 @@ "use strict";

clearInterval(pingInterval);
if (!isProd && code === common_1.CloseCode.SubprotocolNotAcceptable)
console.warn(`WebSocket protocol error occured. It was most likely caused due to an ` +
`unsupported subprotocol "${socket.protocol}" requested by the client. ` +
`graphql-ws implements exclusively the "${common_1.GRAPHQL_TRANSPORT_WS_PROTOCOL}" subprotocol, ` +
'please make sure that the client implements it too.');
if (!isProd &&
code === common_1.CloseCode.SubprotocolNotAcceptable &&
socket.protocol === common_1.DEPRECATED_GRAPHQL_WS_PROTOCOL)
console.warn(`Client provided the unsupported and deprecated subprotocol "${socket.protocol}" used by subscriptions-transport-ws.` +
'Please see https://www.apollographql.com/docs/apollo-server/data/subscriptions/#switching-from-subscriptions-transport-ws.');
closed(code, String(reason));

@@ -124,0 +124,0 @@ });

@@ -99,7 +99,7 @@ "use strict";

clearInterval(pingInterval);
if (!isProd && code === common_1.CloseCode.SubprotocolNotAcceptable)
console.warn(`WebSocket protocol error occured. It was most likely caused due to an ` +
`unsupported subprotocol "${socket.protocol}" requested by the client. ` +
`graphql-ws implements exclusively the "${common_1.GRAPHQL_TRANSPORT_WS_PROTOCOL}" subprotocol, ` +
'please make sure that the client implements it too.');
if (!isProd &&
code === common_1.CloseCode.SubprotocolNotAcceptable &&
socket.protocol === common_1.DEPRECATED_GRAPHQL_WS_PROTOCOL)
console.warn(`Client provided the unsupported and deprecated subprotocol "${socket.protocol}" used by subscriptions-transport-ws.` +
'Please see https://www.apollographql.com/docs/apollo-server/data/subscriptions/#switching-from-subscriptions-transport-ws.');
closed(code, String(reason));

@@ -106,0 +106,0 @@ });

{
"name": "graphql-ws",
"version": "5.6.3",
"version": "5.6.4",
"description": "Coherent, zero-dependency, lazy, simple, GraphQL over WebSocket Protocol compliant server and client",

@@ -30,3 +30,3 @@ "keywords": [

},
"packageManager": "yarn@3.1.0",
"packageManager": "yarn@3.2.0",
"main": "lib/index.js",

@@ -86,3 +86,3 @@ "module": "lib/index.mjs",

"devDependencies": {
"@babel/core": "^7.17.5",
"@babel/core": "^7.17.8",
"@babel/plugin-proposal-class-properties": "^7.16.7",

@@ -99,4 +99,4 @@ "@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.7",

"@types/ws": "^8.5.3",
"@typescript-eslint/eslint-plugin": "^5.14.0",
"@typescript-eslint/parser": "^5.14.0",
"@typescript-eslint/eslint-plugin": "^5.16.0",
"@typescript-eslint/parser": "^5.16.0",
"babel-jest": "^27.5.1",

@@ -107,9 +107,9 @@ "eslint": "^8.11.0",

"fastify": "^3.27.4",
"fastify-websocket": "^4.2.0",
"fastify-websocket": "^4.2.1",
"glob": "^7.2.0",
"graphql": "^16.3.0",
"jest": "^27.5.1",
"prettier": "^2.5.1",
"prettier": "^2.6.0",
"replacestream": "^4.0.3",
"rollup": "^2.70.0",
"rollup": "^2.70.1",
"rollup-plugin-terser": "^7.0.2",

@@ -116,0 +116,0 @@ "semantic-release": "^19.0.2",

@@ -55,2 +55,8 @@ (function (global, factory) {

/**
* The deprecated subprotocol used by [subscriptions-transport-ws](https://github.com/apollographql/subscriptions-transport-ws).
*
* @private
*/
const DEPRECATED_GRAPHQL_WS_PROTOCOL = 'graphql-ws';
/**
* `graphql-ws` expected and standard close codes of the [GraphQL over WebSocket Protocol](/PROTOCOL.md).

@@ -619,2 +625,3 @@ *

exports.DEPRECATED_GRAPHQL_WS_PROTOCOL = DEPRECATED_GRAPHQL_WS_PROTOCOL;
exports.GRAPHQL_TRANSPORT_WS_PROTOCOL = GRAPHQL_TRANSPORT_WS_PROTOCOL;

@@ -621,0 +628,0 @@ exports.createClient = createClient;

@@ -1,1 +0,1 @@

!function(e,o){"object"==typeof exports&&"undefined"!=typeof module?o(exports):"function"==typeof define&&define.amd?define(["exports"],o):o((e="undefined"!=typeof globalThis?globalThis:e||self).graphqlWs={})}(this,(function(e){"use strict";const o=Object.prototype.hasOwnProperty;function n(e){return"object"==typeof e&&null!==e}function t(e,n){return o.call(e,n)}function r(e,t){return o.call(e,t)&&n(e[t])}function i(e,n){return o.call(e,n)&&"string"==typeof e[n]}function a(e,o){return e.length<124?e:o}const s="graphql-transport-ws";var c,l;function d(o){if(n(o)){if(!i(o,"type"))return!1;switch(o.type){case e.MessageType.ConnectionInit:case e.MessageType.ConnectionAck:case e.MessageType.Ping:case e.MessageType.Pong:return!t(o,"payload")||void 0===o.payload||n(o.payload);case e.MessageType.Subscribe:return i(o,"id")&&r(o,"payload")&&(!t(o.payload,"operationName")||void 0===o.payload.operationName||null===o.payload.operationName||"string"==typeof o.payload.operationName)&&i(o.payload,"query")&&(!t(o.payload,"variables")||void 0===o.payload.variables||null===o.payload.variables||r(o.payload,"variables"))&&(!t(o.payload,"extensions")||void 0===o.payload.extensions||null===o.payload.extensions||r(o.payload,"extensions"));case e.MessageType.Next:return i(o,"id")&&r(o,"payload");case e.MessageType.Error:return i(o,"id")&&(a=o.payload,Array.isArray(a)&&a.length>0&&a.every((e=>"message"in e)));case e.MessageType.Complete:return i(o,"id");default:return!1}}var a;return!1}function p(e,o){if(d(e))return e;if("string"!=typeof e)throw new Error("Message not parsable");const n=JSON.parse(e,o);if(!d(n))throw new Error("Invalid message");return n}function u(e,o){if(!d(e))throw new Error("Cannot stringify invalid message");return JSON.stringify(e,o)}function y(e){return n(e)&&"code"in e&&"reason"in e}e.CloseCode=void 0,(c=e.CloseCode||(e.CloseCode={}))[c.InternalServerError=4500]="InternalServerError",c[c.InternalClientError=4005]="InternalClientError",c[c.BadRequest=4400]="BadRequest",c[c.BadResponse=4004]="BadResponse",c[c.Unauthorized=4401]="Unauthorized",c[c.Forbidden=4403]="Forbidden",c[c.SubprotocolNotAcceptable=4406]="SubprotocolNotAcceptable",c[c.ConnectionInitialisationTimeout=4408]="ConnectionInitialisationTimeout",c[c.ConnectionAcknowledgementTimeout=4504]="ConnectionAcknowledgementTimeout",c[c.SubscriberAlreadyExists=4409]="SubscriberAlreadyExists",c[c.TooManyInitialisationRequests=4429]="TooManyInitialisationRequests",e.MessageType=void 0,(l=e.MessageType||(e.MessageType={})).ConnectionInit="connection_init",l.ConnectionAck="connection_ack",l.Ping="ping",l.Pong="pong",l.Subscribe="subscribe",l.Next="next",l.Error="error",l.Complete="complete",e.GRAPHQL_TRANSPORT_WS_PROTOCOL=s,e.createClient=function(o){const{url:n,connectionParams:t,lazy:r=!0,onNonLazyError:i=console.error,lazyCloseTimeout:c=0,keepAlive:l=0,disablePong:d,connectionAckWaitTimeout:g=0,retryAttempts:f=5,retryWait:m=async function(e){let o=1e3;for(let n=0;n<e;n++)o*=2;await new Promise((e=>setTimeout(e,o+Math.floor(2700*Math.random()+300))))},isFatalConnectionProblem:C=(e=>!y(e)),on:b,webSocketImpl:w,generateID:x=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(e=>{const o=16*Math.random()|0;return("x"==e?o:3&o|8).toString(16)}))},jsonMessageReplacer:T,jsonMessageReviver:v}=o;let M;if(w){if(!("function"==typeof(S=w)&&"constructor"in S&&"CLOSED"in S&&"CLOSING"in S&&"CONNECTING"in S&&"OPEN"in S))throw new Error("Invalid WebSocket implementation provided");M=w}else"undefined"!=typeof WebSocket?M=WebSocket:"undefined"!=typeof global?M=global.WebSocket||global.MozWebSocket:"undefined"!=typeof window&&(M=window.WebSocket||window.MozWebSocket);var S;if(!M)throw new Error("WebSocket implementation missing; on Node you can `import WebSocket from 'ws';` and pass `webSocketImpl: WebSocket` to `createClient`");const h=M,E=(()=>{const e=(()=>{const e={};return{on:(o,n)=>(e[o]=n,()=>{delete e[o]}),emit(o){var n;"id"in o&&(null===(n=e[o.id])||void 0===n||n.call(e,o))}}})(),o={connecting:(null==b?void 0:b.connecting)?[b.connecting]:[],opened:(null==b?void 0:b.opened)?[b.opened]:[],connected:(null==b?void 0:b.connected)?[b.connected]:[],ping:(null==b?void 0:b.ping)?[b.ping]:[],pong:(null==b?void 0:b.pong)?[b.pong]:[],message:(null==b?void 0:b.message)?[e.emit,b.message]:[e.emit],closed:(null==b?void 0:b.closed)?[b.closed]:[],error:(null==b?void 0:b.error)?[b.error]:[]};return{onMessage:e.on,on(e,n){const t=o[e];return t.push(n),()=>{t.splice(t.indexOf(n),1)}},emit(e,...n){for(const t of[...o[e]])t(...n)}}})();function N(e){const o=[E.on("error",(n=>{o.forEach((e=>e())),e(n)})),E.on("closed",(n=>{o.forEach((e=>e())),e(n)}))]}let I,P=0,k=!1,A=0,O=!1;async function R(){const[o,r]=await(null!=I?I:I=new Promise(((o,r)=>(async()=>{if(k){if(await m(A),!P)return I=void 0,r({code:1e3,reason:"All Subscriptions Gone"});A++}E.emit("connecting");const i=new h("function"==typeof n?await n():n,s);let c,y;function f(){isFinite(l)&&l>0&&(clearTimeout(y),y=setTimeout((()=>{i.readyState===h.OPEN&&(i.send(u({type:e.MessageType.Ping})),E.emit("ping",!1,void 0))}),l))}N((e=>{I=void 0,clearTimeout(c),clearTimeout(y),r(e)})),i.onerror=e=>E.emit("error",e),i.onclose=e=>E.emit("closed",e),i.onopen=async()=>{try{E.emit("opened",i);const o="function"==typeof t?await t():t;if(i.readyState!==h.OPEN)return;i.send(u(o?{type:e.MessageType.ConnectionInit,payload:o}:{type:e.MessageType.ConnectionInit},T)),isFinite(g)&&g>0&&(c=setTimeout((()=>{i.close(e.CloseCode.ConnectionAcknowledgementTimeout,"Connection acknowledgement timeout")}),g)),f()}catch(o){E.emit("error",o),i.close(e.CloseCode.InternalClientError,a(o instanceof Error?o.message:new Error(o).message,"Internal client error"))}};let C=!1;i.onmessage=({data:n})=>{try{const t=p(n,v);if(E.emit("message",t),"ping"===t.type||"pong"===t.type)return E.emit(t.type,!0,t.payload),void("pong"===t.type?f():d||(i.send(u(t.payload?{type:e.MessageType.Pong,payload:t.payload}:{type:e.MessageType.Pong})),E.emit("pong",!1,t.payload)));if(C)return;if(t.type!==e.MessageType.ConnectionAck)throw new Error(`First message cannot be of type ${t.type}`);clearTimeout(c),C=!0,E.emit("connected",i,t.payload),k=!1,A=0,o([i,new Promise(((e,o)=>N(o)))])}catch(o){i.onmessage=null,E.emit("error",o),i.close(e.CloseCode.BadResponse,a(o instanceof Error?o.message:new Error(o).message,"Bad response"))}}})())));o.readyState===h.CLOSING&&await r;let i=()=>{};const y=new Promise((e=>i=e));return[o,i,Promise.race([y.then((()=>{if(!P){const e=()=>o.close(1e3,"Normal Closure");isFinite(c)&&c>0?setTimeout((()=>{P||o.readyState!==h.OPEN||e()}),c):e()}})),r])]}function W(o){if(y(o)&&(n=o.code,![1e3,1001,1006,1005,1012,1013,1013].includes(n)&&n>=1e3&&n<=1999||[e.CloseCode.InternalServerError,e.CloseCode.InternalClientError,e.CloseCode.BadRequest,e.CloseCode.BadResponse,e.CloseCode.Unauthorized,e.CloseCode.SubprotocolNotAcceptable,e.CloseCode.SubscriberAlreadyExists,e.CloseCode.TooManyInitialisationRequests].includes(o.code)))throw o;var n;if(O)return!1;if(y(o)&&1e3===o.code)return P>0;if(!f||A>=f)throw o;if(C(o))throw o;return k=!0}return r||(async()=>{for(P++;;)try{const[,,e]=await R();await e}catch(e){try{if(!W(e))return}catch(e){return null==i?void 0:i(e)}}})(),{on:E.on,subscribe(o,n){const t=x();let r=!1,i=!1,a=()=>{P--,r=!0};return(async()=>{for(P++;;)try{const[s,c,l]=await R();if(r)return c();const d=E.onMessage(t,(o=>{switch(o.type){case e.MessageType.Next:return void n.next(o.payload);case e.MessageType.Error:return i=!0,r=!0,n.error(o.payload),void a();case e.MessageType.Complete:return r=!0,void a()}}));return s.send(u({id:t,type:e.MessageType.Subscribe,payload:o},T)),a=()=>{r||s.readyState!==h.OPEN||s.send(u({id:t,type:e.MessageType.Complete},T)),P--,r=!0,c()},void await l.finally(d)}catch(e){if(!W(e))return}})().then((()=>{i||n.complete()})).catch((e=>{n.error(e)})),()=>{r||a()}},async dispose(){if(O=!0,I){const[e]=await I;e.close(1e3,"Normal Closure")}}}},e.isMessage=d,e.parseMessage=p,e.stringifyMessage=u,Object.defineProperty(e,"__esModule",{value:!0})}));
!function(e,o){"object"==typeof exports&&"undefined"!=typeof module?o(exports):"function"==typeof define&&define.amd?define(["exports"],o):o((e="undefined"!=typeof globalThis?globalThis:e||self).graphqlWs={})}(this,(function(e){"use strict";const o=Object.prototype.hasOwnProperty;function n(e){return"object"==typeof e&&null!==e}function t(e,n){return o.call(e,n)}function r(e,t){return o.call(e,t)&&n(e[t])}function i(e,n){return o.call(e,n)&&"string"==typeof e[n]}function a(e,o){return e.length<124?e:o}const s="graphql-transport-ws";var c,l;function d(o){if(n(o)){if(!i(o,"type"))return!1;switch(o.type){case e.MessageType.ConnectionInit:case e.MessageType.ConnectionAck:case e.MessageType.Ping:case e.MessageType.Pong:return!t(o,"payload")||void 0===o.payload||n(o.payload);case e.MessageType.Subscribe:return i(o,"id")&&r(o,"payload")&&(!t(o.payload,"operationName")||void 0===o.payload.operationName||null===o.payload.operationName||"string"==typeof o.payload.operationName)&&i(o.payload,"query")&&(!t(o.payload,"variables")||void 0===o.payload.variables||null===o.payload.variables||r(o.payload,"variables"))&&(!t(o.payload,"extensions")||void 0===o.payload.extensions||null===o.payload.extensions||r(o.payload,"extensions"));case e.MessageType.Next:return i(o,"id")&&r(o,"payload");case e.MessageType.Error:return i(o,"id")&&(a=o.payload,Array.isArray(a)&&a.length>0&&a.every((e=>"message"in e)));case e.MessageType.Complete:return i(o,"id");default:return!1}}var a;return!1}function p(e,o){if(d(e))return e;if("string"!=typeof e)throw new Error("Message not parsable");const n=JSON.parse(e,o);if(!d(n))throw new Error("Invalid message");return n}function u(e,o){if(!d(e))throw new Error("Cannot stringify invalid message");return JSON.stringify(e,o)}function y(e){return n(e)&&"code"in e&&"reason"in e}e.CloseCode=void 0,(c=e.CloseCode||(e.CloseCode={}))[c.InternalServerError=4500]="InternalServerError",c[c.InternalClientError=4005]="InternalClientError",c[c.BadRequest=4400]="BadRequest",c[c.BadResponse=4004]="BadResponse",c[c.Unauthorized=4401]="Unauthorized",c[c.Forbidden=4403]="Forbidden",c[c.SubprotocolNotAcceptable=4406]="SubprotocolNotAcceptable",c[c.ConnectionInitialisationTimeout=4408]="ConnectionInitialisationTimeout",c[c.ConnectionAcknowledgementTimeout=4504]="ConnectionAcknowledgementTimeout",c[c.SubscriberAlreadyExists=4409]="SubscriberAlreadyExists",c[c.TooManyInitialisationRequests=4429]="TooManyInitialisationRequests",e.MessageType=void 0,(l=e.MessageType||(e.MessageType={})).ConnectionInit="connection_init",l.ConnectionAck="connection_ack",l.Ping="ping",l.Pong="pong",l.Subscribe="subscribe",l.Next="next",l.Error="error",l.Complete="complete",e.DEPRECATED_GRAPHQL_WS_PROTOCOL="graphql-ws",e.GRAPHQL_TRANSPORT_WS_PROTOCOL=s,e.createClient=function(o){const{url:n,connectionParams:t,lazy:r=!0,onNonLazyError:i=console.error,lazyCloseTimeout:c=0,keepAlive:l=0,disablePong:d,connectionAckWaitTimeout:g=0,retryAttempts:f=5,retryWait:m=async function(e){let o=1e3;for(let n=0;n<e;n++)o*=2;await new Promise((e=>setTimeout(e,o+Math.floor(2700*Math.random()+300))))},isFatalConnectionProblem:C=(e=>!y(e)),on:b,webSocketImpl:w,generateID:x=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(e=>{const o=16*Math.random()|0;return("x"==e?o:3&o|8).toString(16)}))},jsonMessageReplacer:T,jsonMessageReviver:v}=o;let M;if(w){if(!("function"==typeof(S=w)&&"constructor"in S&&"CLOSED"in S&&"CLOSING"in S&&"CONNECTING"in S&&"OPEN"in S))throw new Error("Invalid WebSocket implementation provided");M=w}else"undefined"!=typeof WebSocket?M=WebSocket:"undefined"!=typeof global?M=global.WebSocket||global.MozWebSocket:"undefined"!=typeof window&&(M=window.WebSocket||window.MozWebSocket);var S;if(!M)throw new Error("WebSocket implementation missing; on Node you can `import WebSocket from 'ws';` and pass `webSocketImpl: WebSocket` to `createClient`");const h=M,E=(()=>{const e=(()=>{const e={};return{on:(o,n)=>(e[o]=n,()=>{delete e[o]}),emit(o){var n;"id"in o&&(null===(n=e[o.id])||void 0===n||n.call(e,o))}}})(),o={connecting:(null==b?void 0:b.connecting)?[b.connecting]:[],opened:(null==b?void 0:b.opened)?[b.opened]:[],connected:(null==b?void 0:b.connected)?[b.connected]:[],ping:(null==b?void 0:b.ping)?[b.ping]:[],pong:(null==b?void 0:b.pong)?[b.pong]:[],message:(null==b?void 0:b.message)?[e.emit,b.message]:[e.emit],closed:(null==b?void 0:b.closed)?[b.closed]:[],error:(null==b?void 0:b.error)?[b.error]:[]};return{onMessage:e.on,on(e,n){const t=o[e];return t.push(n),()=>{t.splice(t.indexOf(n),1)}},emit(e,...n){for(const t of[...o[e]])t(...n)}}})();function P(e){const o=[E.on("error",(n=>{o.forEach((e=>e())),e(n)})),E.on("closed",(n=>{o.forEach((e=>e())),e(n)}))]}let N,I=0,k=!1,A=0,O=!1;async function R(){const[o,r]=await(null!=N?N:N=new Promise(((o,r)=>(async()=>{if(k){if(await m(A),!I)return N=void 0,r({code:1e3,reason:"All Subscriptions Gone"});A++}E.emit("connecting");const i=new h("function"==typeof n?await n():n,s);let c,y;function f(){isFinite(l)&&l>0&&(clearTimeout(y),y=setTimeout((()=>{i.readyState===h.OPEN&&(i.send(u({type:e.MessageType.Ping})),E.emit("ping",!1,void 0))}),l))}P((e=>{N=void 0,clearTimeout(c),clearTimeout(y),r(e)})),i.onerror=e=>E.emit("error",e),i.onclose=e=>E.emit("closed",e),i.onopen=async()=>{try{E.emit("opened",i);const o="function"==typeof t?await t():t;if(i.readyState!==h.OPEN)return;i.send(u(o?{type:e.MessageType.ConnectionInit,payload:o}:{type:e.MessageType.ConnectionInit},T)),isFinite(g)&&g>0&&(c=setTimeout((()=>{i.close(e.CloseCode.ConnectionAcknowledgementTimeout,"Connection acknowledgement timeout")}),g)),f()}catch(o){E.emit("error",o),i.close(e.CloseCode.InternalClientError,a(o instanceof Error?o.message:new Error(o).message,"Internal client error"))}};let C=!1;i.onmessage=({data:n})=>{try{const t=p(n,v);if(E.emit("message",t),"ping"===t.type||"pong"===t.type)return E.emit(t.type,!0,t.payload),void("pong"===t.type?f():d||(i.send(u(t.payload?{type:e.MessageType.Pong,payload:t.payload}:{type:e.MessageType.Pong})),E.emit("pong",!1,t.payload)));if(C)return;if(t.type!==e.MessageType.ConnectionAck)throw new Error(`First message cannot be of type ${t.type}`);clearTimeout(c),C=!0,E.emit("connected",i,t.payload),k=!1,A=0,o([i,new Promise(((e,o)=>P(o)))])}catch(o){i.onmessage=null,E.emit("error",o),i.close(e.CloseCode.BadResponse,a(o instanceof Error?o.message:new Error(o).message,"Bad response"))}}})())));o.readyState===h.CLOSING&&await r;let i=()=>{};const y=new Promise((e=>i=e));return[o,i,Promise.race([y.then((()=>{if(!I){const e=()=>o.close(1e3,"Normal Closure");isFinite(c)&&c>0?setTimeout((()=>{I||o.readyState!==h.OPEN||e()}),c):e()}})),r])]}function W(o){if(y(o)&&(n=o.code,![1e3,1001,1006,1005,1012,1013,1013].includes(n)&&n>=1e3&&n<=1999||[e.CloseCode.InternalServerError,e.CloseCode.InternalClientError,e.CloseCode.BadRequest,e.CloseCode.BadResponse,e.CloseCode.Unauthorized,e.CloseCode.SubprotocolNotAcceptable,e.CloseCode.SubscriberAlreadyExists,e.CloseCode.TooManyInitialisationRequests].includes(o.code)))throw o;var n;if(O)return!1;if(y(o)&&1e3===o.code)return I>0;if(!f||A>=f)throw o;if(C(o))throw o;return k=!0}return r||(async()=>{for(I++;;)try{const[,,e]=await R();await e}catch(e){try{if(!W(e))return}catch(e){return null==i?void 0:i(e)}}})(),{on:E.on,subscribe(o,n){const t=x();let r=!1,i=!1,a=()=>{I--,r=!0};return(async()=>{for(I++;;)try{const[s,c,l]=await R();if(r)return c();const d=E.onMessage(t,(o=>{switch(o.type){case e.MessageType.Next:return void n.next(o.payload);case e.MessageType.Error:return i=!0,r=!0,n.error(o.payload),void a();case e.MessageType.Complete:return r=!0,void a()}}));return s.send(u({id:t,type:e.MessageType.Subscribe,payload:o},T)),a=()=>{r||s.readyState!==h.OPEN||s.send(u({id:t,type:e.MessageType.Complete},T)),I--,r=!0,c()},void await l.finally(d)}catch(e){if(!W(e))return}})().then((()=>{i||n.complete()})).catch((e=>{n.error(e)})),()=>{r||a()}},async dispose(){if(O=!0,N){const[e]=await N;e.close(1e3,"Normal Closure")}}}},e.isMessage=d,e.parseMessage=p,e.stringifyMessage=u,Object.defineProperty(e,"__esModule",{value:!0})}));

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc