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

hyperswitch

Package Overview
Dependencies
Maintainers
4
Versions
75
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hyperswitch - npm Package Compare versions

Comparing version 0.12.7 to 0.13.0

53

lib/router.js

@@ -6,2 +6,4 @@ 'use strict';

const fs = P.promisifyAll(require('fs'));
const stringify = require('fast-json-stable-stringify');
const crypto = require('crypto');
const handlerTemplate = require('./handlerTemplate');

@@ -156,2 +158,36 @@ const swaggerRouter = require('swagger-router');

_getCachedModule(modDef, globals) {
const modString = crypto.createHash('sha256')
.update(stringify(modDef, { cycles: true }))
.digest('hex');
const exportedGlobals = utils.exportGlobal(globals);
const globalHash = crypto.createHash('sha256')
.update(stringify(exportedGlobals, { cycles: true }))
.digest('hex');
let cachedModules = this._modules.get(modString);
if (!cachedModules) {
cachedModules = new Map();
this._modules.set(modString, cachedModules);
}
const cachedWithGlobals = cachedModules.get(globalHash);
return {
digest: modString,
module: cachedWithGlobals
};
}
_cacheModule(cacheInfo, mod) {
const cachedModules = this._modules.get(cacheInfo.digest);
const exportedGlobals = utils.exportGlobal(mod._parentGlobals);
const globalHash = crypto.createHash('sha256')
.update(stringify(exportedGlobals, { cycles: true }))
.digest('hex');
cachedModules.set(globalHash, mod);
}
_clearModuleCache() {
this._modules.forEach((value) => value.clear());
this._modules.clear();
}
/**

@@ -164,7 +200,8 @@ * Load and initialize a module

_loadModule(modDef, globals) {
const options = this._expandOptions(modDef, globals);
// First, check if we have a copy of this module in the cache, so that we
// can share it.
const cachedModule = this._modules.get(modDef);
if (cachedModule && cachedModule._parentGlobals === globals) {
return P.resolve(cachedModule);
const cached = this._getCachedModule(modDef, globals);
if (cached.module) {
return P.resolve(cached.module);
}

@@ -215,4 +252,2 @@

const options = this._expandOptions(modDef, globals);
const constructModule = (spec) => {

@@ -225,3 +260,3 @@ const mod = {

};
this._modules.set(modDef, mod);
this._cacheModule(cached, mod);
return mod;

@@ -255,3 +290,3 @@ };

mod._parentGlobals = globals;
this._modules.set(modDef, mod);
this._cacheModule(cached, mod);
return mod;

@@ -560,2 +595,5 @@ });

handleResources(hyper) {
if (this._options.conf && this._options.conf.skip_resources) {
return P.resolve();
}
return this.tree.visitAsync((value, path) => {

@@ -629,2 +667,3 @@ if (value && Array.isArray(value.resources) && value.resources.length > 0) {

.then(() => {
this._clearModuleCache();
return this;

@@ -631,0 +670,0 @@ });

@@ -95,3 +95,3 @@ 'use strict';

if (!sources.length || !sources || !target || !isObject(target)) {
if (!sources || !sources.length || !target || !isObject(target)) {
return target;

@@ -119,2 +119,25 @@ }

utils.exportGlobal = (global) => {
if (!global || ['string', 'number', 'boolean'].includes(typeof global)) {
return global;
}
if (Array.isArray(global)) {
return global.map((x) => utils.exportGlobal(x));
}
if (global.constructor === Object) {
// because the logger appears at various positions in the globals, we need
// to filter it out as it depends on its position how it gets stringified
// TODO: figure out how to get rid of the logger altogether, as it really
// shouldn't be part of the globals object
const keys = Object.keys(global).filter((item) => item !== 'logger' &&
!!global[item] && typeof global[item] !== 'function');
const ret = {};
keys.forEach((x) => {
ret[x] = utils.exportGlobal(global[x]);
});
return ret;
}
return global;
};
module.exports = utils;

4

package.json
{
"name": "hyperswitch",
"version": "0.12.7",
"version": "0.13.0",
"description": "REST API creation framework",

@@ -36,3 +36,3 @@ "main": "index.js",

"swagger-router": "^0.7.4",
"swagger-ui-dist": "^3.23.6",
"swagger-ui-dist": "^3.23.11",
"uuid": "^3.3.3"

@@ -39,0 +39,0 @@ },

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