node-ipinfo
Advanced tools
Comparing version 3.2.0 to 3.3.0
# CHANGELOG | ||
## 3.3.0 | ||
- Checking `bogon` IP locally. | ||
## 3.2.0 | ||
@@ -4,0 +8,0 @@ |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
@@ -223,3 +219,3 @@ if (k2 === undefined) k2 = k; | ||
domain: "lumen.com", | ||
route: "4.0.0.0/9", | ||
route: "4.4.0.0/16", | ||
type: "isp" | ||
@@ -288,2 +284,16 @@ }, | ||
}); }); | ||
test("isBogon", function (done) { return __awaiter(void 0, void 0, void 0, function () { | ||
var data; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4, ipinfoWrapper.lookupIp("198.51.100.1")]; | ||
case 1: | ||
data = _a.sent(); | ||
expect(data.ip).toEqual("198.51.100.1"); | ||
expect(data.bogon).toEqual(true); | ||
done(); | ||
return [2]; | ||
} | ||
}); | ||
}); }); | ||
}); |
@@ -122,1 +122,2 @@ export declare const HOST: string; | ||
} | ||
export declare const BOGON_NETWORKS: readonly ["0.0.0.0/8", "10.0.0.0/8", "100.64.0.0/10", "127.0.0.0/8", "169.254.0.0/16", "172.16.0.0/12", "192.0.0.0/24", "192.0.2.0/24", "192.168.0.0/16", "198.18.0.0/15", "198.51.100.0/24", "203.0.113.0/24", "224.0.0.0/4", "240.0.0.0/4", "255.255.255.255/32", "::/128", "::1/128", "::ffff:0:0/96", "::/96", "100::/64", "2001:10::/28", "2001:db8::/32", "fc00::/7", "fe80::/10", "fec0::/10", "ff00::/8", "2002::/24", "2002:a00::/24", "2002:7f00::/24", "2002:a9fe::/32", "2002:ac10::/28", "2002:c000::/40", "2002:c000:200::/40", "2002:c0a8::/32", "2002:c612::/31", "2002:c633:6400::/40", "2002:cb00:7100::/40", "2002:e000::/20", "2002:f000::/20", "2002:ffff:ffff::/48", "2001::/40", "2001:0:a00::/40", "2001:0:7f00::/40", "2001:0:a9fe::/48", "2001:0:ac10::/44", "2001:0:c000::/56", "2001:0:c000:200::/56", "2001:0:c0a8::/48", "2001:0:c612::/47", "2001:0:c633:6400::/56", "2001:0:cb00:7100::/56", "2001:0:e000::/36", "2001:0:f000::/36", "2001:0:ffff:ffff::/64"]; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.BATCH_REQ_TIMEOUT_DEFAULT = exports.REQUEST_TIMEOUT_DEFAULT = exports.BATCH_MAX_SIZE = exports.CACHE_VSN = exports.HOST = void 0; | ||
exports.BOGON_NETWORKS = exports.BATCH_REQ_TIMEOUT_DEFAULT = exports.REQUEST_TIMEOUT_DEFAULT = exports.BATCH_MAX_SIZE = exports.CACHE_VSN = exports.HOST = void 0; | ||
exports.HOST = "ipinfo.io"; | ||
@@ -9,1 +9,57 @@ exports.CACHE_VSN = "1"; | ||
exports.BATCH_REQ_TIMEOUT_DEFAULT = 5000; | ||
exports.BOGON_NETWORKS = [ | ||
"0.0.0.0/8", | ||
"10.0.0.0/8", | ||
"100.64.0.0/10", | ||
"127.0.0.0/8", | ||
"169.254.0.0/16", | ||
"172.16.0.0/12", | ||
"192.0.0.0/24", | ||
"192.0.2.0/24", | ||
"192.168.0.0/16", | ||
"198.18.0.0/15", | ||
"198.51.100.0/24", | ||
"203.0.113.0/24", | ||
"224.0.0.0/4", | ||
"240.0.0.0/4", | ||
"255.255.255.255/32", | ||
"::/128", | ||
"::1/128", | ||
"::ffff:0:0/96", | ||
"::/96", | ||
"100::/64", | ||
"2001:10::/28", | ||
"2001:db8::/32", | ||
"fc00::/7", | ||
"fe80::/10", | ||
"fec0::/10", | ||
"ff00::/8", | ||
"2002::/24", | ||
"2002:a00::/24", | ||
"2002:7f00::/24", | ||
"2002:a9fe::/32", | ||
"2002:ac10::/28", | ||
"2002:c000::/40", | ||
"2002:c000:200::/40", | ||
"2002:c0a8::/32", | ||
"2002:c612::/31", | ||
"2002:c633:6400::/40", | ||
"2002:cb00:7100::/40", | ||
"2002:e000::/20", | ||
"2002:f000::/20", | ||
"2002:ffff:ffff::/48", | ||
"2001::/40", | ||
"2001:0:a00::/40", | ||
"2001:0:7f00::/40", | ||
"2001:0:a9fe::/48", | ||
"2001:0:ac10::/44", | ||
"2001:0:c000::/56", | ||
"2001:0:c000:200::/56", | ||
"2001:0:c0a8::/48", | ||
"2001:0:c612::/47", | ||
"2001:0:c633:6400::/56", | ||
"2001:0:cb00:7100::/56", | ||
"2001:0:e000::/36", | ||
"2001:0:f000::/36", | ||
"2001:0:ffff:ffff::/64" | ||
]; |
@@ -21,2 +21,3 @@ import Cache from "./cache/cache"; | ||
private is4xxOr5xx; | ||
private isBogon; | ||
} |
@@ -50,5 +50,6 @@ "use strict"; | ||
var apiLimitError_1 = __importDefault(require("./errors/apiLimitError")); | ||
var isInSubnet = require("subnet-check").isInSubnet; | ||
var common_1 = require("./common"); | ||
var version_1 = __importDefault(require("./version")); | ||
var clientUserAgent = "IPinfoClient/nodejs/".concat(version_1.default); | ||
var clientUserAgent = "IPinfoClient/nodejs/" + version_1.default; | ||
var IPinfoWrapper = (function () { | ||
@@ -70,6 +71,14 @@ function IPinfoWrapper(token, cache, timeout) { | ||
IPinfoWrapper.cacheKey = function (k) { | ||
return "".concat(k, ":").concat(common_1.CACHE_VSN); | ||
return k + ":" + common_1.CACHE_VSN; | ||
}; | ||
IPinfoWrapper.prototype.lookupIp = function (ip) { | ||
var _this = this; | ||
if (this.isBogon(ip)) { | ||
var ipinfo_1 = {}; | ||
ipinfo_1.bogon = true; | ||
ipinfo_1.ip = ip; | ||
return new Promise(function (resolve) { | ||
resolve(ipinfo_1); | ||
}); | ||
} | ||
var data = this.cache.get(IPinfoWrapper.cacheKey(ip)); | ||
@@ -84,3 +93,3 @@ if (data) { | ||
Accept: "application/json", | ||
Authorization: "Bearer ".concat(this.token), | ||
Authorization: "Bearer " + this.token, | ||
"Content-Type": "application/json", | ||
@@ -91,3 +100,3 @@ "User-Agent": clientUserAgent | ||
host: common_1.HOST, | ||
path: "/".concat(ip), | ||
path: "/" + ip, | ||
timeout: this.timeout | ||
@@ -162,3 +171,3 @@ }; | ||
Accept: "application/json", | ||
Authorization: "Bearer ".concat(this.token), | ||
Authorization: "Bearer " + this.token, | ||
"Content-Type": "application/json", | ||
@@ -169,3 +178,3 @@ "User-Agent": clientUserAgent | ||
host: common_1.HOST, | ||
path: "/".concat(asn, "/json"), | ||
path: "/" + asn + "/json", | ||
timeout: this.timeout | ||
@@ -227,3 +236,3 @@ }; | ||
Accept: "application/json", | ||
Authorization: "Bearer ".concat(this.token), | ||
Authorization: "Bearer " + this.token, | ||
"Content-Type": "application/json", | ||
@@ -281,3 +290,3 @@ "Content-Length": ipsData.length, | ||
Accept: "application/json", | ||
Authorization: "Bearer ".concat(this.token), | ||
Authorization: "Bearer " + this.token, | ||
"Content-Type": "application/json", | ||
@@ -289,3 +298,3 @@ "Content-Length": ipsData.length, | ||
host: common_1.HOST, | ||
path: "/batch".concat(filter ? "?filter=1" : ""), | ||
path: "/batch" + (filter ? "?filter=1" : ""), | ||
timeout: batchTimeout | ||
@@ -428,4 +437,13 @@ }; | ||
}; | ||
IPinfoWrapper.prototype.isBogon = function (ip) { | ||
for (var _i = 0, BOGON_NETWORKS_1 = common_1.BOGON_NETWORKS; _i < BOGON_NETWORKS_1.length; _i++) { | ||
var network = BOGON_NETWORKS_1[_i]; | ||
if (isInSubnet(ip, network)) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
}; | ||
return IPinfoWrapper; | ||
}()); | ||
exports.default = IPinfoWrapper; |
@@ -1,2 +0,2 @@ | ||
declare const VERSION = "3.2.0"; | ||
declare const VERSION = "3.3.0"; | ||
export default VERSION; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var VERSION = "3.2.0"; | ||
var VERSION = "3.3.0"; | ||
exports.default = VERSION; |
{ | ||
"name": "node-ipinfo", | ||
"version": "3.2.0", | ||
"version": "3.3.0", | ||
"description": "Official Node client library for IPinfo", | ||
@@ -33,4 +33,5 @@ "main": "dist/src/index.js", | ||
"dependencies": { | ||
"@types/lru-cache": "^5.1.1", | ||
"lru-cache": "^6.0.0", | ||
"@types/lru-cache": "^5.1.1" | ||
"subnet-check": "^1.10.1" | ||
}, | ||
@@ -37,0 +38,0 @@ "devDependencies": { |
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
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
113269
2052
1
3
+ Addedsubnet-check@^1.10.1
+ Addedsubnet-check@1.10.1(transitive)