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

@based/server

Package Overview
Dependencies
Maintainers
7
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 8.0.1 to 8.1.0

dist/incoming/http/fakeWs/function.d.ts

42

dist/incoming/http/index.js

@@ -13,8 +13,12 @@ import { isBasedRoute } from '@based/functions';

import { handleRequest } from './handleRequest.js';
import { handleFakeWs } from './fakeWs/index.js';
let clientId = 0;
export const httpHandler = (server, req, res) => {
let ctx;
res.onAborted(() => {
ctx.session.res = null;
ctx.session.req = null;
ctx.session = null;
if (ctx) {
ctx.session.res = null;
ctx.session.req = null;
ctx.session = null;
}
});

@@ -28,2 +32,32 @@ const ip = server.getIp(res, req);

const path = url.split('/');
if (server.restFallbackPath && path[1] === server.restFallbackPath) {
if (method !== 'post') {
res.end();
return;
}
let authorization = path[2];
if (!authorization || authorization.length > 5e3) {
res.end();
return;
}
ctx = {
session: {
url,
res,
req,
method,
origin: req.getHeader('origin'),
ua: req.getHeader('user-agent'),
ip,
id: ++clientId,
authState: parseAuthState(authorization),
// @ts-ignore
headers: {
'content-length': Number(req.getHeader('content-length')),
},
},
};
handleFakeWs(server, ctx);
return;
}
const route = server.functions.route(path[1], url);

@@ -80,3 +114,3 @@ if (route === null || route.internalOnly === true) {

}
const ctx = {
ctx = {
session: {

@@ -83,0 +117,0 @@ url,

@@ -125,2 +125,3 @@ /// <reference types="node" resolution-mode="require"/>

channelCleanupCycle: number;
restFallbackPath: string;
activeChannels: {

@@ -127,0 +128,0 @@ [name: string]: Map<number, ActiveChannel>;

@@ -92,2 +92,3 @@ import { isClientContext, } from '@based/functions';

channelCleanupCycle = 30e3;
restFallbackPath;
activeChannels = {};

@@ -111,2 +112,19 @@ activeChannelsById = new Map();

this.clients = opts.clients ?? {};
if (!opts.functions) {
opts.functions = {};
}
if (!opts.functions.configs) {
opts.functions.configs = {};
}
let restPath = '1' +
(~~(Math.random() * 99999999)).toString(16) +
(~~(Math.random() * 99999999)).toString(16);
this.restFallbackPath = restPath;
opts.functions.configs['based:rpstatus'] = {
type: 'function',
public: true,
fn: async () => {
return restPath;
},
};
this.functions = new BasedFunctions(this, opts.functions);

@@ -113,0 +131,0 @@ this.auth = new BasedAuth(this, opts.auth);

2

package.json
{
"name": "@based/server",
"version": "8.0.1",
"version": "8.1.0",
"license": "MIT",

@@ -5,0 +5,0 @@ "main": "./dist/index.js",

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