maxmind 4.3.5 → 4.3.7
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 +2 -22
- package/lib/index.d.ts +3 -3
- package/lib/index.js +9 -4
- package/lib/index.js.map +1 -1
- package/package.json +18 -17
package/README.md
CHANGED
|
@@ -15,26 +15,6 @@ npm i maxmind
|
|
|
15
15
|
|
|
16
16
|
## Usage
|
|
17
17
|
|
|
18
|
-
### JavaScript
|
|
19
|
-
|
|
20
|
-
```javascript
|
|
21
|
-
const maxmind = require('maxmind');
|
|
22
|
-
|
|
23
|
-
maxmind.open('/path/to/GeoLite2-City.mmdb').then((lookup) => {
|
|
24
|
-
console.log(lookup.get('66.6.44.4'));
|
|
25
|
-
|
|
26
|
-
console.log(lookup.getWithPrefixLength('66.6.44.4'));
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
maxmind.open('/path/to/GeoOrg.mmdb').then((lookup) => {
|
|
30
|
-
console.log(lookup.get('66.6.44.4'));
|
|
31
|
-
|
|
32
|
-
console.log(lookup.getWithPrefixLength('66.6.44.4'));
|
|
33
|
-
});
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
### TypeScript
|
|
37
|
-
|
|
38
18
|
```typescript
|
|
39
19
|
import maxmind, { CityResponse } from 'maxmind';
|
|
40
20
|
|
|
@@ -46,7 +26,7 @@ console.log(lookup.getWithPrefixLength('66.6.44.4')); // tuple with inferred typ
|
|
|
46
26
|
|
|
47
27
|
### Sync API
|
|
48
28
|
|
|
49
|
-
You can use `Reader` class directly
|
|
29
|
+
You can use `Reader` class directly in case if you would want to instantiate it in non-async fashion. Use cases would include receiving a buffer database over network, or just reading it synchronously from disk.
|
|
50
30
|
|
|
51
31
|
```typescript
|
|
52
32
|
import { Reader } from 'maxmind';
|
|
@@ -69,7 +49,7 @@ Supported response types:
|
|
|
69
49
|
- IspResponse
|
|
70
50
|
```
|
|
71
51
|
|
|
72
|
-
##
|
|
52
|
+
## IPv6 Support
|
|
73
53
|
|
|
74
54
|
Module is fully compatible with IPv6. There are no differences in API between IPv4 and IPv6.
|
|
75
55
|
|
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Reader } from 'mmdb-lib';
|
|
1
|
+
import { Reader, Response } from 'mmdb-lib';
|
|
2
2
|
declare type Callback = () => void;
|
|
3
3
|
export interface OpenOpts {
|
|
4
4
|
cache?: {
|
|
@@ -8,14 +8,14 @@ export interface OpenOpts {
|
|
|
8
8
|
watchForUpdatesNonPersistent?: boolean;
|
|
9
9
|
watchForUpdatesHook?: Callback;
|
|
10
10
|
}
|
|
11
|
-
export declare const open: <T>(filepath: string, opts?: OpenOpts
|
|
11
|
+
export declare const open: <T extends Response>(filepath: string, opts?: OpenOpts, cb?: Callback) => Promise<Reader<T>>;
|
|
12
12
|
export declare const openSync: () => never;
|
|
13
13
|
export declare const init: () => never;
|
|
14
14
|
export declare const validate: (ip: string) => boolean;
|
|
15
15
|
export * from 'mmdb-lib';
|
|
16
16
|
declare const _default: {
|
|
17
17
|
init: () => never;
|
|
18
|
-
open: <T>(filepath: string, opts?: OpenOpts | undefined, cb?: Callback | undefined) => Promise<Reader<T>>;
|
|
18
|
+
open: <T extends Response>(filepath: string, opts?: OpenOpts | undefined, cb?: Callback | undefined) => Promise<Reader<T>>;
|
|
19
19
|
openSync: () => never;
|
|
20
20
|
validate: (ip: string) => boolean;
|
|
21
21
|
};
|
package/lib/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -15,20 +19,21 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
15
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
20
|
exports.Reader = exports.validate = exports.init = exports.openSync = exports.open = void 0;
|
|
17
21
|
const assert_1 = __importDefault(require("assert"));
|
|
18
|
-
const tiny_lru_1 = __importDefault(require("tiny-lru"));
|
|
19
22
|
const mmdb_lib_1 = require("mmdb-lib");
|
|
20
23
|
Object.defineProperty(exports, "Reader", { enumerable: true, get: function () { return mmdb_lib_1.Reader; } });
|
|
24
|
+
const tiny_lru_1 = require("tiny-lru");
|
|
21
25
|
const fs_1 = __importDefault(require("./fs"));
|
|
22
26
|
const ip_1 = __importDefault(require("./ip"));
|
|
23
27
|
const is_gzip_1 = __importDefault(require("./is-gzip"));
|
|
24
28
|
const utils_1 = __importDefault(require("./utils"));
|
|
25
29
|
const open = async (filepath, opts, cb) => {
|
|
30
|
+
var _a;
|
|
26
31
|
(0, assert_1.default)(!cb, utils_1.default.legacyErrorMessage);
|
|
27
32
|
const database = await fs_1.default.readFile(filepath);
|
|
28
33
|
if ((0, is_gzip_1.default)(database)) {
|
|
29
34
|
throw new Error('Looks like you are passing in a file in gzip format, please use mmdb database instead.');
|
|
30
35
|
}
|
|
31
|
-
const cache = (0, tiny_lru_1.
|
|
36
|
+
const cache = (0, tiny_lru_1.lru)(((_a = opts === null || opts === void 0 ? void 0 : opts.cache) === null || _a === void 0 ? void 0 : _a.max) || 60000);
|
|
32
37
|
const reader = new mmdb_lib_1.Reader(database, { cache });
|
|
33
38
|
if (opts && !!opts.watchForUpdates) {
|
|
34
39
|
if (opts.watchForUpdatesHook &&
|
|
@@ -44,7 +49,7 @@ const open = async (filepath, opts, cb) => {
|
|
|
44
49
|
if (fs_1.default.existsSync(filepath)) {
|
|
45
50
|
return true;
|
|
46
51
|
}
|
|
47
|
-
await new Promise(a => setTimeout(a, 500));
|
|
52
|
+
await new Promise((a) => setTimeout(a, 500));
|
|
48
53
|
}
|
|
49
54
|
return false;
|
|
50
55
|
};
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,oDAA4B;AAC5B,uCAA4C;AA+FnC,uFA/FA,iBAAM,OA+FA;AA9Ff,uCAA+B;AAC/B,8CAAsB;AACtB,8CAAsB;AACtB,wDAA+B;AAC/B,oDAA4B;AAarB,MAAM,IAAI,GAAG,KAAK,EACvB,QAAgB,EAChB,IAAe,EACf,EAAa,EACO,EAAE;;IACtB,IAAA,gBAAM,EAAC,CAAC,EAAE,EAAE,eAAK,CAAC,kBAAkB,CAAC,CAAC;IAEtC,MAAM,QAAQ,GAAG,MAAM,YAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAE7C,IAAI,IAAA,iBAAM,EAAC,QAAQ,CAAC,EAAE;QACpB,MAAM,IAAI,KAAK,CACb,wFAAwF,CACzF,CAAC;KACH;IAED,MAAM,KAAK,GAAG,IAAA,cAAG,EAAC,CAAA,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,KAAK,0CAAE,GAAG,KAAI,KAAK,CAAC,CAAC;IAC7C,MAAM,MAAM,GAAG,IAAI,iBAAM,CAAI,QAAQ,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IAElD,IAAI,IAAI,IAAI,CAAC,CAAC,IAAI,CAAC,eAAe,EAAE;QAClC,IACE,IAAI,CAAC,mBAAmB;YACxB,OAAO,IAAI,CAAC,mBAAmB,KAAK,UAAU,EAC9C;YACA,MAAM,IAAI,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AAC5C,CAAC,CAAC;AAFW,QAAA,IAAI,QAEf;AAEW,QAAA,QAAQ,GAAG,YAAE,CAAC,QAAQ,CAAC;AAEpC,2CAAyB;AAEzB,kBAAe;IACb,IAAI,EAAJ,YAAI;IACJ,IAAI,EAAJ,YAAI;IACJ,QAAQ,EAAR,gBAAQ;IACR,QAAQ,EAAE,YAAE,CAAC,QAAQ;CACtB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "maxmind",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.7",
|
|
4
4
|
"homepage": "https://github.com/runk/node-maxmind",
|
|
5
5
|
"description": "IP lookup using Maxmind databases",
|
|
6
6
|
"keywords": [
|
|
@@ -27,20 +27,22 @@
|
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"mmdb-lib": "2.0.2",
|
|
30
|
-
"tiny-lru": "
|
|
30
|
+
"tiny-lru": "9.0.2"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@types/
|
|
34
|
-
"@types/jest": "
|
|
35
|
-
"@types/
|
|
36
|
-
"@types/
|
|
33
|
+
"@types/ip6addr": "0.2.3",
|
|
34
|
+
"@types/jest": "28.1.8",
|
|
35
|
+
"@types/netmask": "1.0.30",
|
|
36
|
+
"@types/node": "16.11.63",
|
|
37
|
+
"@types/sinon": "10.0.13",
|
|
37
38
|
"ip-address": "8.1.0",
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
39
|
+
"ip6addr": "0.2.5",
|
|
40
|
+
"jest": "28.1.3",
|
|
41
|
+
"prettier": "2.7.1",
|
|
42
|
+
"semantic-release": "19.0.5",
|
|
43
|
+
"sinon": "14.0.0",
|
|
44
|
+
"ts-jest": "28.0.7",
|
|
45
|
+
"typescript": "4.8.4"
|
|
44
46
|
},
|
|
45
47
|
"repository": {
|
|
46
48
|
"type": "git",
|
|
@@ -56,16 +58,15 @@
|
|
|
56
58
|
"main": "lib/index.js",
|
|
57
59
|
"typings": "lib/index.d.ts",
|
|
58
60
|
"engines": {
|
|
59
|
-
"node": ">=
|
|
61
|
+
"node": ">=12",
|
|
60
62
|
"npm": ">=6"
|
|
61
63
|
},
|
|
62
64
|
"license": "MIT",
|
|
63
65
|
"scripts": {
|
|
64
66
|
"build": "rm -rf lib/* && tsc",
|
|
65
|
-
"
|
|
66
|
-
"lint:types": "tsc --noEmit",
|
|
67
|
-
"test": "jest",
|
|
67
|
+
"format": "prettier --write .",
|
|
68
68
|
"prepublish": "npm run build",
|
|
69
|
-
"semantic-release": "semantic-release"
|
|
69
|
+
"semantic-release": "semantic-release",
|
|
70
|
+
"test": "jest"
|
|
70
71
|
}
|
|
71
72
|
}
|