@streamr/geoip-location 100.2.4

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/.eslintignore ADDED
@@ -0,0 +1,4 @@
1
+ node_modules/**
2
+ dist/**
3
+ .idea/**
4
+ src/proto/**
package/.eslintrc ADDED
@@ -0,0 +1,3 @@
1
+ {
2
+ "extends": "../../.eslintrc.js"
3
+ }
package/LICENSE ADDED
@@ -0,0 +1,174 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
package/README.md ADDED
@@ -0,0 +1,72 @@
1
+ # geoip-location
2
+
3
+ @streamr/geoip-location is a package that provides a way to detect the latitude and longitude of an IP address using
4
+ the [mmdb-lib reader package](https://www.npmjs.com/package/mmdb-lib) and the MaxMind GeoLite2 City database resdistributed by [GitSquared/node-geolite2-redist](https://github.com/GitSquared/node-geolite2-redist). The library complies with the
5
+ [MaxMind GeoLite2 End User License Agreement] (https://www.maxmind.com/en/geolite2/eula) by keeping the database up-to-date by periodically downloading the fresh database from the GitSquared/node-geolite2-redist repository.
6
+
7
+ ## Differences to the node-geolite2-redist package
8
+
9
+ * The period between checks for the updates of the GeoLite2 City database is configurable
10
+ * Distributed as commonjs module for greater compatibility with other packages
11
+ * Better error handling and focus on clean shutdown without lingering timers or memory leaks
12
+ * Fewer dependencies: uses 'fetch' instead of 'got' for downloading the database
13
+ * Only supports the GeoLite2 City database
14
+ * Only returns the latitude and longitude of the IP address
15
+
16
+ # Getting started
17
+
18
+ ## Installation
19
+
20
+ ```bash
21
+ npm install @streamr/geoip-location
22
+ ```
23
+
24
+ ## Usage
25
+
26
+ ```typescript
27
+ import { GeoIpLocator } from '@streamr/geoip-location'
28
+
29
+ (async () => {
30
+
31
+ // Creates a new GeoIpLocator object with the following parameters:
32
+ // geoiIpDatabasePath: string - the path to the directory for the GeoLite2 City database
33
+ // the disrectory will be created if it does not exist.
34
+ // dbCheckInterval?: number - the interval in milliseconds between the checks
35
+ // for the updates of the GeoLite2 City database (default: 28 days)
36
+ // dbCheckErrorInterval?: number - the interval in milliseconds between the checks
37
+ // for the updates of the GeoLite2 City database in case of a failed update (default: 1 day)
38
+
39
+ const locator = new GeoIpLocator('~/geoipdatabases', 15 * 24 * 60 * 60 * 1000, 60 * 60 * 1000)
40
+
41
+ // Downloads the GeoLite2 City database if it is not found in the geoiIpDatabasePath
42
+ // or if the database is outdated. Also starts the db update timer.
43
+
44
+ await locator.start()
45
+
46
+ // Returns the { latitude, longitude } of the IP address
47
+ // or undefined if the location cannot be found
48
+
49
+ const location = locator!.lookup('62.241.198.245')
50
+
51
+ console.log(location.latitude) // 60.1695
52
+ console.log(location.longitude) // 24.9354
53
+
54
+ // Stops the db update timer, does not delete the GeoLite2 City database
55
+
56
+ locator.stop()
57
+
58
+ // (optional) Deletes the GeoLite2 City database
59
+
60
+ fs.unlinkSync(dbDir + '~/geoipdatabases/GeoLite2-City.mmdb')
61
+
62
+ })()
63
+ ```
64
+
65
+ ## License
66
+
67
+ This package is licensed under the Apache-2.0 license (see [LICENSE](./LICENSE)).
68
+ The databases themselves are provided by MaxMind under [CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/) and redistributed by [GitSquared/node-geolite2-redist](https://github.com/GitSquared/node-geolite2-redist)
69
+
70
+
71
+ **This software package uses GeoLite2 data created by MaxMind, available from [https://www.maxmind.com](https://www.maxmind.com).**
72
+
@@ -0,0 +1,20 @@
1
+ interface GeoIpLookupResult {
2
+ latitude: number;
3
+ longitude: number;
4
+ }
5
+ export declare class GeoIpLocator {
6
+ private abortController;
7
+ private readonly geoIpDatabaseFolder;
8
+ private readonly dbCheckInterval;
9
+ private readonly dbCheckErrorInterval;
10
+ private readonly mirrorUrl?;
11
+ private reader?;
12
+ private dbCheckTimeout?;
13
+ constructor(geoIpDatabaseFolder: string, dbCheckInterval?: number, dbCheckErrorInterval?: number, mirrorUrl?: string);
14
+ private checkDatabase;
15
+ private scheduleCheck;
16
+ start(): Promise<void>;
17
+ stop(): void;
18
+ lookup(ip: string): GeoIpLookupResult | undefined;
19
+ }
20
+ export {};
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.GeoIpLocator = void 0;
7
+ const utils_1 = require("@streamr/utils");
8
+ const long_timeout_1 = __importDefault(require("long-timeout"));
9
+ const downloadGeoIpDatabase_1 = require("./downloadGeoIpDatabase");
10
+ const logger = new utils_1.Logger(module);
11
+ // 30 days in milliseconds
12
+ const DEFAULT_DB_CHECK_INTERVAL = 30 * 24 * 60 * 60 * 1000;
13
+ // 24 hours in milliseconds
14
+ const DEFAULT_DB_CHECK_ERROR_INTERVAL = 24 * 60 * 60 * 1000;
15
+ class GeoIpLocator {
16
+ abortController;
17
+ geoIpDatabaseFolder;
18
+ dbCheckInterval;
19
+ dbCheckErrorInterval;
20
+ mirrorUrl;
21
+ reader;
22
+ dbCheckTimeout;
23
+ constructor(geoIpDatabaseFolder, dbCheckInterval = DEFAULT_DB_CHECK_INTERVAL, dbCheckErrorInterval = DEFAULT_DB_CHECK_ERROR_INTERVAL, mirrorUrl) {
24
+ this.abortController = new AbortController();
25
+ this.dbCheckInterval = dbCheckInterval;
26
+ this.dbCheckErrorInterval = dbCheckErrorInterval;
27
+ if (!geoIpDatabaseFolder.endsWith('/')) {
28
+ geoIpDatabaseFolder += '/';
29
+ }
30
+ this.geoIpDatabaseFolder = (0, utils_1.filePathToNodeFormat)(geoIpDatabaseFolder);
31
+ this.mirrorUrl = mirrorUrl;
32
+ }
33
+ checkDatabase = async () => {
34
+ if (this.reader === undefined) {
35
+ // if we do not have a reader, create a new one in any case
36
+ this.reader = await (0, downloadGeoIpDatabase_1.downloadGeoIpDatabase)(this.geoIpDatabaseFolder, true, this.abortController.signal, this.mirrorUrl);
37
+ }
38
+ else {
39
+ // if we already have a reader, create a new one only if db has changed
40
+ const newReader = await (0, downloadGeoIpDatabase_1.downloadGeoIpDatabase)(this.geoIpDatabaseFolder, false, this.abortController.signal, this.mirrorUrl);
41
+ if (newReader !== undefined) {
42
+ this.reader = newReader;
43
+ }
44
+ }
45
+ };
46
+ scheduleCheck = async (timeout) => {
47
+ if (this.abortController.signal.aborted) {
48
+ return;
49
+ }
50
+ this.dbCheckTimeout = long_timeout_1.default.setTimeout(async () => {
51
+ try {
52
+ await this.checkDatabase();
53
+ this.scheduleCheck(this.dbCheckInterval);
54
+ }
55
+ catch (err) {
56
+ logger.warn('GeoIpLocator: GeoIP database check failed', { err });
57
+ this.scheduleCheck(this.dbCheckErrorInterval);
58
+ }
59
+ }, timeout);
60
+ };
61
+ async start() {
62
+ if (this.dbCheckTimeout !== undefined) {
63
+ return;
64
+ }
65
+ await this.checkDatabase();
66
+ this.scheduleCheck(this.dbCheckInterval);
67
+ }
68
+ stop() {
69
+ if (this.dbCheckTimeout !== undefined) {
70
+ long_timeout_1.default.clearTimeout(this.dbCheckTimeout);
71
+ }
72
+ this.abortController.abort();
73
+ }
74
+ lookup(ip) {
75
+ if (this.reader === undefined) {
76
+ logger.warn('GeoIpLocator: lookup called before database is ready (maybe start() was not called?');
77
+ return undefined;
78
+ }
79
+ // If ip is falsy, the library will crash
80
+ // this might happen despite the ts typings because the ip address
81
+ // comes from the ws server socket and is not under our control
82
+ if (!ip) {
83
+ return undefined;
84
+ }
85
+ const result = this.reader.get(ip);
86
+ if (!result || !result.location || !result.location.latitude || !result.location.longitude) {
87
+ return undefined;
88
+ }
89
+ else {
90
+ return {
91
+ latitude: result.location.latitude,
92
+ longitude: result.location.longitude
93
+ };
94
+ }
95
+ }
96
+ }
97
+ exports.GeoIpLocator = GeoIpLocator;
98
+ //# sourceMappingURL=GeoIpLocator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GeoIpLocator.js","sourceRoot":"","sources":["../../src/GeoIpLocator.ts"],"names":[],"mappings":";;;;;;AAAA,0CAA6D;AAE7D,gEAAsC;AACtC,mEAA+D;AAE/D,MAAM,MAAM,GAAG,IAAI,cAAM,CAAC,MAAM,CAAC,CAAA;AAOjC,0BAA0B;AAC1B,MAAM,yBAAyB,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAA;AAC1D,2BAA2B;AAC3B,MAAM,+BAA+B,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAA;AAE3D,MAAa,YAAY;IACb,eAAe,CAAiB;IACvB,mBAAmB,CAAQ;IAC3B,eAAe,CAAQ;IACvB,oBAAoB,CAAQ;IAC5B,SAAS,CAAS;IAC3B,MAAM,CAAuB;IAC7B,cAAc,CAAsB;IAE5C,YACI,mBAA2B,EAC3B,eAAe,GAAG,yBAAyB,EAC3C,oBAAoB,GAAG,+BAA+B,EACtD,SAAkB;QAElB,IAAI,CAAC,eAAe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AAO,SAAS,CAAA;QACpB,CAAC;aAAM,CAAC;YACJ,OAAO;gBACH,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC,QAAQ;gBAClC,SAAS,EAAE,MAAM,CAAC,QAAQ,CAAC,SAAS;aACvC,CAAA;QACL,CAAC;IACL,CAAC;CACJ;AA3FD,oCA2FC"}
@@ -0,0 +1,3 @@
1
+ /// <reference types="node" />
2
+ import { CityResponse, Reader } from 'mmdb-lib';
3
+ export declare const downloadGeoIpDatabase: (dbFolder: string, forceReturnReader: boolean, abortSignal: AbortSignal, mirrorUrl?: string) => Promise<Reader<CityResponse> | undefined>;
@@ -0,0 +1,169 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.downloadGeoIpDatabase = void 0;
7
+ const crypto_1 = __importDefault(require("crypto"));
8
+ const fs_1 = __importDefault(require("fs"));
9
+ const mmdb_lib_1 = require("mmdb-lib");
10
+ const tarHelper_1 = require("./tarHelper");
11
+ const uuid_1 = require("uuid");
12
+ const utils_1 = require("@streamr/utils");
13
+ const GEOIP_MIRROR_URL = 'https://raw.githubusercontent.com/GitSquared/node-geolite2-redist/master/redist/';
14
+ const DB_NAME = 'GeoLite2-City';
15
+ const TAR_SUFFFIX = '.tar.gz';
16
+ const DB_SUFFIX = '.mmdb';
17
+ const HASH_SUFFIX = '.mmdb.sha384';
18
+ const logger = new utils_1.Logger(module);
19
+ const downloadNewDb = async (url, dbFolder, remoteHash, abortSignal) => {
20
+ // make a unique name for the temporary download folder
21
+ // in case there are multiple downloads happening at the same time
22
+ const uniqueName = (0, uuid_1.v4)();
23
+ const downloadFolder = dbFolder + '.download' + uniqueName;
24
+ const dbFileName = DB_NAME + DB_SUFFIX;
25
+ const dbFileInDownloadFolder = downloadFolder + '/' + dbFileName;
26
+ const dbFileInDbFolder = dbFolder + dbFileName;
27
+ let response;
28
+ try {
29
+ logger.debug('Downloading GeoIP database from: ' + url);
30
+ response = await fetch(url, { keepalive: false, signal: abortSignal });
31
+ }
32
+ catch (e) {
33
+ // Catching and re-throwing as async exception
34
+ // here is necessary, synch exceptions cannot be caught by the caller
35
+ throw new Error('Fetch error when downloading ' + url + ', error: ' + e);
36
+ }
37
+ if (!response.ok) {
38
+ throw new Error('HTTP error when downloading ' + url + ', status: ' + response.status);
39
+ }
40
+ // extract the tarball to a temporary folder
41
+ try {
42
+ fs_1.default.mkdirSync(downloadFolder, { recursive: true });
43
+ }
44
+ catch (e) {
45
+ throw new Error('Error creating temporary folder ' + downloadFolder + ', error: ' + e);
46
+ }
47
+ try {
48
+ await (0, tarHelper_1.extractFileFromTarStream)(dbFileName, response.body, downloadFolder);
49
+ }
50
+ catch (e) {
51
+ try {
52
+ fs_1.default.rmSync(downloadFolder, { recursive: true });
53
+ }
54
+ catch (e2) {
55
+ // ignore error when removing the temporary folder
56
+ }
57
+ throw e;
58
+ }
59
+ // check the hash of the extracted file
60
+ if (!isDbFileValid(dbFileInDownloadFolder, remoteHash)) {
61
+ try {
62
+ fs_1.default.rmSync(downloadFolder, { recursive: true });
63
+ }
64
+ catch (e2) {
65
+ // ignore error when removing the temporary folder
66
+ }
67
+ throw new Error('Downloaded database hash does not match the expected hash');
68
+ }
69
+ try {
70
+ // move the extracted file to the correct location
71
+ fs_1.default.renameSync(dbFileInDownloadFolder, dbFileInDbFolder);
72
+ }
73
+ catch (e) {
74
+ throw new Error('Error moving ' + dbFileInDownloadFolder + ' to ' + dbFileInDbFolder + ', error: ' + e);
75
+ }
76
+ finally {
77
+ try {
78
+ fs_1.default.rmSync(downloadFolder, { recursive: true });
79
+ }
80
+ catch (e2) {
81
+ // ignore error when removing the temporary folder
82
+ }
83
+ }
84
+ // set the db file permissions to rw only for the owner
85
+ try {
86
+ fs_1.default.chmodSync(dbFileInDbFolder, 0o600);
87
+ }
88
+ catch (err) {
89
+ throw new Error('Error setting permissions on ' + dbFileInDbFolder + ', error: ' + err);
90
+ }
91
+ logger.debug('Downloaded GeoIP database to: ' + dbFileInDbFolder);
92
+ };
93
+ const downloadRemoteHash = async (remoteHashUrl, abortSignal) => {
94
+ // download the hash of the latest GeoIP database using fetch as text and trim it
95
+ let response;
96
+ try {
97
+ logger.debug('Downloading GeoIP database hash from: ' + remoteHashUrl);
98
+ response = await fetch(remoteHashUrl, { signal: abortSignal });
99
+ }
100
+ catch (e) {
101
+ // Catching and re-throwing as async exception
102
+ // here is necessary, synch exceptions cannot be caught by the caller
103
+ throw new Error('Fetch error when downloading ' + remoteHashUrl + ', error: ' + e);
104
+ }
105
+ if (!response.ok) {
106
+ throw new Error('HTTP error when downloading ' + remoteHashUrl + ', status: ' + response.status);
107
+ }
108
+ return (await response.text()).trim();
109
+ };
110
+ const isDbFileValid = async (dbFile, remoteHash) => {
111
+ // check if the local db exists and calculate its hash
112
+ try {
113
+ const db = fs_1.default.readFileSync(dbFile);
114
+ const localHash = crypto_1.default.createHash('sha384').update(db).digest('hex');
115
+ // if the hashes are different, download the latest database
116
+ if (localHash !== remoteHash) {
117
+ return false;
118
+ }
119
+ else {
120
+ return true;
121
+ }
122
+ }
123
+ catch (e) {
124
+ // if the local db does not exist, or some other exception occurres db is not considered valid
125
+ return false;
126
+ }
127
+ };
128
+ // returns a Reader if a new db was downloaded, or if the caller wants to force return a reader
129
+ // also if there was no need to download a new db
130
+ const downloadGeoIpDatabase = async (dbFolder, forceReturnReader, abortSignal, mirrorUrl) => {
131
+ // This will throw if the download folder is not readable
132
+ if (!fs_1.default.existsSync(dbFolder)) {
133
+ // This will throw if the download folder is not writable
134
+ fs_1.default.mkdirSync(dbFolder, { recursive: true });
135
+ }
136
+ if (!dbFolder.endsWith('/')) {
137
+ dbFolder += '/';
138
+ }
139
+ let geoIpMirrorUrl = GEOIP_MIRROR_URL;
140
+ if (mirrorUrl !== undefined) {
141
+ if (!mirrorUrl.endsWith('/')) {
142
+ mirrorUrl += '/';
143
+ }
144
+ geoIpMirrorUrl = mirrorUrl;
145
+ }
146
+ const remoteHashUrl = geoIpMirrorUrl + DB_NAME + HASH_SUFFIX;
147
+ const dbDownloadUrl = geoIpMirrorUrl + DB_NAME + TAR_SUFFFIX;
148
+ const dbFileInDbFolder = dbFolder + DB_NAME + DB_SUFFIX;
149
+ const remoteHash = await downloadRemoteHash(remoteHashUrl, abortSignal);
150
+ const dbValid = await isDbFileValid(dbFileInDbFolder, remoteHash);
151
+ if (dbValid === false) {
152
+ await downloadNewDb(dbDownloadUrl, dbFolder, remoteHash, abortSignal);
153
+ // return new reader if db was downloaded
154
+ return new mmdb_lib_1.Reader(fs_1.default.readFileSync(dbFileInDbFolder));
155
+ }
156
+ else {
157
+ logger.debug('The hash of the local GeoIP database matches the remote hash, no need to download a new database');
158
+ }
159
+ if (forceReturnReader) {
160
+ // return reader also for old db the caller wants it
161
+ return new mmdb_lib_1.Reader(fs_1.default.readFileSync(dbFileInDbFolder));
162
+ }
163
+ else {
164
+ // return undefined if the db is already up to date
165
+ return undefined;
166
+ }
167
+ };
168
+ exports.downloadGeoIpDatabase = downloadGeoIpDatabase;
169
+ //# sourceMappingURL=downloadGeoIpDatabase.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"downloadGeoIpDatabase.js","sourceRoot":"","sources":["../../src/downloadGeoIpDatabase.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA2B;AAC3B,4CAAmB;AACnB,uCAA+C;AAC/C,2CAAsD;AACtD,+BAAyB;AACzB,0CAAuC;AAEvC,MAAM,gBAAgB,GAAG,kFAAkF,CAAA;AAC3G,MAAM,OAAO,GAAG,eAAe,CAAA;AAC/B,MAAM,WAAW,GAAG,SAAS,CAAA;AAC7B,MAAM,SAAS,GAAG,OAAO,CAAA;AACzB,MAAM,WAAW,GAAG,cAAc,CAAA;AAElC,MAAM,MAAM,GAAG,IAAI,cAAM,CAAC,MAAM,CAAC,CAAA;AAEjC,MAAM,aAAa,GAAG,KAAK,EACvB,GAA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a,EAAE,QAAQ,EAAE,UAAU,EAAE,WAAW,CAAC,CAAA;QACrE,yCAAyC;QACzC,OAAO,IAAI,iBAAM,CAAe,YAAE,CAAC,YAAY,CAAC,gBAAgB,CAAC,CAAC,CAAA;IACtE,CAAC;SAAM,CAAC;QACJ,MAAM,CAAC,KAAK,CAAC,kGAAkG,CAAC,CAAA;IACpH,CAAC;IACD,IAAI,iBAAiB,EAAE,CAAC;QACpB,oDAAoD;QACpD,OAAO,IAAI,iBAAM,CAAe,YAAE,CAAC,YAAY,CAAC,gBAAgB,CAAC,CAAC,CAAA;IACtE,CAAC;SAAM,CAAC;QACJ,mDAAmD;QACnD,OAAO,SAAS,CAAA;IACpB,CAAC;AACL,CAAC,CAAA;AAzCY,QAAA,qBAAqB,yBAyCjC"}
@@ -0,0 +1 @@
1
+ export { GeoIpLocator } from './GeoIpLocator';
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GeoIpLocator = void 0;
4
+ var GeoIpLocator_1 = require("./GeoIpLocator");
5
+ Object.defineProperty(exports, "GeoIpLocator", { enumerable: true, get: function () { return GeoIpLocator_1.GeoIpLocator; } });
6
+ //# sourceMappingURL=exports.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exports.js","sourceRoot":"","sources":["../../src/exports.ts"],"names":[],"mappings":";;;AAAA,+CAA6C;AAApC,4GAAA,YAAY,OAAA"}
@@ -0,0 +1,3 @@
1
+ /// <reference types="node" />
2
+ import { ReadableStream } from 'stream/web';
3
+ export declare const extractFileFromTarStream: (fileName: string, stream: ReadableStream<any>, downloadFolder: string) => Promise<void>;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.extractFileFromTarStream = void 0;
7
+ const stream_1 = require("stream");
8
+ const tar_1 = __importDefault(require("tar"));
9
+ const path_1 = __importDefault(require("path")); // use NodePath to avoid conflict with other 'path' symbols
10
+ const fs_1 = __importDefault(require("fs"));
11
+ const doExtractFileFromTarStream = (fileName, stream, downloadFolder) => {
12
+ return new Promise((resolve, reject) => {
13
+ try {
14
+ const nodeStream = stream_1.Readable.fromWeb(stream);
15
+ (0, stream_1.pipeline)(nodeStream, tar_1.default.x({
16
+ cwd: downloadFolder,
17
+ filter: (entryPath) => path_1.default.basename(entryPath) === fileName,
18
+ strip: 1
19
+ }), (err) => {
20
+ if (err) {
21
+ reject(new Error('Error extracting tarball to ' + downloadFolder + ', error: ' + err));
22
+ }
23
+ else {
24
+ resolve();
25
+ }
26
+ });
27
+ }
28
+ catch (e) {
29
+ reject(new Error('Failed to create nodejs Readable from web stream: ' + e));
30
+ }
31
+ });
32
+ };
33
+ const extractFileFromTarStream = async (fileName, stream, downloadFolder) => {
34
+ await doExtractFileFromTarStream(fileName, stream, downloadFolder);
35
+ if (!fs_1.default.existsSync(path_1.default.join(downloadFolder, fileName))) {
36
+ throw new Error('File not found in tarball: ' + fileName);
37
+ }
38
+ };
39
+ exports.extractFileFromTarStream = extractFileFromTarStream;
40
+ //# sourceMappingURL=tarHelper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tarHelper.js","sourceRoot":"","sources":["../../src/tarHelper.ts"],"names":[],"mappings":";;;;;;AAAA,mCAA2C;AAC3C,8CAAqB;AAErB,gDAA2B,CAAK,2DAA2D;AAC3F,4CAAmB;AAEnB,MAAM,0BAA0B,GAAG,CAAC,QAAgB,EAAE,MAA2B,EAAE,cAAsB,EAAiB,EAAE;IACxH,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACnC,IAAI,CAAC;YACD,MAAM,UAAU,GAAG,iBAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;YAC3C,IAAA,iBAAQ,EAAC,UAAU,EACf,aAAG,CAAC,CAAC,CAAC;gBACF,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