You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

peer-info

Package Overview
Dependencies
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.6.0 to 0.6.1

dist/index.js

45

package.json
{
"name": "peer-info",
"version": "0.6.0",
"version": "0.6.1",
"description": "IPFS Peer abstraction JavaScript implementation",
"main": "src/index.js",
"main": "lib/index.js",
"jsnext:main": "src/index.js",
"scripts": {
"lint": "standard",
"test": "npm run test:node && npm run test:browser",
"test:node": "mocha tests/*-test.js",
"test:browser": "karma start karma.conf.js",
"coverage": "istanbul cover --print both -- _mocha tests/*-test.js"
"lint": "dignified-lint",
"build": "dignified-build",
"test": "dignified-test",
"test:node": "dignified-test node",
"test:browser": "dignified-test browser",
"release": "dignified-release",
"coverage": "dignified-coverage"
},

@@ -36,19 +39,17 @@ "repository": {

"chai": "^3.5.0",
"istanbul": "^0.4.2",
"json-loader": "^0.5.4",
"karma": "^0.13.19",
"karma-chrome-launcher": "^0.2.2",
"karma-cli": "^0.1.2",
"karma-firefox-launcher": "^0.1.7",
"karma-mocha": "^0.2.1",
"karma-spec-reporter": "0.0.24",
"karma-webpack": "^1.7.0",
"mocha": "^2.4.5",
"dignified.js": "^1.0.0",
"multiaddr": "^1.1.1",
"peer-id": "^0.6.0",
"pre-commit": "^1.1.2",
"standard": "^6.0.7",
"webpack": "^1.12.14"
"peer-id": "^0.6.6",
"pre-commit": "^1.1.2"
},
"dependencies": {}
"dependencies": {},
"dignified": {
"webpack": {
"resolve": {
"alias": {
"node-forge": "../vendor/forge.bundle.js"
}
}
}
}
}

@@ -6,18 +6,101 @@ peer-info JavaScript implementation

[![](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs)
![Build Status](https://travis-ci.org/diasdavid/js-peer-info.svg?style=flat-square)](https://travis-ci.org/diasdavid/js-peer-info) ![](https://img.shields.io/badge/coverage-%3F-yellow.svg?style=flat-square)
[![Build Status](https://travis-ci.org/diasdavid/js-peer-info.svg?style=flat-square)](https://travis-ci.org/diasdavid/js-peer-info)
[![Dependency Status](https://david-dm.org/diasdavid/js-peer-info.svg?style=flat-square)](https://david-dm.org/diasdavid/js-peer-info)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard)
> Peer Info contains information about a peer Id and its multiaddrs. This module is used by IPFS and libp2p.
> A PeerInfo object contains information about a
> [PeerID](https://github.com/diasdavid/js-peer-id) and its
> [multiaddrs](https://github.com/jbenet/js-multiaddr). This module is used by
> [IPFS](https://github.com/ipfs/ipfs) and
> [libp2p](https://github.com/diasdavid/js-libp2p).
# Usage
# Example
### In Node.js through npm
```js
const PeerInfo = require('peer-info')
const multiaddr = require('multiaddr')
```bash
> npm install --save peer-info
const peer = new PeerInfo()
// TCP port 5001
peer.multiaddr.add(multiaddr('/ip4/1.2.3.4/tcp/5001'))
// UDP port 8001
peer.multiaddr.add(multiaddr('/ip4/1.2.3.4/udp/8001'))
// mic/speaker soundwaves using frequencies 697 and 1209
peer.multiaddr.add(multiaddr('/sonic/bfsk/697/1209'))
```
```javascript
# API
```js
const PeerInfo = require('peer-info')
```
## const peer = new PeerInfo()
Creates a new PeerInfo instance and also generates a new underlying
[PeerID](https://github.com/diasdavid/js-peer-id) for it.
## const peer = new PeerInfo(peerId)
Creates a new PeerInfo instance from an existing PeerID.
## peer.multiaddrs
A list of multiaddresses instances that `peer` can be reached at.
## peer.multiaddr.add(addr)
Adds a new multiaddress that `peer` can be reached at. `addr` is an instance of
a [multiaddr](https://github.com/jbenet/js-multiaddr).
## peer.multiaddr.addSafe(addr)
The `addSafe` call, in comparison to `add`, will only add the multiaddr to
`multiaddrs` if the same multiaddr tries to be added twice.
This is a simple mechanism to prevent `multiaddrs` from becoming bloated with
unusable addresses, which happens when we exchange observed multiaddrs with
peers which will not provide a useful multiaddr to be shared to the rest of the
network (e.g. a multiaddr referring to a peer inside a LAN being shared to the
outside world).
## peer.multiaddr.rm(addr)
Removes a multiaddress instance `addr` from `peer`.
## peer.multiaddr.replace(existing, fresh)
Removes the array of multiaddresses `existing` from `peer`, and adds the array
of multiaddresses `fresh`.
# Installation
## npm
```sh
> npm i peer-info
```
## Node.JS, Browserify, Webpack
```JavaScript
var PeerInfo = require('peer-info')
```
## Browser: `<script>` Tag
Loading this module through a script tag will make the `PeerInfo` obj available in the global namespace.
```html
<script src="https://npmcdn.com/peer-info/dist/index.min.js"></script>
<!-- OR -->
<script src="https://npmcdn.com/peer-info/dist/index.js"></script>
```
# License
MIT

@@ -1,4 +0,2 @@

/*
* Peer represents a peer on the IPFS network
*/
'use strict'

@@ -9,2 +7,3 @@ const Id = require('peer-id')

// Peer represents a peer on the IPFS network
function Peer (peerId) {

@@ -11,0 +10,0 @@ if (!(this instanceof Peer)) {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc