mmdb-lib 2.1.0 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -1
- package/lib/decoder.js +3 -3
- package/lib/metadata.js +1 -2
- package/lib/utils.d.ts +1 -0
- package/lib/utils.js +6 -0
- package/package.json +7 -11
package/README.md
CHANGED
|
@@ -63,4 +63,16 @@ MIT
|
|
|
63
63
|
|
|
64
64
|
## Contributing
|
|
65
65
|
|
|
66
|
-
add
|
|
66
|
+
All contributions are welcome. Please make sure to add tests for your changes.
|
|
67
|
+
|
|
68
|
+
You need to initialise the repository with the following command:
|
|
69
|
+
|
|
70
|
+
```shell
|
|
71
|
+
git submodule update --init --recursive
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Then you can run tests with:
|
|
75
|
+
|
|
76
|
+
```shell
|
|
77
|
+
npm test
|
|
78
|
+
```
|
package/lib/decoder.js
CHANGED
|
@@ -3,9 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const assert_1 = __importDefault(require("assert"));
|
|
7
6
|
const utils_1 = __importDefault(require("./utils"));
|
|
8
|
-
|
|
7
|
+
utils_1.default.assert(typeof BigInt !== 'undefined', 'Apparently you are using old version of node. Please upgrade to node 10.4.x or above.');
|
|
9
8
|
var DataType;
|
|
10
9
|
(function (DataType) {
|
|
11
10
|
DataType[DataType["Extended"] = 0] = "Extended";
|
|
@@ -34,7 +33,8 @@ const cursor = (value, offset) => ({ value, offset });
|
|
|
34
33
|
class Decoder {
|
|
35
34
|
constructor(db, baseOffset = 0, cache = noCache) {
|
|
36
35
|
this.telemetry = {};
|
|
37
|
-
|
|
36
|
+
utils_1.default.assert(Boolean(db), 'Database buffer is required');
|
|
37
|
+
this.db = db;
|
|
38
38
|
this.baseOffset = baseOffset;
|
|
39
39
|
this.cache = cache;
|
|
40
40
|
}
|
package/lib/metadata.js
CHANGED
|
@@ -4,7 +4,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.isLegacyFormat = exports.parseMetadata = void 0;
|
|
7
|
-
const assert_1 = __importDefault(require("assert"));
|
|
8
7
|
const decoder_1 = __importDefault(require("./decoder"));
|
|
9
8
|
const utils_1 = __importDefault(require("./utils"));
|
|
10
9
|
const METADATA_START_MARKER = Buffer.from('ABCDEF4D61784D696E642E636F6D', 'hex');
|
|
@@ -17,7 +16,7 @@ const parseMetadata = (db) => {
|
|
|
17
16
|
? utils_1.default.legacyErrorMessage
|
|
18
17
|
: 'Cannot parse binary database');
|
|
19
18
|
}
|
|
20
|
-
|
|
19
|
+
utils_1.default.assert([24, 28, 32].indexOf(metadata.record_size) > -1, 'Unsupported record size');
|
|
21
20
|
return {
|
|
22
21
|
binaryFormatMajorVersion: metadata.binary_format_major_version,
|
|
23
22
|
binaryFormatMinorVersion: metadata.binary_format_minor_version,
|
package/lib/utils.d.ts
CHANGED
package/lib/utils.js
CHANGED
|
@@ -13,7 +13,13 @@ const legacyErrorMessage = `Maxmind v2 module has changed API.\n\
|
|
|
13
13
|
Upgrade instructions can be found here: \
|
|
14
14
|
https://github.com/runk/node-maxmind/wiki/Migration-guide\n\
|
|
15
15
|
If you want to use legacy library then explicitly install maxmind@1`;
|
|
16
|
+
const assert = (condition, message) => {
|
|
17
|
+
if (!condition) {
|
|
18
|
+
throw new Error(message);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
16
21
|
exports.default = {
|
|
22
|
+
assert,
|
|
17
23
|
concat2,
|
|
18
24
|
concat3,
|
|
19
25
|
concat4,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mmdb-lib",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"homepage": "https://github.com/runk/mmdb-lib",
|
|
5
5
|
"description": "Maxmind DB (MMDB) Library",
|
|
6
6
|
"keywords": [
|
|
@@ -16,20 +16,17 @@
|
|
|
16
16
|
"Uman Shahzad @UmanShahzad"
|
|
17
17
|
],
|
|
18
18
|
"devDependencies": {
|
|
19
|
-
"@types/ip-address": "
|
|
19
|
+
"@types/ip-address": "7.0.0",
|
|
20
20
|
"@types/mocha": "^10.0.1",
|
|
21
|
-
"@types/node": "20.
|
|
22
|
-
"@types/sinon": "17.0.
|
|
23
|
-
"@typescript-eslint/eslint-plugin": "^5.0.0",
|
|
24
|
-
"@typescript-eslint/parser": "^5.0.0",
|
|
25
|
-
"eslint": "^8.0.0",
|
|
21
|
+
"@types/node": "20.12.8",
|
|
22
|
+
"@types/sinon": "17.0.3",
|
|
26
23
|
"ip-address": "9.0.5",
|
|
27
24
|
"mocha": "^10.2.0",
|
|
28
25
|
"prettier": "^3.0.0",
|
|
29
|
-
"semantic-release": "^
|
|
26
|
+
"semantic-release": "^23.0.0",
|
|
30
27
|
"sinon": "17.0.1",
|
|
31
28
|
"ts-node": "^10.4.0",
|
|
32
|
-
"typescript": "5.
|
|
29
|
+
"typescript": "5.4.5"
|
|
33
30
|
},
|
|
34
31
|
"repository": {
|
|
35
32
|
"type": "git",
|
|
@@ -51,8 +48,7 @@
|
|
|
51
48
|
"license": "MIT",
|
|
52
49
|
"scripts": {
|
|
53
50
|
"build": "rm -rf lib/* && tsc",
|
|
54
|
-
"
|
|
55
|
-
"lint:types": "tsc --noEmit",
|
|
51
|
+
"typecheck": "tsc --noEmit",
|
|
56
52
|
"test": "mocha",
|
|
57
53
|
"test-imports": "node test/imports/commonjs.js && node test/imports/esm.mjs && ts-node test/imports/typescript.ts",
|
|
58
54
|
"format": "prettier --write src",
|