Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@based/server

Package Overview
Dependencies
Maintainers
1
Versions
112
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@based/server - npm Package Compare versions

Comparing version 6.5.1 to 6.6.0

30

dist/channel/start.js

@@ -83,3 +83,31 @@ "use strict";

try {
channel.closeFunction = spec.subscriber(server.client, payload, id, (msg) => updateChannelListener(server, channel, msg), (err) => errorChannelListener(server, channel, err));
if (spec.throttle) {
let tempMsg;
let isThrottled;
let throtDebounced = false;
let timer;
const update = (msg) => {
if (isThrottled) {
tempMsg = msg;
throtDebounced = true;
}
else {
isThrottled = true;
timer = setTimeout(() => {
if (throtDebounced && !channel.isDestroyed) {
updateChannelListener(server, channel, tempMsg);
// deref
tempMsg = null;
}
throtDebounced = false;
isThrottled = false;
}, spec.throttle);
updateChannelListener(server, channel, msg);
}
};
channel.closeFunction = spec.subscriber(server.client, payload, id, update, (err) => errorChannelListener(server, channel, err));
}
else {
channel.closeFunction = spec.subscriber(server.client, payload, id, (msg) => updateChannelListener(server, channel, msg), (err) => errorChannelListener(server, channel, err));
}
}

@@ -86,0 +114,0 @@ catch (err) {

@@ -13,2 +13,5 @@ "use strict";

const channel = (0, get_1.getChannelAndStopRemove)(server, id);
if (server.channelEvents) {
server.channelEvents.subscribe(channel, ctx);
}
session.obs.add(id);

@@ -15,0 +18,0 @@ channel.clients.add(session.id);

@@ -31,2 +31,5 @@ "use strict";

if (channel.clients.delete(session.id)) {
if (server.channelEvents) {
server.channelEvents.unsubscribe(channel, ctx);
}
(0, destroy_1.destroyChannel)(server, id);

@@ -46,3 +49,5 @@ return true;

}
channel.clients.delete(session.id);
if (channel.clients.delete(session.id) && server.channelEvents) {
server.channelEvents.unsubscribe(channel, ctx);
}
(0, destroy_1.destroyChannel)(server, id);

@@ -49,0 +54,0 @@ };

6

dist/incoming/http/index.js

