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

volos-quota-common

Package Overview
Dependencies
Maintainers
3
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

volos-quota-common - npm Package Compare versions

Comparing version 0.11.8 to 0.11.9

22

lib/memory_buffer.js

@@ -53,2 +53,3 @@ /****************************************************************************

this.clockOffset = undefined;
this.remoteApplyFailed = false;

@@ -134,2 +135,3 @@ assert(options.timeInterval);

this.flushing = false;
this.remoteExpiryTimestamp = undefined;
};

@@ -182,3 +184,4 @@

isAllowed: (count <= allow),
expiryTime: this.expires - now
expiryTime: this.expires - now,
remoteApplyFailed: this.owner.remoteApplyFailed
};

@@ -207,3 +210,9 @@

self.flushing = false;
if (err) { return (cb) ? cb(err) : console.error(err); }
if (err) {
if (self.owner.options.failOpen === true ) {
self.owner.remoteApplyFailed = true;
}
return (cb) ? cb(err) : console.error(err);
}
self.owner.remoteApplyFailed = false;

@@ -222,2 +231,7 @@ // sync time with remote if never been synced

(!remoteExpires || remoteExpires === self.remoteExpires); // same remote time bucket?
if ( reply.expiryTimestamp ) { // filter out back dated remote expiry, these are invalid responses from remote
sameTimeBucket = sameTimeBucket && ( !self.remoteExpiryTimestamp || reply.expiryTimestamp >= self.remoteExpiryTimestamp );
}
if (!sameTimeBucket) {

@@ -230,2 +244,6 @@ debug('new time bucket');

self.remoteCount = reply.used;
if ( reply.expiryTimestamp ) {
self.remoteExpiryTimestamp = reply.expiryTimestamp;
}
self.count -= options.weight; // subtract applied value

@@ -232,0 +250,0 @@

@@ -51,3 +51,3 @@ /****************************************************************************

var opts = calcOptions(req, options);
applyQuota(self, opts, resp, next);
applyQuota(self, opts, resp, next, req);
};

@@ -70,3 +70,3 @@ };

debug('Quota check:', opts.identifier);
applyQuota(self, opts, resp, next);
applyQuota(self, opts, resp, next, req);
};

@@ -84,3 +84,3 @@ };

function applyQuota(self, options, resp, next) {
function applyQuota(self, options, resp, next, req) {
debug('Quota check:', options.identifier);

@@ -90,3 +90,20 @@ self.quota.apply(

function(err, reply) {
if (err) { return next(err); }
if (err) {
if ( self.quota.options.failOpen === true ) {
if ( req ) {
req['quota-failed-open'] = true; // pass the flag to next plugins
debug('bypassing quota checks and setting quota-failed-open for identifier: %s', options.key || options.identifier);
}
return next();
} else {
return next(err);
}
}
if ( reply.remoteApplyFailed === true ) {
if ( req ) {
req['quota-failed-open'] = true; // pass the flag to next plugins
debug('remote quota not available so processing locally, setting quota-failed-open for identifier: %s', options.key || options.identifier);
}
}
resp.setHeader('X-RateLimit-Limit', reply.allowed);

@@ -93,0 +110,0 @@ resp.setHeader('X-RateLimit-Remaining', reply.allowed - reply.used);

2

npm-shrinkwrap.json
{
"name": "volos-quota-common",
"version": "0.11.8",
"version": "0.11.9",
"lockfileVersion": 1,

@@ -5,0 +5,0 @@ "requires": true,

{
"name": "volos-quota-common",
"version": "0.11.8",
"version": "0.11.9",
"main": "lib/quota.js",

@@ -5,0 +5,0 @@ "license": "MIT",

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