New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@nodefony/http-bundle

Package Overview
Dependencies
Maintainers
1
Versions
111
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nodefony/http-bundle - npm Package Compare versions

Comparing version 4.3.1 to 4.3.2

4

package.json
{
"name": "@nodefony/http-bundle",
"version": "4.3.1",
"version": "4.3.2",
"description": "Nodefony Framework Bundle HTTP ",

@@ -18,3 +18,3 @@ "contributors": [],

"memcached": "^2.2.2",
"mime": "^2.4.0",
"mime": "^2.4.2",
"mkdirp": "^0.5.1",

@@ -21,0 +21,0 @@ "ms": "^2.1.1",

@@ -77,32 +77,32 @@ /*

switch (nodefony.typeOf(this.kernel.domainAlias)) {
case "string":
alias = this.kernel.domainAlias.split(" ");
Array.prototype.unshift.call(alias, "^" + this.kernel.domain + "$");
for (let i = 0; i < alias.length; i++) {
if (i === 0) {
str = alias[i];
} else {
str += "|" + alias[i];
}
case "string":
alias = this.kernel.domainAlias.split(" ");
Array.prototype.unshift.call(alias, "^" + this.kernel.domain + "$");
for (let i = 0; i < alias.length; i++) {
if (i === 0) {
str = alias[i];
} else {
str += "|" + alias[i];
}
break;
case "object":
let first = true;
for (let myAlias in this.kernel.domainAlias) {
if (first) {
first = false;
str = this.kernel.domainAlias[myAlias];
} else {
str += "|" + this.kernel.domainAlias[myAlias];
}
}
break;
case "object":
let first = true;
for (let myAlias in this.kernel.domainAlias) {
if (first) {
first = false;
str = this.kernel.domainAlias[myAlias];
} else {
str += "|" + this.kernel.domainAlias[myAlias];
}
break;
case "array":
str = "^" + this.kernel.domain + "$";
for (let i = 0; i < this.kernel.domainAlias.length; i++) {
str += "|" + this.kernel.domainAlias[i];
}
break;
default:
throw new Error("Config file bad format for domain alias must be a string ");
}
break;
case "array":
str = "^" + this.kernel.domain + "$";
for (let i = 0; i < this.kernel.domainAlias.length; i++) {
str += "|" + this.kernel.domainAlias[i];
}
break;
default:
throw new Error("Config file bad format for domain alias must be a string ");
}

@@ -204,3 +204,4 @@ if (str) {

debug: this.kernel.debug,
local: context.translation.defaultLocale.substr(0, 2)
local: context.translation.defaultLocale.substr(0, 2),
core: this.kernel.isCore
},

@@ -253,26 +254,26 @@ getFlashBag: context.getFlashBag.bind(context),

switch (typeof this.cdn) {
case "object":
if (!this.cdn) {
return "";
}
if (this.cdn.global) {
return this.cdn.global;
}
if (!type) {
let txt = "CDN ERROR getCDN bad argument type ";
this.logger(txt, "ERROR");
throw new Error(txt);
}
if (type in this.cdn) {
if (this.cdn[type][wish]) {
return this.cdn[type][wish];
}
}
case "object":
if (!this.cdn) {
return "";
case "string":
return this.cdn || "";
default:
let txt = "CDN CONFIG ERROR ";
}
if (this.cdn.global) {
return this.cdn.global;
}
if (!type) {
let txt = "CDN ERROR getCDN bad argument type ";
this.logger(txt, "ERROR");
throw new Error(txt);
}
if (type in this.cdn) {
if (this.cdn[type][wish]) {
return this.cdn[type][wish];
}
}
return "";
case "string":
return this.cdn || "";
default:
let txt = "CDN CONFIG ERROR ";
this.logger(txt, "ERROR");
throw new Error(txt);
}

@@ -289,21 +290,21 @@ }

switch (next) {
case 200:
return next;
default:
this.logger("\x1b[31m DOMAIN Unauthorized \x1b[0mREQUEST DOMAIN : " + context.domain, "ERROR");
let error = new Error("Domain : " + context.domain + " Unauthorized ");
error.code = next;
throw error;
/*switch ( context.type ){
case "HTTP":
case "HTTPS":
this.logger("\x1b[31m DOMAIN Unauthorized \x1b[0mREQUEST DOMAIN : " + context.domain ,"ERROR");
let error = new Error("Domain : "+context.domain+" Unauthorized ");
error.code = next ;
throw error ;
case "WEBSOCKET":
case "WEBSOCKET SECURE":
context.close(3001, "DOMAIN Unauthorized "+ context.domain );
break;
}*/
case 200:
return next;
default:
this.logger("\x1b[31m DOMAIN Unauthorized \x1b[0mREQUEST DOMAIN : " + context.domain, "ERROR");
let error = new Error("Domain : " + context.domain + " Unauthorized ");
error.code = next;
throw error;
/*switch ( context.type ){
case "HTTP":
case "HTTPS":
this.logger("\x1b[31m DOMAIN Unauthorized \x1b[0mREQUEST DOMAIN : " + context.domain ,"ERROR");
let error = new Error("Domain : "+context.domain+" Unauthorized ");
error.code = next ;
throw error ;
case "WEBSOCKET":
case "WEBSOCKET SECURE":
context.close(3001, "DOMAIN Unauthorized "+ context.domain );
break;
}*/
}

