{"id":31196980,"url":"https://github.com/webpod/ip","last_synced_at":"2025-09-20T05:25:23.956Z","repository":{"id":313750500,"uuid":"1051579860","full_name":"webpod/ip","owner":"webpod","description":"Lite IP tools","archived":false,"fork":false,"pushed_at":"2025-09-15T11:31:06.000Z","size":462,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-15T13:21:05.497Z","etag":null,"topics":["cidr","ip","ip-address","ipv4","ipv6","subnet"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/webpod.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-06T09:42:37.000Z","updated_at":"2025-09-15T11:31:10.000Z","dependencies_parsed_at":"2025-09-08T09:09:44.194Z","dependency_job_id":"5fa97e06-a265-41b8-97db-32724bfe1a3a","html_url":"https://github.com/webpod/ip","commit_stats":null,"previous_names":["webpod/ip"],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/webpod/ip","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webpod%2Fip","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webpod%2Fip/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webpod%2Fip/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webpod%2Fip/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/webpod","download_url":"https://codeload.github.com/webpod/ip/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webpod%2Fip/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275624498,"owners_count":25498580,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-17T02:00:09.119Z","response_time":84,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cidr","ip","ip-address","ipv4","ipv6","subnet"],"created_at":"2025-09-20T05:25:18.296Z","updated_at":"2025-09-20T05:25:23.109Z","avatar_url":"https://github.com/webpod.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @webpod/ip\n\n\u003e Lite IP tools\n\nThis lib is an alternative for the [`ip`](https://www.npmjs.com/package/ip) package which resolves [many upstream issues](https://github.com/indutny/node-ip/issues).\n* Reforged in TypeScript\n* Provides both ESM and CJS entries\n* Exposes browser-compatible `./core`\n* Eliminates annoying vulnerabilities [CVE-2024-29415](https://github.com/advisories/GHSA-2p57-rm9w-gvfp), [CVE-2023-42282](https://github.com/advisories/GHSA-78xj-cgh5-2h22)\n* Brings various fixes, improvements and optimizations\n* [Enterprise ready](https://dev.to/antongolub/cve-2024-29415-problem-solution-3o3f)\n\n## Install\n```shell\nnpm i @webpod/ip\n```\n\n## Drop-in\n```shell\n- const ip = require('ip')\n+ const ip = require('@webpod/ip')\n```\nTemporary workaround to avoid refactoring is using `overrides` / `resolutions` in your `package.json`:\n```json\n{\n  \"overrides\": {\n    \"ip\": \"@webpod/ip\"\n  }\n}\n```\n\nBrowser-compatible core build is available as `@webpod/ip/core`: it omits `node:os` dependency and polyfills the `Buffer` API.\n\n## Usage\nThe API is fully compatible with the latest `ip@2.0.1` but enforces stricter validations. See [coherence.md](./COHERENCE.md) for details.\n\n```ts\nimport ip from '@webpod/ip'\n\n// -------------------------------------------------------\n// Addresses \u0026 formats\n// -------------------------------------------------------\n\nip.address()                              // '192.168.1.50'  (example local address)\nip.isPrivate('127.0.0.1')                 // true\nip.isV4Format('127.0.0.1')                // true\nip.isV6Format('::ffff:127.0.0.1')         // true\nip.isEqual('::1', '::0:1')                // true\n\n// -------------------------------------------------------\n// Conversions\n// -------------------------------------------------------\n\nip.toBuffer('127.0.0.1')                  // \u003cBuffer 7f 00 00 01\u003e\nip.toString(Buffer.from([127, 0, 0, 1]))  // '127.0.0.1'\n\nip.toLong('127.0.0.1')                    // 2130706433\nip.fromLong(2130706433)                   // '127.0.0.1'\n\nip.fromPrefixLen(24)                      // '255.255.255.0'\n\n// in-place buffer usage\nconst buf = Buffer.alloc(128)\nconst offset = 64\nip.toBuffer('127.0.0.1', buf, offset)     // writes [127, 0, 0, 1] at offset 64\nip.toString(buf, offset, 4)               // '127.0.0.1'\n\n// -------------------------------------------------------\n// Masking, bitwise, and ranges\n// -------------------------------------------------------\n\nip.mask('192.168.1.134', '255.255.255.0') // '192.168.1.0'\nip.cidr('192.168.1.134/26')               // '192.168.1.128'\nip.not('255.255.255.0')                   // '0.0.0.255'\nip.or('192.168.1.134', '0.0.0.255')       // '192.168.1.255'\n\n// -------------------------------------------------------\n// Subnets\n// -------------------------------------------------------\n\nip.subnet('192.168.1.134', '255.255.255.192')\n/*\n{\n  networkAddress:   '192.168.1.128',\n  firstAddress:     '192.168.1.129',\n  lastAddress:      '192.168.1.190',\n  broadcastAddress: '192.168.1.191',\n  subnetMask:       '255.255.255.192',\n  subnetMaskLength: 26,\n  numHosts:         62,\n  length:           64,\n  contains: [Function: contains]\n}\n*/\n\nip.cidrSubnet('192.168.1.134/26').contains('192.168.1.190') // true\n```\n\n### Address class\n```ts\nimport { Address } from '@webpod/ip'\n\n// -------------------------------------------------------\n// Prototype methods\n// -------------------------------------------------------\n\nconst addr4 = Address.from('192.168.1.134')\n\naddr4.family        // 4\naddr4.big           // 323223590n\naddr4.toString()    // '192.168.1.134'\naddr4.toLong()      // 323223590\naddr4.toBuffer()    // \u003cBuffer c0 a8 01 86\u003e\naddr4.toArray()     // [192, 168, 1, 134]\n\nconst addr6 = Address.from('::1')\n\naddr6.family        // 6\naddr6.big           // 1n\naddr6.toString()    // '::1'\naddr6.toString(4)   // '0.0.0.1'\naddr6.toBuffer().toString('hex') // '00000000000000000000000000000001'\n\n// -------------------------------------------------------\n// Specific ranges check\n// -------------------------------------------------------\n\nAddress.from('127.0.0.1').range                   // 'loopback'\nAddress.from('192.0.2.10').range                  // 'documentation'\n\nAddress.isSpecial('127.0.0.1')                    // true\nAddress.isSpecial('127.0.0.1', 'loopback')        // true\nAddress.isSpecial('127.0.0.1', 'documentation')   // false\nAddress.isSpecial('1.2.3.4')                      // false\n```\n\n## License\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebpod%2Fip","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwebpod%2Fip","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebpod%2Fip/lists"}