{"id":13482568,"url":"https://github.com/libp2p/js-peer-info","last_synced_at":"2025-03-27T13:32:11.603Z","repository":{"id":34799229,"uuid":"38784179","full_name":"libp2p/js-peer-info","owner":"libp2p","description":"libp2p Peer abstraction Node.js implementation","archived":true,"fork":false,"pushed_at":"2020-06-12T09:48:31.000Z","size":1504,"stargazers_count":37,"open_issues_count":7,"forks_count":28,"subscribers_count":21,"default_branch":"master","last_synced_at":"2025-01-19T18:02:31.441Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://libp2p.io","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/libp2p.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}},"created_at":"2015-07-08T22:49:06.000Z","updated_at":"2023-01-28T10:22:13.000Z","dependencies_parsed_at":"2022-09-15T10:01:21.143Z","dependency_job_id":null,"html_url":"https://github.com/libp2p/js-peer-info","commit_stats":null,"previous_names":["diasdavid/node-ipfs-peer","diasdavid/node-peer-info"],"tags_count":49,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libp2p%2Fjs-peer-info","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libp2p%2Fjs-peer-info/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libp2p%2Fjs-peer-info/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libp2p%2Fjs-peer-info/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/libp2p","download_url":"https://codeload.github.com/libp2p/js-peer-info/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245854531,"owners_count":20683371,"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","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":[],"created_at":"2024-07-31T17:01:03.331Z","updated_at":"2025-03-27T13:32:11.269Z","avatar_url":"https://github.com/libp2p.png","language":"JavaScript","funding_links":[],"categories":["Modules"],"sub_categories":[],"readme":"⛔️ DEPRECATED: peer-info is not used anymore in favour of storing this data in the [PeerStore](https://github.com/libp2p/js-libp2p/tree/master/src/peer-store) from [libp2p@0.28.0](https://github.com/libp2p/js-libp2p/releases/tag/v0.28.0).\n======\n\n# js-peer-info\n\n[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://protocol.ai)\n[![](https://img.shields.io/badge/project-libp2p-yellow.svg?style=flat-square)](http://libp2p.io/)\n[![](https://img.shields.io/badge/freenode-%23libp2p-yellow.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23libp2p)\n[![Discourse posts](https://img.shields.io/discourse/https/discuss.libp2p.io/posts.svg)](https://discuss.libp2p.io)\n[![](https://img.shields.io/codecov/c/github/libp2p/js-peer-info.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-peer-info)\n[![](https://img.shields.io/travis/libp2p/js-peer-info.svg?style=flat-square)](https://travis-ci.com/libp2p/js-peer-info)\n[![Dependency Status](https://david-dm.org/libp2p/js-peer-info.svg?style=flat-square)](https://david-dm.org/libp2p/js-peer-info)\n[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard)\n![](https://img.shields.io/badge/npm-%3E%3D3.0.0-orange.svg?style=flat-square)\n![](https://img.shields.io/badge/Node.js-%3E%3D6.0.0-orange.svg?style=flat-square)\n\n## Lead Maintainer\n\n[Vasco Santos](https://github.com/vasco-santos)\n\n## Table of Contents\n\n- [js-peer-info](#js-peer-info)\n  - [Lead Maintainer](#lead-maintainer)\n  - [Table of Contents](#table-of-contents)\n  - [Installation](#installation)\n    - [npm](#npm)\n    - [Node.JS, Browserify, Webpack](#nodejs-browserify-webpack)\n    - [Browser: `\u003cscript\u003e` Tag](#browser-script-tag)\n  - [Usage](#usage)\n  - [API](#api)\n    - [`PeerInfo.create([id])`](#peerinfocreateid)\n    - [`new PeerInfo(id)`](#new-peerinfoid)\n    - [`.id`](#id)\n    - [`protocols`](#protocols)\n    - [`.protocols.add(protocol)`](#protocolsaddprotocol)\n    - [`.protocols.delete(protocol)`](#protocolsdeleteprotocol)\n    - [`.multiaddrs`](#multiaddrs)\n    - [`.multiaddrs.add(addr)`](#multiaddrsaddaddr)\n    - [`.multiaddrs.addSafe(addr)`](#multiaddrsaddsafeaddr)\n    - [`.multiaddrs.delete(addr)`](#multiaddrsdeleteaddr)\n    - [`.multiaddrs.replace(existing, fresh)`](#multiaddrsreplaceexisting-fresh)\n    - [`.connect(ma)`](#connectma)\n    - [`.disconnect()`](#disconnect)\n    - [`.isConnected()`](#isconnected)\n  - [Contribute](#contribute)\n  - [License](#license)\n\n## Installation\n\n### npm\n\n```sh\n\u003e npm i peer-info\n```\n\n### Node.JS, Browserify, Webpack\n\n```js\nconst PeerInfo = require('peer-info')\n```\n\n### Browser: `\u003cscript\u003e` Tag\n\nLoading this module through a script tag will make the `PeerInfo` obj available in the global namespace.\n\n```html\n\u003cscript src=\"https://unpkg.com/peer-info/dist/index.min.js\"\u003e\u003c/script\u003e\n\u003c!-- OR --\u003e\n\u003cscript src=\"https://unpkg.com/peer-info/dist/index.js\"\u003e\u003c/script\u003e\n```\n\n## Usage\n\n```js\nconst PeerInfo = require('peer-info')\nconst peer = new PeerInfo()\n\n// TCP port 5001\npeer.multiaddrs.add('/ip4/1.2.3.4/tcp/5001')\n\n// UDP port 8001\npeer.multiaddrs.add('/ip4/1.2.3.4/udp/8001')\n\n// mic/speaker soundwaves using frequencies 697 and 1209\npeer.multiaddrs.add('/sonic/bfsk/697/1209')\n```\n\n## API\n\n```js\nconst PeerInfo = require('peer-info')\n```\n\n### `PeerInfo.create([id])`\n\n- `id` optional - can be a PeerId or a JSON object(will be parsed with https://github.com/libp2p/js-peer-id#createfromjsonobj)\n\nCreates a new PeerInfo instance and if no `id` is passed it\ngenerates a new underlying [PeerID](https://github.com/libp2p/js-peer-id)\nfor it.\n\nReturns `Promise\u003cPeerInfo\u003e`.\n\n### `new PeerInfo(id)`\n\n- `id: PeerId` - instance of PeerId (optional)\n\nCreates a new PeerInfo instance from an existing PeerId.\n\n### `.id`\n\nThe [PeerId](https://github.com/libp2p/js-peer-id) of the peer this info relates to.\n\n### `protocols`\n\nA list of protocols that `peer` supports.\n\n### `.protocols.add(protocol)`\n\nAdds a protocol that `peer` can support. `protocol` is a string.\n\n### `.protocols.delete(protocol)`\n\nRemoves a protocol that `peer` no longer supports. `protocol` is a string.\n\n### `.multiaddrs`\n\nA list of multiaddresses instances that `peer` can be reached at.\n\n### `.multiaddrs.add(addr)`\n\n- `addr: Multiaddr`\n\nAdds a new multiaddress that `peer` can be reached at. `addr` is an instance of\na [multiaddr](https://github.com/multiformats/js-multiaddr).\n\n### `.multiaddrs.addSafe(addr)`\n\n- `addr: Multiaddr`\n\nThe `addSafe` call, in comparison to `add`, will only add the multiaddr to\n`multiaddrs` if the same multiaddr tries to be added twice.\n\nThis is a simple mechanism to prevent `multiaddrs` from becoming bloated with\nunusable addresses, which happens when we exchange observed multiaddrs with\npeers which will not provide a useful multiaddr to be shared to the rest of the\nnetwork (e.g. a multiaddr referring to a peer inside a LAN being shared to the\noutside world).\n\n### `.multiaddrs.delete(addr)`\n\n- `addr: Multiaddr`\n\nRemoves a multiaddress instance `addr` from `peer`.\n\n### `.multiaddrs.replace(existing, fresh)`\n\n- `existing: Multiaddr`\n- `fresh: Multiaddr`\n\nRemoves the array of multiaddresses `existing` from `peer`, and adds the array\nof multiaddresses `fresh`.\n\n### `.connect(ma)`\n\nRecords the given multiaddr, `ma` as the active multiaddr of the peer.\n\n- `ma: Multiaddr`\n\n### `.disconnect()`\n\nRemoves the existing connected Multiaddr from tracking.\n\n### `.isConnected()`\n\nReturns `true`  if a connected Multiaddr exists, otherwise returns `false`.\n\n## Contribute\n\nPRs accepted.\n\nSmall note: If editing the Readme, please conform to the [standard-readme](https://github.com/RichardLitt/standard-readme) specification.\n\n## License\n\n[MIT © David Dias](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flibp2p%2Fjs-peer-info","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flibp2p%2Fjs-peer-info","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flibp2p%2Fjs-peer-info/lists"}