@streamr/geoip-location 102.0.0-beta.0 → 102.0.0-beta.2

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.
@@ -83,7 +83,7 @@ class GeoIpLocator {
83
83
  return undefined;
84
84
  }
85
85
  const result = this.reader.get(ip);
86
- if (!result || !result.location || !result.location.latitude || !result.location.longitude) {
86
+ if (!result?.location?.latitude || !result.location.longitude) {
87
87
  return undefined;
88
88
  }
89
89
  else {
@@ -1 +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,GAAG,IAAI,eAAe,EAAE,CAAA;QAC5C,IAAI,CAAC,eAAe,GAAG,eAAe,CAAA;QACtC,IAAI,CAAC,oBAAoB,GAAG,oBAAoB,CAAA;QAChD,IAAI,CAAC,mBAAmB,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YACrC,mBAAmB,IAAI,GAAG,CAAA;QAC9B,CAAC;QACD,IAAI,CA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CAAC,IAAI,CAAC,cAAc,CAAC,CAAA;QACjD,CAAC;QACD,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,CAAA;IAChC,CAAC;IAED,MAAM,CAAC,EAAU;QACb,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YAC5B,MAAM,CAAC,IAAI,CAAC,qFAAqF,CAAC,CAAA;YAClG,OAAO,SAAS,CAAA;QACpB,CAAC;QAED,yCAAyC;QACzC,mEAAmE;QACnE,+DAA+D;QAC/D,IAAI,CAAC,EAAE,EAAE,CAAC;YACN,OAAO,SAAS,CAAA;QACpB,CAAC;QAED,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;QAClC,IAAI,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,EAAE,CAAC;YAC5D,OAAO,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"}
@@ -1,3 +1,2 @@
1
- /// <reference types="node" />
2
1
  import { CityResponse, Reader } from 'mmdb-lib';
3
2
  export declare const downloadGeoIpDatabase: (dbFolder: string, forceReturnReader: boolean, abortSignal: AbortSignal, mirrorUrl?: string) => Promise<Reader<CityResponse> | undefined>;
@@ -1,3 +1,2 @@
1
- /// <reference types="node" />
2
1
  import { ReadableStream } from 'stream/web';
3
2
  export declare const extractFileFromTarStream: (fileName: string, stream: ReadableStream<any>, downloadFolder: string) => Promise<void>;
package/jest.config.ts ADDED
@@ -0,0 +1 @@
1
+ export { default } from '../../jest.config'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@streamr/geoip-location",
3
- "version": "102.0.0-beta.0",
3
+ "version": "102.0.0-beta.2",
4
4
  "description": "Library for getting location information from IP addresses based on MaxMind GeoLite2 databases",
5
5
  "repository": {
6
6
  "type": "git",
@@ -25,16 +25,16 @@
25
25
  "test-unit": "jest test/unit"
26
26
  },
27
27
  "dependencies": {
28
- "@streamr/utils": "102.0.0-beta.0",
28
+ "@streamr/utils": "102.0.0-beta.2",
29
29
  "eventemitter3": "^5.0.0",
30
30
  "long-timeout": "^0.1.1",
31
31
  "mmdb-lib": "^2.1.1",
32
32
  "tar": "^7.4.3",
33
- "uuid": "^10.0.0"
33
+ "uuid": "^11.0.5"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@types/long-timeout": "^0.1.2",
37
37
  "@types/tar": "^6.1.11",
38
- "express": "^4.21.1"
38
+ "express": "^4.21.2"
39
39
  }
40
40
  }
@@ -97,7 +97,7 @@ export class GeoIpLocator {
97
97
  }
98
98
 
99
99
  const result = this.reader.get(ip)
100
- if (!result || !result.location || !result.location.latitude || !result.location.longitude) {
100
+ if (!result?.location?.latitude || !result.location.longitude) {
101
101
  return undefined
102
102
  } else {
103
103
  return {
@@ -1,5 +1,5 @@
1
1
  import { GeoIpLocator } from '../../src/GeoIpLocator'
2
- import { wait, waitForCondition } from '@streamr/utils'
2
+ import { wait, until } from '@streamr/utils'
3
3
  import fs from 'fs'
4
4
  import { TestServer } from '../helpers/TestServer'
5
5
 
@@ -94,14 +94,14 @@ describe('GeoIpLocator', () => {
94
94
  expect(fetchMock2).toHaveBeenCalledTimes(2)
95
95
 
96
96
  // expect the db to be there
97
- await waitForCondition(() => fs.existsSync(dbDir + '/' + DB_FILENAME), 10000)
97
+ await until(() => fs.existsSync(dbDir + '/' + DB_FILENAME), 10000)
98
98
 
99
- // suomi.fi
100
- const location = locator.lookup('62.241.198.245')
99
+ // helsinki.fi
100
+ const location = locator.lookup('128.214.222.50')
101
101
  expect(location).toBeDefined()
102
102
 
103
103
  // Helsinki, Finland
104
- expect(location!.latitude).toBe(60.1797)
105
- expect(location!.longitude).toBe(24.9344)
104
+ expect(location!.latitude).toBe(60.1719)
105
+ expect(location!.longitude).toBe(24.9347)
106
106
  }, 60000)
107
107
  })
@@ -43,13 +43,13 @@ describe('GeoIpLocatorNoNetworkAtMonthly', () => {
43
43
 
44
44
  fetchMock.mockRestore()
45
45
 
46
- // suomi.fi
47
- const location = locator!.lookup('62.241.198.245')
46
+ // helsinki.fi
47
+ const location = locator!.lookup('128.214.222.50')
48
48
  expect(location).toBeDefined()
49
49
 
50
50
  // Helsinki, Finland
51
- expect(location!.latitude).toBe(60.1797)
52
- expect(location!.longitude).toBe(24.9344)
51
+ expect(location!.latitude).toBe(60.1719)
52
+ expect(location!.longitude).toBe(24.9347)
53
53
 
54
54
  }, 60000)
55
55
  })
