🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

fluvial

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fluvial - npm Package Compare versions

Comparing version

to
0.4.7

3

dist/middleware/form-data.js

@@ -20,2 +20,3 @@ import { randomUUID } from 'node:crypto';

if (req.headers['content-type']?.includes('multipart/form-data')) {
let raw = Buffer.from([]);
let data = '';

@@ -28,2 +29,3 @@ const files = {};

for await (const chunk of req.rawRequest) {
raw = Buffer.concat([raw, chunk]);
if (currentFileId && chunk.includes(formBoundaryBuffer)) {

@@ -53,2 +55,3 @@ currentFileId = null;

const deserializedPayload = parse(data, getBoundary(req.headers['content-type']), files);
Object.defineProperty(req, 'rawPayload', { get() { return raw; } });
Object.defineProperty(req, 'payload', { get() { return deserializedPayload; } });

@@ -55,0 +58,0 @@ }

@@ -5,4 +5,6 @@ export function deserializeJsonPayload(options) {

if (req.headers['content-type']?.includes('json')) {
let raw = Buffer.from([]);
let data = '';
for await (const chunk of req.rawRequest) {
raw = Buffer.concat([raw, chunk]);
data += chunk.toString('utf-8');

@@ -12,2 +14,3 @@ }

const deserializedPayload = parse(data);
Object.defineProperty(req, 'rawPayload', { get() { return raw; } });
Object.defineProperty(req, 'payload', { get() { return deserializedPayload; } });

@@ -14,0 +17,0 @@ }

export function preparePlainTextPayload({ encoding = 'utf-8' } = {}) {
return async (req, res) => {
let raw = Buffer.from([]);
let data = '';
try {
for await (const chunk of req.rawRequest) {
raw = Buffer.concat([raw, chunk]);
data += chunk.toString(encoding);

@@ -13,2 +15,3 @@ }

}
Object.defineProperty(req, 'rawPayload', { get() { return raw; } });
Object.defineProperty(req, 'payload', { get() { return data; } });

@@ -15,0 +18,0 @@ return 'next';

export function deserializeUrlencodedPayload( /* options?: DeserializeUrlencodedOptions */) {
return async (req, res) => {
if (req.headers['content-type'].includes('x-www-form-urlencoded')) {
let raw = Buffer.from([]);
let data = '';
for await (const chunk of req.rawRequest) {
raw = Buffer.concat([raw, chunk]);
data += chunk.toString('utf-8');

@@ -10,2 +12,3 @@ }

const deserializedPayload = parse(data);
Object.defineProperty(req, 'rawPayload', { get() { return raw; } });
Object.defineProperty(req, 'payload', { get() { return deserializedPayload; } });

@@ -12,0 +15,0 @@ }

4

dist/request.d.ts

@@ -5,2 +5,3 @@ /// <reference types="node" />

/// <reference types="node" />
/// <reference types="node" />
import { IncomingMessage } from 'node:http';

@@ -20,3 +21,4 @@ import { Http2ServerRequest, IncomingHttpHeaders } from 'node:http2';

readonly headers: Readonly<IncomingHttpHeaders>;
readonly payload: any;
readonly payload?: any;
readonly rawPayload?: Buffer;
readonly rawRequest: Http2ServerRequest | IncomingMessage;

@@ -23,0 +25,0 @@ readonly params: Readonly<ParamsDictionary>;

@@ -110,4 +110,11 @@ import { randomUUID } from 'node:crypto';

}
// all overloads of writable.end will work here...
this.rawResponse.end(data);
if (typeof data == 'function') {
this.rawResponse.on('close', data);
}
if (data && typeof data != 'function') {
this.rawResponse.end(data);
}
else {
this.rawResponse.end();
}
return this;

@@ -126,6 +133,9 @@ }

}
else if (data && typeof data == 'object') {
else if (data && typeof data == 'object' && !Buffer.isBuffer(data)) {
this.json(data);
return;
}
else if (Buffer.isBuffer(data) && !this.headers['content-type']) {
this.headers['content-type'] = 'application/octet-stream';
}
else if (data && !this.headers['content-type']) {

@@ -191,2 +201,11 @@ this.headers['content-type'] = 'text/plain';

async #send(data) {
const bytes = Buffer.isBuffer(data) ? data : typeof data == 'string' ? Buffer.from(data) : Buffer.from([]);
for (const type of this.rawResponse.eventNames()) {
this.rawResponse.on(type, (...args) => {
console.log(type, args);
});
}
if (bytes.byteLength) {
this.headers['content-length'] = String(bytes.byteLength);
}
if (this.httpVersion == '1.1') {

@@ -201,4 +220,5 @@ this.rawResponse.writeHead(this.#status, { ...this.headers });

}
if (data) {
this.write(Buffer.from(data));
if (bytes.byteLength) {
this.write(bytes, 'buffer');
this.write('\r\n\r\n');
}

@@ -205,0 +225,0 @@ this.end();

{
"name": "fluvial",
"version": "0.4.6",
"version": "0.4.7",
"description": "Fluvial: A light http/2 server framework, similar to Express",

@@ -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

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