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

private-ip

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

private-ip - npm Package Compare versions

Comparing version 2.3.4 to 3.0.0

_test.js

3

index.js
'use strict'
module.exports = require('./lib').default
import is_ip_private from './lib/index.js'
export default is_ip_private

@@ -1,2 +0,2 @@

declare const _default: (ip: string) => boolean;
declare const _default: (ip: string) => boolean | undefined;
export default _default;

@@ -1,10 +0,6 @@

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const netmask_1 = require("netmask");
const ip_regex_1 = __importDefault(require("ip-regex"));
const is_ip_1 = __importDefault(require("is-ip"));
const ipaddr_js_1 = require("ipaddr.js");
import { Netmask } from 'netmask';
import ip_regex from 'ip-regex';
import { isIP } from '@chainsafe/is-ip';
import ipaddr from 'ipaddr.js';
const { isValid: is_valid, parse } = ipaddr;
const PRIVATE_IP_RANGES = [

@@ -36,3 +32,3 @@ '0.0.0.0/8',

];
const NETMASK_RANGES = PRIVATE_IP_RANGES.map(ip_range => new netmask_1.Netmask(ip_range));
const NETMASK_RANGES = PRIVATE_IP_RANGES.map(ip_range => new Netmask(ip_range));
function ipv4_check(ip_addr) {

@@ -60,5 +56,5 @@ for (let r of NETMASK_RANGES) {

}
exports.default = (ip) => {
if ((0, ipaddr_js_1.isValid)(ip)) {
const parsed = (0, ipaddr_js_1.parse)(ip);
export default (ip) => {
if (is_valid(ip)) {
const parsed = parse(ip);
if (parsed.kind() === 'ipv4')

@@ -69,5 +65,5 @@ return ipv4_check(parsed.toNormalizedString());

}
else if ((0, is_ip_1.default)(ip) && ip_regex_1.default.v6().test(ip))
else if (isIP(ip) && ip_regex.v6().test(ip))
return ipv6_check(ip);
return undefined;
};
{
"name": "private-ip",
"version": "2.3.4",
"version": "3.0.0",
"description": "Check if IP address is private.",
"main": "index.js",
"exports": "./index.js",
"type": "module",
"types": "lib/index.d.ts",

@@ -48,12 +49,15 @@ "repository": {

"@types/netmask": "^1.0.30",
"ava": "^4.3.1",
"ava": "^5.0.1",
"rimraf": "^3.0.2",
"typescript": "^4.7.4"
"typescript": "^4.8.4"
},
"dependencies": {
"ip-regex": "^4.3.0",
"@chainsafe/is-ip": "^2.0.1",
"ip-regex": "^5.0.0",
"ipaddr.js": "^2.0.1",
"is-ip": "^3.1.0",
"netmask": "^2.0.2"
},
"engines": {
"node": ">=14.16"
}
}

@@ -23,3 +23,3 @@ private-ip

```js
const is_ip_private = require('private-ip')
import is_ip_private from 'private-ip'

@@ -26,0 +26,0 @@ is_ip_private('10.0.0.0')

@@ -1,3 +0,3 @@

const test = require('ava')
const is_ip_private = require('./')
import test from 'ava'
import is_ip_private from './index.js'

@@ -4,0 +4,0 @@ const pub_ips = [

{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"target": "ES2020",
"module": "ES2020",
"moduleResolution": "node",
"esModuleInterop": true,

@@ -6,0 +7,0 @@ "declaration": true

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