@@ -33,14 +33,14 @@ describe('GeoIpLocator', () => {
33
33
  locator = new GeoIpLocator(dbDir, 5000, 5000, serverUrl)
34
34
  await locator.start()
35
35
 
36
- // suomi.fi
37
- const location = locator.lookup('62.241.198.245')
36
+ // helsinki.fi
37
+ const location = locator.lookup('128.214.222.50')
38
38
 
39
39
  expect(location).toBeDefined()
40
40
 
41
41
  // Helsinki, Finland
42
- expect(location!.latitude).toBe(60.1797)
43
- expect(location!.longitude).toBe(24.9344)
42
+ expect(location!.latitude).toBe(60.1719)
43
+ expect(location!.longitude).toBe(24.9347)
44
44
 
45
45
  locator.stop()
46
46
  fs.unlinkSync(dbDir + '/GeoLite2-City.mmdb')
@@ -70,13 +70,13 @@ describe('GeoIpLocator', () => {
70
70
 
71
71
  await wait(7000)
72
72
 
73
- // suomi.fi
74
- const location = locator.lookup('62.241.198.245')
73
+ // helsinki.fi
74
+ const location = locator.lookup('128.214.222.50')
75
75
  expect(location).toBeDefined()
76
76
 
77
77
  // Helsinki, Finland
78
- expect(location!.latitude).toBe(60.1797)
79
- expect(location!.longitude).toBe(24.9344)
78
+ expect(location!.latitude).toBe(60.1719)
79
+ expect(location!.longitude).toBe(24.9347)
80
80
 
81
81
  locator.stop()
82
82
  fs.unlinkSync(dbDir + '/GeoLite2-City.mmdb')
@@ -92,13 +92,13 @@ describe('GeoIpLocator', () => {
92
92
 
93
93
  await wait(10000)
94
94
 
95
- // suomi.fi
96
- const location = locator.lookup('62.241.198.245')
95
+ // helsinki.fi
96
+ const location = locator.lookup('128.214.222.50')
97
97
  expect(location).toBeDefined()
98
98
 
99
99
  // Helsinki, Finland
100
- expect(location!.latitude).toBe(60.1797)
101
- expect(location!.longitude).toBe(24.9344)
100
+ expect(location!.latitude).toBe(60.1719)
101
+ expect(location!.longitude).toBe(24.9347)
102
102
 
103
103
  locator.stop()
104
104
  fs.unlinkSync(dbDir + '/GeoLite2-City.mmdb')
@@ -110,7 +110,7 @@ describe('GeoIpLocator', () => {
110
110
  it('returns undefined if not started', async () => {
111
111
  const dbDir = getDbDir()
112
112
  const locator = new GeoIpLocator(dbDir)
113
- const location = locator.lookup('62.241.198.245')
113
+ const location = locator.lookup('128.214.222.50')
114
114
  expect(location).toBeUndefined()
115
115
  })
116
116
 
package/.eslintignore DELETED
@@ -1,4 +0,0 @@
1
- node_modules/**
2
- dist/**
3
- .idea/**
4
- src/proto/**
package/.eslintrc DELETED
@@ -1,3 +0,0 @@
1
- {
2
- "extends": "../../.eslintrc.js"
3
- }
package/jest.config.js DELETED
@@ -1,2 +0,0 @@
1
- const rootConfig = require('../../jest.config')
2
- module.exports = rootConfig