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

@libj/ip-filter

Package Overview
Dependencies
Maintainers
2
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@libj/ip-filter - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

dist/constants.d.ts

12

dist/makeIpFilterMiddleware.js

@@ -6,6 +6,7 @@ "use strict";

var src_1 = require("@libj/http-meta");
var constants_1 = require("./constants");
exports.makeIpFilterMiddleware = function (config) { return function (req, res, next) {
var _a = validateConfig(config), whitelist = _a.whitelist, blacklist = _a.blacklist, response = _a.response, ip = defineIp(req, config);
var response = validateConfig(config).response, ip = defineIp(req, config);
if (ip) {
var isAllowed = whitelist ? isIpInRange_1.isIpInRange(ip, whitelist) : !isIpInRange_1.isIpInRange(ip, blacklist);
var isAllowed = isIpAllowed(ip, config);
if (isAllowed) {

@@ -33,2 +34,9 @@ return next();

}
function isIpAllowed(ip, config) {
var whitelist = config.whitelist, blacklist = config.blacklist;
if (whitelist) {
return whitelist.indexOf(constants_1.WILDCARD_IP) > -1 ? true : isIpInRange_1.isIpInRange(ip, whitelist);
}
return !isIpInRange_1.isIpInRange(ip, blacklist);
}
function validateConfig(config) {

@@ -35,0 +43,0 @@ if (!config.whitelist && !config.blacklist) {

8

package.json
{
"dependencies": {
"@libj/http-meta": "0.1.5",
"@libj/logger": "0.0.5",
"@libj/http-meta": "0.1.6",
"@libj/logger": "0.0.6",
"ip-range-check": "^0.2.0"
},
"name": "@libj/ip-filter",
"version": "0.0.1",
"version": "0.0.2",
"description": "Ip filter utils (function, middleware)",

@@ -38,3 +38,3 @@ "author": "Sergey Poskachey <seregynp@gmail.com>",

},
"gitHead": "f3465afd0105f9003e74b9171b25f6181f36e59e"
"gitHead": "9f86083862e66b5d34d2fdb6954bb3d6d7d563e4"
}

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