@@ -108,5 +108,5 @@ "use strict";

};
if (!(method === 'post' &&
route.type === 'stream' &&
ctx.session.headers['content-type'] === 'multipart/form-data')) {
if (!((method === 'post' && route.type === 'stream')
// ctx.session.headers['content-type'].includes('multipart/form-data')
)) {
const defHeaders = 'Authorization,Content-Type';

@@ -113,0 +113,0 @@ if (route.headers) {

@@ -105,2 +105,5 @@ "use strict";

const obs = (0, query_1.getObsAndStopRemove)(server, id);
if (server.queryEvents) {
server.queryEvents.get(obs, ctx);
}
if (obs.error) {

@@ -133,2 +136,5 @@ (0, query_1.sendObsGetError)(server, ctx, obs.id, obs.error);

const obs = (0, query_1.createObs)(server, name, id, payload, true);
if (server.queryEvents) {
server.queryEvents.get(obs, ctx);
}
(0, query_1.subscribeNext)(obs, (err) => {

@@ -135,0 +141,0 @@ if (err) {

@@ -57,19 +57,7 @@ "use strict";

if (ctx.session) {
if (route.headers) {
for (const header of route.headers) {
ctx.session.headers[header] = ctx.session.req.getHeader(header);
}
ctx.session.res.cork(() => {
ctx.session.res.writeHeader('Access-Control-Allow-Headers', 'Authorization,Content-Type' + ',' + route.headers.join(','));
ctx.session.res.writeHeader('Access-Control-Expose-Headers', '*');
ctx.session.res.writeHeader('Access-Control-Allow-Origin', '*');
});
}
else {
ctx.session.res.cork(() => {
ctx.session.res.writeHeader('Access-Control-Allow-Headers', 'Authorization,Content-Type');
ctx.session.res.writeHeader('Access-Control-Expose-Headers', '*');
ctx.session.res.writeHeader('Access-Control-Allow-Origin', '*');
});
}
ctx.session.res.cork(() => {
ctx.session.res.writeHeader('Access-Control-Allow-Headers', 'Authorization,Content-Type');
ctx.session.res.writeHeader('Access-Control-Expose-Headers', '*');
ctx.session.res.writeHeader('Access-Control-Allow-Origin', '*');
});
(0, sendHttpResponse_1.sendHttpResponse)(ctx, results);

@@ -76,0 +64,0 @@ }

@@ -16,2 +16,12 @@ "use strict";

const authorize_1 = require("../../../../authorize");
const ready = async (ctx, r) => {
if (ctx.session) {
ctx.session.res.cork(() => {
ctx.session.res.writeHeader('Access-Control-Allow-Headers', 'Authorization,Content-Type');
ctx.session.res.writeHeader('Access-Control-Expose-Headers', '*');
ctx.session.res.writeHeader('Access-Control-Allow-Origin', '*');
});
(0, sendHttpResponse_1.sendHttpResponse)(ctx, r);
}
};
const singleStream = (server, ctx, route, type, size) => {

@@ -58,7 +68,7 @@ const extension = ctx.session.req.getHeader('content-extension');

if (stream.readableEnded || stream.listenerCount('data') === 0) {
(0, sendHttpResponse_1.sendHttpResponse)(ctx, r);
ready(ctx, r);
}
else {
stream.on('end', () => {
(0, sendHttpResponse_1.sendHttpResponse)(ctx, r);
ready(ctx, r);
});

@@ -65,0 +75,0 @@ }

@@ -50,2 +50,3 @@ "use strict";

const session = ws.getUserData();
// @ts-ignore
(0, ws_1.message)(server, session.c, data, isBinary);

@@ -52,0 +53,0 @@ },

@@ -32,2 +32,5 @@ "use strict";

const obs = (0, query_1.getObsAndStopRemove)(server, id);
if (server.queryEvents) {
server.queryEvents.get(obs, ctx);
}
if (obs.error) {

@@ -64,2 +67,5 @@ (0, query_1.sendObsGetError)(server, ctx, id, obs.error);

const obs = (0, query_1.createObs)(server, route.name, id, payload, true);
if (server.queryEvents) {
server.queryEvents.get(obs, ctx);
}
if (!session.obs.has(id)) {

@@ -66,0 +72,0 @@ (0, query_1.subscribeNext)(obs, (err) => {

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

const payload = obs.payload;
const update = (data, checksum, err, cache, diff, fromChecksum, isDeflate) => {
const updateRaw = (data, checksum, err, cache, diff, fromChecksum, isDeflate) => {
if (err) {

@@ -28,2 +28,29 @@ (0, error_1.errorListener)(server, obs, err);

};
let isThrottled;
let throttledArgs;
let throtDebounced = false;
let timer;
const update = spec.throttle
? (...args) => {
if (isThrottled) {
throttledArgs = args;
throtDebounced = true;
}
else {
isThrottled = true;
timer = setTimeout(() => {
if (throtDebounced && !obs.isDestroyed) {
// @ts-ignore
updateRaw(...throttledArgs);
// deref
throttledArgs = null;
}
throtDebounced = false;
isThrottled = false;
}, spec.throttle);
// @ts-ignore
updateRaw(...args);
}
}
: updateRaw;
const startId = ++obs.startId;

@@ -30,0 +57,0 @@ if (spec.relay) {

@@ -21,2 +21,5 @@ "use strict";

}
if (server.queryEvents) {
server.queryEvents.subscribe(obs, ctx);
}
if (obs.cache && obs.checksum !== checksum) {

@@ -34,6 +37,7 @@ if (obs.diffCache && obs.previousChecksum === checksum) {

const obs = (0, get_1.getObsAndStopRemove)(server, id);
if (obs.functionObserveClients.add(update))
if (obs.functionObserveClients.add(update)) {
if (obs.cache) {
update(obs.rawData, obs.checksum, null, obs.cache, obs.diffCache, obs.previousChecksum, obs.isDeflate);
}
}
};

@@ -40,0 +44,0 @@ exports.subscribeFunction = subscribeFunction;

@@ -28,2 +28,5 @@ "use strict";

if (obs.clients.delete(session.id)) {
if (server.queryEvents) {
server.queryEvents.unsubscribe(obs, ctx);
}
(0, destroy_1.destroyObs)(server, id);

@@ -43,3 +46,5 @@ return true;

}
obs.clients.delete(session.id);
if (obs.clients.delete(session.id) && server.queryEvents) {
server.queryEvents.unsubscribe(obs, ctx);
}
(0, destroy_1.destroyObs)(server, id);

@@ -46,0 +51,0 @@ };

@@ -25,2 +25,11 @@ /// <reference types="node" />

type GetIp = (res: uws.HttpResponse, req: uws.HttpRequest) => string;
type QueryEvents = {
subscribe: (obs: ActiveObservable, ctx: Context<WebSocketSession>) => void;
unsubscribe: (obs: ActiveObservable, ctx: Context<WebSocketSession>) => void;
get: (obs: ActiveObservable, ctx: Context<WebSocketSession | HttpSession>) => void;
};
type ChannelEvents = {
subscribe: (obs: ActiveChannel, ctx: Context<WebSocketSession>) => void;
unsubscribe: (obs: ActiveChannel, ctx: Context<WebSocketSession>) => void;
};
export type ServerOptions = {

@@ -41,2 +50,4 @@ clients?: {

auth?: AuthConfig;
query?: QueryEvents;
channel?: ChannelEvents;
ws?: {

@@ -94,2 +105,4 @@ maxBackpressureSize?: number;

silent: boolean;
queryEvents: QueryEvents;
channelEvents: ChannelEvents;
rateLimit: RateLimit;

@@ -96,0 +109,0 @@ listenSocket: any;

@@ -92,2 +92,8 @@ "use strict";

this.listeners = {};
if (opts.query) {
this.queryEvents = opts.query;
}
if (opts.channel) {
this.channelEvents = opts.channel;
}
if (opts.silent) {

@@ -94,0 +100,0 @@ this.silent = opts.silent;

{
"name": "@based/server",
"version": "6.5.1",
"version": "6.6.0",
"license": "MIT",

@@ -31,3 +31,3 @@ "main": "./dist/index.js",

"mime-types": "^2.1.31",
"@based/functions": "^2.1.1"
"@based/functions": "^2.1.3"
},

@@ -34,0 +34,0 @@ "devDependencies": {

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

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

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

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc