private-ip
Advanced tools
Comparing version 2.3.4 to 3.0.0
'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 |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
14894
10
446
Yes
+ Added@chainsafe/is-ip@^2.0.1
+ Added@chainsafe/is-ip@2.0.2(transitive)
+ Addedip-regex@5.0.0(transitive)
- Removedis-ip@^3.1.0
- Removedip-regex@4.3.0(transitive)
- Removedis-ip@3.1.0(transitive)
Updatedip-regex@^5.0.0