{"analyzedAt":"2022-11-09T08:18:26.770Z","collected":{"metadata":{"name":"ipfs-geoip","scope":"unscoped","version":"9.0.1","description":"Library for ipfs geoip lookups","keywords":["ipfs","geoip"],"date":"2022-11-08T17:07:41.596Z","author":{"name":"Kristoffer Ström","email":"kristoffer@rymdkoloni.se"},"publisher":{"username":"npm-service-account-ipfs-shipyard","email":"npm-service-account+ipfs-shipyard@protocol.ai"},"maintainers":[{"username":"daviddias","email":"mail@daviddias.me"},{"username":"hacdias","email":"hacdias@gmail.com"},{"username":"lidel","email":"lidel@lidel.org"},{"username":"npm-service-account-ipfs-shipyard","email":"npm-service-account+ipfs-shipyard@protocol.ai"}],"contributors":[{"name":"Marcin Rataj","email":"lidel@lidel.org"},{"name":"Friedel Ziegelmayer","email":"dignifiedquire@gmail.com"},{"name":"Kristoffer Ström","email":"kristoffer@rymdkoloni.se"},{"name":"David Dias","email":"daviddias.p@gmail.com"},{"name":"Henrique Dias","email":"hacdias@gmail.com"},{"name":"Oli Evans","email":"oli@tableflip.io"},{"name":"Ali Mirlou","email":"alimirlou@gmail.com"},{"name":"Andrew Nesbitt","email":"andrewnez@gmail.com"},{"name":"Jessica Schilling","email":"jessica@protocol.ai"},{"name":"Raúl Kripalani","email":"raul.kripalani@gmail.com"},{"name":"Richard Littauer","email":"richard.littauer@gmail.com"},{"name":"nijynot","email":"nijynot@gmail.com"}],"repository":{"type":"git","url":"git+https://github.com/ipfs-shipyard/ipfs-geoip.git"},"links":{"npm":"https://www.npmjs.com/package/ipfs-geoip","homepage":"https://github.com/ipfs-shipyard/ipfs-geoip","repository":"https://github.com/ipfs-shipyard/ipfs-geoip","bugs":"https://github.com/ipfs-shipyard/ipfs-geoip/issues"},"license":"MIT","devDependencies":{"@ipld/car":"^4.1.5","@ipld/dag-cbor":"^7.0.3","aegir":"^37.5.4","bluebird":"^3.7.2","chai-as-promised":"^7.1.1","chai":"^4.3.6","cross-fetch":"^3.1.5","csv-parse":"^5.3.0","esmock":"^2.0.6","gauge":"^4.0.4","ip":"^2.0.0","ipfs-http-client":"^58.0.1","it-concat":"^2.0.0","lodash-es":"^4.17.21","multiformats":"^9.9.0","multihashes":"^4.0.3","p-memoize":"^7.1.0","pre-commit":"^1.2.2","uint8arrays":"^3.1.0"},"releases":[{"from":"2022-10-10T00:00:00.000Z","to":"2022-11-09T00:00:00.000Z","count":3},{"from":"2022-08-11T00:00:00.000Z","to":"2022-11-09T00:00:00.000Z","count":3},{"from":"2022-05-13T00:00:00.000Z","to":"2022-11-09T00:00:00.000Z","count":4},{"from":"2021-11-09T00:00:00.000Z","to":"2022-11-09T00:00:00.000Z","count":4},{"from":"2020-11-09T00:00:00.000Z","to":"2022-11-09T00:00:00.000Z","count":5}],"hasTestScript":true,"hasSelectiveFiles":true,"readme":"# IPFS GeoIP\n\n[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://ipn.io)\n[![](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io/)\n[![](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs)\n[![standard-readme compliant](https://img.shields.io/badge/standard--readme-OK-green.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme)\n[![Dependency Status](https://david-dm.org/ipfs/ipfs-geoip.svg?style=flat-square)](https://david-dm.org/ipfs/ipfs-geoip)\n[![Travis CI](https://img.shields.io/travis/ipfs-shipyard/ipfs-geoip/master.svg?style=flat-square)](https://travis-ci.org/ipfs-shipyard/ipfs-geoip)\n[![](https://data.jsdelivr.com/v1/package/npm/ipfs-geoip/badge)](https://www.jsdelivr.com/package/npm/ipfs-geoip)\n[![Coverage Status](https://coveralls.io/repos/github/ipfs/ipfs-geoip/badge.svg?branch=master)](https://coveralls.io/github/ipfs/ipfs-geoip?branch=master)\n\n> GeoIP lookup over IPFS\n\n\n# Table of Contents\n\n- [IPFS GeoIP](#ipfs-geoip)\n- [Table of Contents](#table-of-contents)\n  - [Install](#install)\n    - [NPM](#npm)\n    - [CDN](#cdn)\n  - [Usage](#usage)\n  - [API](#api)\n    - [`lookup(ipfs, ip)`](#lookupipfs-ip)\n    - [`lookupPretty(ipfs, multiaddrs)`](#lookupprettyipfs-multiaddrs)\n  - [Maintenance](#maintenance)\n    - [CIDs of the lookup dataset](#cids-of-the-lookup-dataset)\n    - [Updating GeoLite2 dataset](#updating-geolite2-dataset)\n  - [Testing in CLI](#testing-in-cli)\n  - [Contribute](#contribute)\n    - [Want to hack on IPFS?](#want-to-hack-on-ipfs)\n  - [License](#license)\n\n## Install\n\n### NPM\n\n\n```js\nnpm install --save ipfs-geoip\n```\n\n### CDN\n\nInstead of a local installation (and browserification) you may request a specific\nversion `N.N.N` as a [remote copy from jsDelivr](https://www.jsdelivr.com/package/npm/ipfs-geoip):\n\n```html\n<script type=\"module\">\n  import { lookup } from 'https://cdn.jsdelivr.net/npm/ipfs-geoip@N.N.N/dist/index.min.js';\n  const gateway = 'https://ipfs.io'\n  console.log(await lookup(gateway, '66.6.44.4'))\n</script>\n```\n\nThe response in the console should look similar to:\n```js\n{\n    \"country_name\": \"USA\",\n    \"country_code\": \"US\",\n    \"region_code\": \"VA\",\n    \"city\": \"Ashburn\",\n    \"postal_code\": \"20149\",\n    \"latitude\": 39.0469,\n    \"longitude\": -77.4903,\n    \"planet\": \"Earth\"\n}\n```\n\n## Usage\n\n### With public gateways (default)\n\nIf `gateways` is a string or array of strings with public gateway URLs, it will be used for\nfetching IPFS blocks as [`application/vnd.ipld.raw`](https://www.iana.org/assignments/media-types/application/vnd.ipld.raw)\nand parsing them as DAG-CBOR locally via [@ipld/dag-cbor](https://www.npmjs.com/package/@ipld/dag-cbor):\n\n```js\nconst geoip = require('ipfs-geoip')\nconst exampleIp = '66.6.44.4'\n\nconst gateways = ['https://ipfs.io', 'https://dweb.link']\n\ntry {\n  const result = await geoip.lookup(gateways, exampleIp)\n  console.log('Result: ', result)\n} catch (err) {\n  console.log('Error: ' + err)\n}\n\ntry {\n  const result = await geoip.lookupPretty(gateways, '/ip4/' + exampleIp)\n  console.log('Pretty result: %s', result.formatted)\n} catch (err) {\n  console.log('Error: ' + err)\n}\n```\n\n### With custom block getter function\n\nIt is also possible to use it with local or remote IPFS node by passing block getter function, e.g., one that exposes\n[`ipfs.block.get` Core JS API](https://github.com/ipfs/js-ipfs/blob/master/docs/core-api/BLOCK.md#ipfsblockgetcid-options):\n\n```js\nconst geoip = require('ipfs-geoip')\nconst exampleIp = '66.6.44.4'\n\nconst ipfs = require('ipfs-http-client')()\n\ntry {\n  const getBlock = (cid) => ipfs.block.get(cid)\n  const result = await geoip.lookup(getBlock, exampleIp)\n  console.log('Result: ', result)\n} catch (err) {\n  console.log('Error: ' + err)\n}\n```\n\n## API\n\n### `lookup(ipfs, ip)`\n\nReturns a promise that resolves to an object of the form\n\n```js\n{\n  \"country_code\": \"US\",\n  \"country_name\": \"USA\",\n  \"region_code\": \"CA\",\n  \"city\": \"Mountain View\",\n  \"postal_code\": \"94040\",\n  \"latitude\": 37.3860,\n  \"longitude\": -122.0838,\n  \"planet\": \"Earth\"\n}\n```\n\n### `lookupPretty(ipfs, multiaddrs)`\n\nProvides the same results as `lookup` with the addition of\na `formatted` property that looks like this: `Mountain View, CA, United States, Earth`.\n\n## Maintenance\n\n### CIDs of the lookup dataset\n\nThe current root hash for lookups is defined under `GEOIP_ROOT` in `src/lookup.js`.\n\nIt is a proprietary b-tree generated from source files provided defined under `DATA_HASH` in `src/generate/index.js`.\n\n### Updating GeoLite2 dataset\n\nThere is a generator included, that can be run with\n\n```bash\n$ npm run generate\n```\n\nThis takes quite a long time to import, but you only need to do it once when updating the global index used by the lookup feature.\n\nIt reads original GeoLite CSV files provided from `DATA_HASH` directory defined\nin `src/generate/index.js`, and turns them into a 32-way branching b-tree\nof [DAG-CBOR](https://ipld.io/specs/codecs/dag-cbor/spec/) objects.\n\nThe tree is saved as `ipfs-geoip.car` and the root CID is printed to the\nterminal. It should then be imported to IPFS and the root CID should be pinned\nin multiple locations,  and stored as the new `GEOIP_ROOT` in `src/lookup.js`\n\n> 👉 this library uses [`dag-cbor`](https://ipld.io/specs/codecs/dag-cbor/spec/)\n> and reads raw blocks via [`ipfs.block` RPC](https://github.com/ipfs/js-ipfs/blob/master/docs/core-api/BLOCK.md),\n> but could be refactored to fetch blocks as [`application/vnd.ipld.raw`](https://www.iana.org/assignments/media-types/application/vnd.ipld.raw)\n> from a regular [HTTP Gateway](https://docs.ipfs.tech/reference/http/gateway/).\n\n\n## Testing in CLI\n\nIt is possible to run tests against a local gateway by passing `IPFS_GATEWAY`:\n\n```console\n$ IPFS_GATEWAY=\"http://127.0.0.1:8080\" npm test\n```\n\nYou can find an example of how to use this in [`example/lookup.js`](example/lookup.js), which you can use like this:\n\n```bash\n$ export IPFS_GATEWAY=\"http://127.0.0.1:8080\"\n$ node example/lookup.js 66.6.44.4\nResult: {\n  \"country_name\": \"USA\",\n  \"country_code\": \"US\",\n  \"region_code\": \"NY\",\n  \"city\": \"New York\",\n  \"postal_code\": \"10004\",\n  \"latitude\": 40.7126,\n  \"longitude\": -74.0066,\n  \"planet\": \"Earth\"\n}\nPretty result: New York, NY, USA, Earth\n```\n\n\n## Contribute\n\nFeel free to join in. All welcome. Open an [issue](https://github.com/ipfs/ipfs-geoip/issues)!\n\nThis repository falls under the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md).\n\n### Want to hack on IPFS?\n\n[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md)\n\n## License\n\nipfs-geoip is [MIT](LICENSE) licensed.\n\nThis library includes GeoLite2 data created by MaxMind, available from [maxmind.com](http://www.maxmind.com)."},"npm":{"downloads":[{"from":"2022-11-08T00:00:00.000Z","to":"2022-11-09T00:00:00.000Z","count":58},{"from":"2022-11-02T00:00:00.000Z","to":"2022-11-09T00:00:00.000Z","count":203},{"from":"2022-10-10T00:00:00.000Z","to":"2022-11-09T00:00:00.000Z","count":760},{"from":"2022-08-11T00:00:00.000Z","to":"2022-11-09T00:00:00.000Z","count":1703},{"from":"2022-05-13T00:00:00.000Z","to":"2022-11-09T00:00:00.000Z","count":2956},{"from":"2021-11-09T00:00:00.000Z","to":"2022-11-09T00:00:00.000Z","count":5783}],"starsCount":0},"github":{"starsCount":61,"forksCount":22,"subscribersCount":31,"issues":{"count":102,"openCount":5,"distribution":{"3600":12,"10800":3,"32400":7,"97200":3,"291600":7,"874800":12,"2624400":18,"7873200":12,"23619600":9,"70858800":14,"212576400":5},"isDisabled":false},"contributors":[{"username":"lidel","commitsCount":35},{"username":"dignifiedquire","commitsCount":16},{"username":"krl","commitsCount":14},{"username":"daviddias","commitsCount":7},{"username":"olizilla","commitsCount":4},{"username":"hacdias","commitsCount":4},{"username":"whizzzkid","commitsCount":2},{"username":"RichardLitt","commitsCount":1},{"username":"nijynot","commitsCount":1},{"username":"AliMirlou","commitsCount":1},{"username":"andrew","commitsCount":1},{"username":"jessicaschilling","commitsCount":1},{"username":"raulk","commitsCount":1},{"username":"Gozala","commitsCount":1},{"username":"SgtPooki","commitsCount":1},{"username":"web3-bot","commitsCount":1},{"username":"semantic-release-bot","commitsCount":1}],"commits":[{"from":"2022-11-02T00:00:00.000Z","to":"2022-11-09T00:00:00.000Z","count":3},{"from":"2022-10-10T00:00:00.000Z","to":"2022-11-09T00:00:00.000Z","count":9},{"from":"2022-08-11T00:00:00.000Z","to":"2022-11-09T00:00:00.000Z","count":9},{"from":"2022-05-13T00:00:00.000Z","to":"2022-11-09T00:00:00.000Z","count":13},{"from":"2021-11-09T00:00:00.000Z","to":"2022-11-09T00:00:00.000Z","count":14}]},"source":{"files":{"readmeSize":6896,"testsSize":7270,"hasNpmIgnore":true,"hasChangelog":true},"badges":[{"urls":{"original":"https://david-dm.org/ipfs/ipfs-geoip.svg?style=flat-square","service":"https://david-dm.org/ipfs/ipfs-geoip.svg","shields":"https://img.shields.io/david/ipfs/ipfs-geoip.svg","content":"https://img.shields.io/david/ipfs/ipfs-geoip.json"},"info":{"service":"david","type":"dependencies","modifiers":{"statusType":"normal"}}},{"urls":{"original":"https://img.shields.io/travis/ipfs-shipyard/ipfs-geoip/master.svg?style=flat-square","service":"https://api.travis-ci.org/ipfs-shipyard/ipfs-geoip.svg?branch=master","shields":"https://img.shields.io/travis/ipfs-shipyard/ipfs-geoip/master.svg","content":"https://img.shields.io/travis/ipfs-shipyard/ipfs-geoip/master.json"},"info":{"service":"travis","type":"build","modifiers":{"branch":"master"}}},{"urls":{"original":"https://coveralls.io/repos/github/ipfs/ipfs-geoip/badge.svg?branch=master","service":"https://coveralls.io/repos/github/ipfs/ipfs-geoip/badge.svg?branch=master","shields":"https://img.shields.io/coveralls/ipfs/ipfs-geoip/master.svg","content":"https://img.shields.io/coveralls/ipfs/ipfs-geoip/master.json"},"info":{"service":"coveralls","type":"coverage","modifiers":{"branch":"master"}}}],"linters":["editorconfig","eslint"],"coverage":0.82}},"evaluation":{"quality":{"carefulness":0.9999999999999999,"tests":0.723,"health":1,"branding":0.44999999999999996},"popularity":{"communityInterest":131,"downloadsCount":567.6666666666666,"downloadsAcceleration":2.51697108066971,"dependentsCount":0},"maintenance":{"releasesFrequency":1,"commitsFrequency":0.9,"openIssues":1,"issuesDistribution":0.9}},"score":{"final":0.6501914558889192,"detail":{"quality":0.886544924287412,"popularity":0.09788784127161526,"maintenance":0.9999063833075152}}}