@@ -319,12 +320,12 @@ return next;

switch (true) {
case (error instanceof nodefony.securityError):
case (error instanceof nodefony.httpError):
httpError = error;
break;
default:
if (context.response && context.response.statusCode === 200) {
httpError = new nodefony.httpError(error, 500, container);
} else {
httpError = new nodefony.httpError(error, null, container);
}
case (error instanceof nodefony.securityError):
case (error instanceof nodefony.httpError):
httpError = error;
break;
default:
if (context.response && context.response.statusCode === 200) {
httpError = new nodefony.httpError(error, 500, container);
} else {
httpError = new nodefony.httpError(error, null, container);
}
}

@@ -403,9 +404,9 @@ if (!httpError.context) {

switch (type) {
case "HTTP":
case "HTTPS":
case "HTTP2":
return this.handleHttp(container, request, response, type);
case "WEBSOCKET":
case "WEBSOCKET SECURE":
return this.handleWebsocket(container, request, type);
case "HTTP":
case "HTTPS":
case "HTTP2":
return this.handleHttp(container, request, response, type);
case "WEBSOCKET":
case "WEBSOCKET SECURE":
return this.handleWebsocket(container, request, type);
}

@@ -412,0 +413,0 @@ }

const QS = require('qs');
const formidable = require("formidable");
module.exports = nodefony.register("Request", function() {
module.exports = nodefony.register("Request", function () {

@@ -72,3 +72,3 @@ // ARRAY PHP LIKE

const acceptParser = function(acc) {
const acceptParser = function (acc) {
if (!acc) {

@@ -210,62 +210,62 @@ return [{

switch (this.contentType) {
case "application/xml":
case "text/xml":
this.parser = new parserXml(this);
break;
case "application/x-www-form-urlencoded":
this.parser = new parserQs(this);
break;
default:
let opt = nodefony.extend(this.context.requestSettings, {
encoding: this.charset
});
this.parser = new formidable.IncomingForm(opt);
this.parser.parse(this.request, (err, fields, files) => {
if (err) {
this.request.on("end", () => {
this.context.fire("onError", this.context.container, err);
});
return;
}
try {
this.queryPost = fields;
//this.context.setParameters("query.post", this.queryPost);
this.query = nodefony.extend({}, this.query, this.queryPost);
//this.context.setParameters("query.request", this.query);
if (Object.keys(files).length) {
for (let file in files) {
try {
if (reg.exec(file)) {
if (nodefony.isArray(files[file])) {
for (let multifiles in files[file]) {
this.createFileUpload(multifiles, files[file][multifiles], opt.maxFileSize);
}
} else {
if (files[file].name) {
this.createFileUpload(file, files[file], opt.maxFileSize);
}
case "application/xml":
case "text/xml":
this.parser = new parserXml(this);
break;
case "application/x-www-form-urlencoded":
this.parser = new parserQs(this);
break;
default:
let opt = nodefony.extend(this.context.requestSettings, {
encoding: this.charset
});
this.parser = new formidable.IncomingForm(opt);
this.parser.parse(this.request, (err, fields, files) => {
if (err) {
this.request.on("end", () => {
this.context.fire("onError", this.context.container, err);
});
return;
}
try {
this.queryPost = fields;
//this.context.setParameters("query.post", this.queryPost);
this.query = nodefony.extend({}, this.query, this.queryPost);
//this.context.setParameters("query.request", this.query);
if (Object.keys(files).length) {
for (let file in files) {
try {
if (reg.exec(file)) {
if (nodefony.isArray(files[file])) {
for (let multifiles in files[file]) {
this.createFileUpload(multifiles, files[file][multifiles], opt.maxFileSize);
}
} else {
if (nodefony.isArray(files[file])) {
for (let multifiles in files[file]) {
this.createFileUpload(multifiles, files[file][multifiles], opt.maxFileSize);
}
} else {
if (files[file].name) {
this.createFileUpload(file, files[file], opt.maxFileSize);
}
}
} catch (err) {
this.context.fire("onError", this.context.container, err);
return err;
} else {
if (nodefony.isArray(files[file])) {
for (let multifiles in files[file]) {
this.createFileUpload(multifiles, files[file][multifiles], opt.maxFileSize);
}
} else {
this.createFileUpload(file, files[file], opt.maxFileSize);
}
}
} catch (err) {
this.context.fire("onError", this.context.container, err);
return err;
}
}
} catch (err) {
this.request.on("end", () => {
this.context.fire("onError", this.context.container, err);
});
}
this.context.requestEnded = true;
this.context.fire("onRequestEnd", this);
});
} catch (err) {
this.request.on("end", () => {
this.context.fire("onError", this.context.container, err);
});
}
this.context.requestEnded = true;
this.context.fire("onRequestEnd", this);
});
}

@@ -284,11 +284,11 @@ }

switch (parse.length) {
case 1:
subtype = parse.shift();
break;
case 2:
type = parse.shift();
subtype = parse.shift();
break;
default:
throw new Error("request accepts method bad type format");
case 1:
subtype = parse.shift();
break;
case 2:
type = parse.shift();
subtype = parse.shift();
break;
default:
throw new Error("request accepts method bad type format");
}

@@ -320,3 +320,6 @@ }

}
return this.getHost().split(":")[0];
if (host = this.getHost()) {
return host.split(":")[0];
}
return "";
}

@@ -323,0 +326,0 @@

@@ -258,3 +258,3 @@ const http = require("http");

this.ended = true;
return Promise.resolve(this.response.end(data, encoding));
return Promise.resolve(this.response.end(data, (encoding || this.encoding)));
}

@@ -261,0 +261,0 @@ return Promise.resolve(null);

@@ -94,3 +94,3 @@ //const http = require("http");

this.ended = true;
return Promise.resolve(this.stream.end(data, encoding));
return Promise.resolve(this.stream.end(data, (encoding || this.encoding)));
} else {

@@ -97,0 +97,0 @@ return super.end(data, encoding);

@@ -5,3 +5,3 @@ /*

*/
nodefony.register("Session", function() {
nodefony.register("Session", function () {

@@ -11,14 +11,14 @@ const algorithm = 'aes-256-ctr';

const checkSecureReferer = function() {
const checkSecureReferer = function () {
let host = null;
switch (this.context.type) {
case "HTTP":
case "HTTPS":
case "HTTP2":
host = this.context.request.request.headers.host;
break;
case "WEBSOCKET":
case "WEBSOCKET SECURE":
host = this.context.request.httpRequest.headers.host;
break;
case "HTTP":
case "HTTPS":
case "HTTP2":
host = this.context.request.request.headers.host;
break;
case "WEBSOCKET":
case "WEBSOCKET SECURE":
host = this.context.request.httpRequest.headers.host;
break;
}

@@ -37,3 +37,3 @@ let meta = this.getMetaBag("host");

const setMetasSession = function() {
const setMetasSession = function () {
let time = new Date();

@@ -78,6 +78,7 @@ this.setMetaBag("lifetime", this.settings.cookie.maxAge);

set(name, object) {
//console.log(name)
//console.log(object)
return super.set(name, object);
get(name) {
if (!name) {
return this.protoService.prototype;
}
return super.get(name);
}

@@ -121,10 +122,10 @@

switch (ret) {
case false:
return new Promise((resolve /*, reject*/ ) => {
return resolve(this);
});
case "restart":
return this.start(context, contextSession);
default:
return this.getSession(contextSession);
case false:
return new Promise((resolve /*, reject*/ ) => {
return resolve(this);
});
case "restart":
return this.start(context, contextSession);
default:
return this.getSession(contextSession);
}

@@ -140,19 +141,19 @@ } catch (e) {

switch (this.status) {
case "active":
this.manager.logger("SESSION ALLREADY STARTED ==> " + this.name + " : " + this.id, "WARNING");
return false;
case "disabled":
try {
this.storage = this.manager.initializeStorage();
if (this.storage) {
this.status = "none";
return "restart";
}
} catch (e) {
this.manager.logger("SESSION STORAGE HANDLER NOT FOUND ", "ERROR");
throw new Error("SESSION STORAGE HANDLER NOT FOUND ");
case "active":
this.manager.logger("SESSION ALLREADY STARTED ==> " + this.name + " : " + this.id, "WARNING");
return false;
case "disabled":
try {
this.storage = this.manager.initializeStorage();
if (this.storage) {
this.status = "none";
return "restart";
}
break;
default:
return true;
} catch (e) {
this.manager.logger("SESSION STORAGE HANDLER NOT FOUND ", "ERROR");
throw new Error("SESSION STORAGE HANDLER NOT FOUND ");
}
break;
default:
return true;
}

@@ -193,33 +194,33 @@ }

switch (this.strategy) {
case "migrate":
return this.storage.start(this.id, this.contextSession).then((result) => {
this.deSerialize(result);
if (!this.isValidSession(result, this.context)) {
this.manager.logger("INVALID SESSION ==> " + this.name + " : " + this.id, "WARNING");
this.destroy();
this.contextSession = contextSession;
return this.create(this.lifetime, null);
}
this.remove();
this.manager.logger(`STRATEGY MIGRATE SESSION ==> ${this.name} : ${this.id}`, "DEBUG");
this.migrated = true;
case "migrate":
return this.storage.start(this.id, this.contextSession).then((result) => {
this.deSerialize(result);
if (!this.isValidSession(result, this.context)) {
this.manager.logger("INVALID SESSION ==> " + this.name + " : " + this.id, "WARNING");
this.destroy();
this.contextSession = contextSession;
return this.create(this.lifetime, null);
}).catch((error) => {
throw error;
});
case "invalidate":
this.manager.logger("STRATEGY INVALIDATE SESSION ==> " + this.name + " : " + this.id, "DEBUG");
this.destroy();
}
this.remove();
this.manager.logger(`STRATEGY MIGRATE SESSION ==> ${this.name} : ${this.id}`, "DEBUG");
this.migrated = true;
this.contextSession = contextSession;
return new Promise((resolve, reject) => {
try {
return resolve(this.create(this.lifetime, null));
} catch (e) {
return reject(e);
}
});
case "none":
this.strategyNone = true;
break;
return this.create(this.lifetime, null);
}).catch((error) => {
throw error;
});
case "invalidate":
this.manager.logger("STRATEGY INVALIDATE SESSION ==> " + this.name + " : " + this.id, "DEBUG");
this.destroy();
this.contextSession = contextSession;
return new Promise((resolve, reject) => {
try {
return resolve(this.create(this.lifetime, null));
} catch (e) {
return reject(e);
}
});
case "none":
this.strategyNone = true;
break;
}

@@ -289,2 +290,5 @@ if (!this.strategyNone) {

}
getAttributes() {
return this.attributes();
}

@@ -294,3 +298,2 @@ metaBag() {

}
getMetas() {

@@ -420,5 +423,5 @@ return this.metaBag();

delete this.protoService;
this.protoService = function() {};
this.protoService = function () {};
delete this.protoParameters;
this.protoParameters = function() {};
this.protoParameters = function () {};
delete this.services;

@@ -457,10 +460,10 @@ this.services = new this.protoService();

switch (this.settings.hash_function) {
case "md5":
hash = crypto.createHash('md5');
break;
case "sha1":
hash = crypto.createHash('sha1');
break;
default:
hash = crypto.createHash('md5');
case "md5":
hash = crypto.createHash('md5');
break;
case "sha1":
hash = crypto.createHash('sha1');
break;
default:
hash = crypto.createHash('md5');
}

@@ -467,0 +470,0 @@ let res = hash.update(concat).digest("hex");

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