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

ip2location-nodejs

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ip2location-nodejs - npm Package Compare versions

Comparing version 9.4.2 to 9.4.3

3

package.json
{
"name": "ip2location-nodejs",
"version": "9.4.2",
"version": "9.4.3",
"description": "IP2Location geolocation component",

@@ -25,3 +25,2 @@ "keywords": [

"dependencies": {
"big-integer": "^1.6.47",
"csv-parser": "^3.0.0"

@@ -28,0 +27,0 @@ },

@@ -16,3 +16,3 @@ export class IP2Location {

* @param readType The data type to convert the bytes to. (Valid values: int8|int32|uint32|float|str|int128)
* @param isBigInt Whether to convert to BigInteger object.
* @param isBigInt Whether to convert to BigInt.
* @returns The value of the specified data type.

@@ -40,3 +40,3 @@ */

* @param position The file offset to start reading.
* @param isBigInt Whether to convert to BigInteger object.
* @param isBigInt Whether to convert to BigInt.
* @returns Unsigned 32-bit integer.

@@ -58,3 +58,3 @@ */

* @param buffer The buffer containing the data.
* @returns BigInteger object.
* @returns BigInt.
*/

@@ -68,3 +68,3 @@ read128Row(position: number, buffer: any): any;

* @param len The number of bytes to read.
* @returns BigInteger object or unsigned 32-bit integer.
* @returns BigInt or unsigned 32-bit integer.
*/

@@ -77,3 +77,3 @@ read32Or128Row(position: number, buffer: any, len: number): any;

* @param ipType 4 for IPv4 or 6 for IPv6.
* @returns BigInteger object or unsigned 32-bit integer.
* @returns BigInt or unsigned 32-bit integer.
*/

@@ -85,3 +85,3 @@ read32Or128(position: number, ipType: number): any;

* @param position The file offset to start reading.
* @returns BigInteger object.
* @returns BigInt.
*/

@@ -427,3 +427,3 @@ read128(position: number): any;

* @param myIP The IP address to convert.
* @returns The IP number in a BigInteger object.
* @returns The IP number in a BigInt.
*/

@@ -430,0 +430,0 @@ ipV6ToDecimal(myIP: string): any;

var net = require("net");
var fs = require("fs");
var bigInt = require("big-integer");
var https = require("https");

@@ -8,3 +7,3 @@ const csv = require("csv-parser");

// For BIN queries
const VERSION = "9.4.2";
const VERSION = "9.4.3";
const MAX_INDEX = 65536;

@@ -85,9 +84,9 @@ const COUNTRY_POSITION = [

];
const MAX_IPV4_RANGE = bigInt(4294967295);
const MAX_IPV6_RANGE = bigInt("340282366920938463463374607431768211455");
const FROM_6TO4 = bigInt("42545680458834377588178886921629466624");
const TO_6TO4 = bigInt("42550872755692912415807417417958686719");
const FROM_TEREDO = bigInt("42540488161975842760550356425300246528");
const TO_TEREDO = bigInt("42540488241204005274814694018844196863");
const LAST_32_BITS = bigInt("4294967295");
const MAX_IPV4_RANGE = BigInt(4294967295);
const MAX_IPV6_RANGE = BigInt("340282366920938463463374607431768211455");
const FROM_6TO4 = BigInt("42545680458834377588178886921629466624");
const TO_6TO4 = BigInt("42550872755692912415807417417958686719");
const FROM_TEREDO = BigInt("42540488161975842760550356425300246528");
const TO_TEREDO = BigInt("42540488241204005274814694018844196863");
const LAST_32_BITS = BigInt("4294967295");

@@ -244,3 +243,3 @@ const MODES = {

return isBigInt
? bigInt(buffer.readUInt32LE(0))
? BigInt(buffer.readUInt32LE(0))
: buffer.readUInt32LE(0);

@@ -255,8 +254,6 @@ break;

case "int128":
let myBig = bigInt(); // zero
let myBig = BigInt(0); // zero
let bitShift = 8;
for (let x = 0; x < 16; x++) {
myBig = myBig.add(
bigInt(buffer.readUInt8(x)).shiftLeft(bitShift * x)
);
myBig = myBig + (BigInt(buffer.readUInt8(x)) << (bitShift * x));
}

@@ -295,9 +292,8 @@ return myBig;

read128Row(position, buffer) {
let myBig = bigInt(); // zero
let myBig = BigInt(0); // zero
let bitShift = 8;
for (let x = 0; x < 16; x++) {
let pos = position + x;
myBig = myBig.add(
bigInt(this.read8Row(pos, buffer)).shiftLeft(bitShift * x)
);
myBig =
myBig + (BigInt(this.read8Row(pos, buffer)) << BigInt(bitShift * x));
}

@@ -579,4 +575,4 @@ return myBig;

if (
(ipNumber.geq(FROM_6TO4) && ipNumber.leq(TO_6TO4)) ||
(ipNumber.geq(FROM_TEREDO) && ipNumber.leq(TO_TEREDO))
(ipNumber >= FROM_6TO4 && ipNumber <= TO_6TO4) ||
(ipNumber >= FROM_TEREDO && ipNumber <= TO_TEREDO)
) {

@@ -589,6 +585,6 @@ ipType = 4;

if (ipNumber.geq(FROM_6TO4) && ipNumber.leq(TO_6TO4)) {
ipNumber = ipNumber.shiftRight(80).and(LAST_32_BITS).toJSNumber();
if (ipNumber >= FROM_6TO4 && ipNumber <= TO_6TO4) {
ipNumber = Number((ipNumber >> BigInt(80)) & LAST_32_BITS);
} else {
ipNumber = ipNumber.not().and(LAST_32_BITS).toJSNumber();
ipNumber = Number(~ipNumber & LAST_32_BITS);
}

@@ -603,3 +599,3 @@ if (this.#myDB.indexed == 1) {

if (this.#myDB.indexedIPV6 == 1) {
indexAddress = ipNumber.shiftRight(112).toJSNumber();
indexAddress = Number(ipNumber >> BigInt(112));
low = this.#indexArrayIPV6[indexAddress][0];

@@ -611,6 +607,6 @@ high = this.#indexArrayIPV6[indexAddress][1];

data.ip = myIP;
ipNumber = bigInt(ipNumber);
ipNumber = BigInt(ipNumber);
if (ipNumber.geq(MAX_IP_RANGE)) {
ipNumber = MAX_IP_RANGE.minus(1);
if (ipNumber >= MAX_IP_RANGE) {
ipNumber = MAX_IP_RANGE - BigInt(1);
}

@@ -630,6 +626,6 @@

ipFrom = bigInt(ipFrom);
ipTo = bigInt(ipTo);
ipFrom = BigInt(ipFrom);
ipTo = BigInt(ipTo);
if (ipFrom.leq(ipNumber) && ipTo.gt(ipNumber)) {
if (ipFrom <= ipNumber && ipTo > ipNumber) {
loadMesg(data, MSG_NOT_SUPPORTED); // load default message

@@ -803,3 +799,3 @@

} else {
if (ipFrom.gt(ipNumber)) {
if (ipFrom > ipNumber) {
high = mid - 1;

@@ -1046,3 +1042,3 @@ } else {

let total = bigInt(); // zero
let total = BigInt(0); // zero

@@ -1055,15 +1051,13 @@ if (m.length == 2) {

for (let x = 0; x < myArrLeft.length; x++) {
total = total.add(
bigInt(parseInt("0x" + myArrLeft[x])).shiftLeft(
(maxSections - (x + 1)) * sectionBits
)
);
total =
total +
(BigInt(parseInt("0x" + myArrLeft[x])) <<
BigInt((maxSections - (x + 1)) * sectionBits));
}
for (let x = 0; x < myArrRight.length; x++) {
total = total.add(
bigInt(parseInt("0x" + myArrRight[x])).shiftLeft(
(myArrRight.length - (x + 1)) * sectionBits
)
);
total =
total +
(BigInt(parseInt("0x" + myArrRight[x])) <<
BigInt((myArrRight.length - (x + 1)) * sectionBits));
}

@@ -1074,7 +1068,6 @@ } else if (m.length == 1) {

for (let x = 0; x < myArr.length; x++) {
total = total.add(
bigInt(parseInt("0x" + myArr[x])).shiftLeft(
(maxSections - (x + 1)) * sectionBits
)
);
total =
total +
(BigInt(parseInt("0x" + myArr[x])) <<
BigInt((maxSections - (x + 1)) * sectionBits));
}

@@ -1248,6 +1241,6 @@ }

if (typeof ipNum == "string" || typeof ipNum == "number") {
ipNum = bigInt(ipNum);
ipNum = BigInt(ipNum);
}
if (ipNum.lt(bigInt.zero) || ipNum.gt(MAX_IPV6_RANGE)) {
if (ipNum < BigInt(0) || ipNum > MAX_IPV6_RANGE) {
return null;

@@ -1366,3 +1359,3 @@ }

let ipNum = bigInt(myBin, 2);
let ipNum = BigInt("0b" + myBin);
let v6 = this.decimalToIPV6(ipNum);

@@ -1369,0 +1362,0 @@

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