Installations
npm install mmdb-lib
Developer Guide
Typescript
No
Module System
CommonJS
Min. Node Version
>=10
Node Version
20.13.1
NPM Version
10.8.0
Score
99.2
Supply Chain
93.3
Quality
76.8
Maintenance
100
Vulnerability
100
License
Releases
Contributors
Unable to fetch Contributors
Languages
TypeScript (98.6%)
JavaScript (1.4%)
Developer
runk
Download Statistics
Total Downloads
19,452,120
Last Day
10,339
Last Week
110,386
Last Month
615,136
Last Year
6,224,558
GitHub Statistics
28 Stars
270 Commits
10 Forks
5 Watching
7 Branches
5 Contributors
Bundle Size
8.60 kB
Minified
3.15 kB
Minified + Gzipped
Package Meta Information
Latest Version
2.1.1
Package Id
mmdb-lib@2.1.1
Unpacked Size
33.65 kB
Size
10.22 kB
File Count
19
NPM Version
10.8.0
Node Version
20.13.1
Publised On
29 May 2024
Total Downloads
Cumulative downloads
Total Downloads
19,452,120
Last day
-71.2%
10,339
Compared to previous day
Last week
-28%
110,386
Compared to previous week
Last month
8.2%
615,136
Compared to previous month
Last year
16.1%
6,224,558
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
mmdb-lib
Javascript library for working with Maxmind binary databases (aka mmdb or geoip2).
Library is designed to be agnostic to environment and works equally well in node.js and browser. Module is fully compatible with IPv6. There are no differences in API between IPv4 and IPv6.
Installation
1npm i mmdb-lib
Usage
1import fs from 'fs'; 2import * as mmdb from 'mmdb-lib'; 3 4// Get a buffer with mmdb database, from file system or whereever. 5const db = fs.readFileSync('/path/to/GeoLite2-City.mmdb'); 6 7const reader = new mmdb.Reader<CityResponse>(db); 8console.log(reader.get('66.6.44.4')); // inferred type `CityResponse` 9console.log(reader.getWithPrefixLength('66.6.44.4')); // tuple with inferred type `[CityResponse|null, number]`
Supported response types:
- CountryResponse
- CityResponse
- AnonymousIPResponse
- AsnResponse
- ConnectionTypeResponse
- DomainResponse
- IspResponse
Usage in browser-like environments
Library expects to receive an instance of Buffer
during instantiation of Reader
. Since there is no direct alternative of node's Buffer
in browser, you can use https://github.com/feross/buffer that mimics native Buffer
interface. Neither ArrayBuffer
nor Uint8Array
is supported right now. Another requirement is BigInt object available.
Options
Reader(db:Buffer, [options])
options
:<Object>
cache
:<Object>
Cache helper. tiny-lru is great basic option. Only two methods expected:get(key: string | number): any
andset(key: string | number, val: any): void
.
References
- Loosely based on https://github.com/PaddeK/node-maxmind-db
- MaxMind DB file format specification http://maxmind.github.io/MaxMind-DB/
- MaxMind test/sample DB files https://github.com/maxmind/MaxMind-DB
- GeoLite2 Free Downloadable Databases http://dev.maxmind.com/geoip/geoip2/geolite2/
- Great talk about V8 performance https://www.youtube.com/watch?v=UJPdhx5zTaw
- V8 Optimization killers https://github.com/petkaantonov/bluebird/wiki/Optimization-killers
- More V8 performance tips http://www.html5rocks.com/en/tutorials/speed/v8/
License
MIT
Contributing
All contributions are welcome. Please make sure to add tests for your changes.
You need to initialise the repository with the following command:
1git submodule update --init --recursive
Then you can run tests with:
1npm test
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
15 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 10
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
packaging workflow detected
Details
- Info: Project packages its releases by way of GitHub Actions.: .github/workflows/release.yml:7
Reason
Found 0/15 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/build.yml:1
- Warn: no topLevel permission defined: .github/workflows/release.yml:1
- Info: no jobLevel write permissions found
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/runk/mmdb-lib/build.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build.yml:22: update your workflow using https://app.stepsecurity.io/secureworkflow/runk/mmdb-lib/build.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:12: update your workflow using https://app.stepsecurity.io/secureworkflow/runk/mmdb-lib/release.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/runk/mmdb-lib/release.yml/master?enable=pin
- Warn: npmCommand not pinned by hash: .github/workflows/build.yml:26
- Warn: npmCommand not pinned by hash: .github/workflows/release.yml:21
- Info: 0 out of 4 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 2 npmCommand dependencies pinned
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 30 are checked with a SAST tool
Score
5.2
/10
Last Scanned on 2024-12-16
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More