mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-07-22 12:01:57 +00:00
Compare commits
27 Commits
v0.29.0
...
v0.29.0-rc
Author | SHA1 | Date | |
---|---|---|---|
|
32e7a83c39 | ||
|
83856611de | ||
|
69c31374ab | ||
|
e14ce40b09 | ||
|
507f8c441c | ||
|
02b6248aa3 | ||
|
7681a19cd9 | ||
|
c7e93a5764 | ||
|
26e4481bcb | ||
|
e1b8edcfa3 | ||
|
5bce4cbbc6 | ||
|
109abda1fe | ||
|
cbd2b52e0e | ||
|
e0ed258c54 | ||
|
40e4e94f20 | ||
|
a798c65286 | ||
|
4dfa8094d8 | ||
|
83922a7fad | ||
|
f8354577a2 | ||
|
ce8b77106e | ||
|
53340af863 | ||
|
97b5d2ade4 | ||
|
1e6ada5db9 | ||
|
e29d4a6d6c | ||
|
f95edf1c20 | ||
|
c27228878e | ||
|
ad7f02e62a |
92
CHANGELOG.md
92
CHANGELOG.md
@@ -1,95 +1,3 @@
|
||||
<a name="0.29.0"></a>
|
||||
# [0.29.0](https://github.com/libp2p/js-libp2p/compare/v0.28.10...v0.29.0) (2020-08-27)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* do not return self on peerstore.peers ([15613cc](https://github.com/libp2p/js-libp2p/commit/15613cc))
|
||||
* peer record interop with go ([#739](https://github.com/libp2p/js-libp2p/issues/739)) ([93dda74](https://github.com/libp2p/js-libp2p/commit/93dda74))
|
||||
* replace node buffers with uint8arrays ([#730](https://github.com/libp2p/js-libp2p/issues/730)) ([1e86971](https://github.com/libp2p/js-libp2p/commit/1e86971))
|
||||
* revert new identify protocol versions ([3158366](https://github.com/libp2p/js-libp2p/commit/3158366))
|
||||
* signature compliant with spec ([4ab125e](https://github.com/libp2p/js-libp2p/commit/4ab125e))
|
||||
|
||||
|
||||
### Chores
|
||||
|
||||
* update travis to use node lts and stable ([098f3d1](https://github.com/libp2p/js-libp2p/commit/098f3d1))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* cerified addressbook ([8f2e690](https://github.com/libp2p/js-libp2p/commit/8f2e690))
|
||||
* create self peer record in identify ([8a97dde](https://github.com/libp2p/js-libp2p/commit/8a97dde))
|
||||
* exchange signed peer records in identify ([e50f0ee](https://github.com/libp2p/js-libp2p/commit/e50f0ee))
|
||||
* gossipsub 1.1 ([#733](https://github.com/libp2p/js-libp2p/issues/733)) ([55c9bfa](https://github.com/libp2p/js-libp2p/commit/55c9bfa))
|
||||
* signed peer records record manager ([3e5d450](https://github.com/libp2p/js-libp2p/commit/3e5d450))
|
||||
|
||||
|
||||
### Reverts
|
||||
|
||||
* reapply "fix: throw if no conn encryption module provided ([#665](https://github.com/libp2p/js-libp2p/issues/665))" ([689f90a](https://github.com/libp2p/js-libp2p/commit/689f90a))
|
||||
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
* pubsub implementation is now directly exposed and its API was updated according to the new pubsub interface in js-libp2p-interfaces repo
|
||||
|
||||
* chore: use gossipsub branch with src added
|
||||
|
||||
* fix: add pubsub handlers adapter
|
||||
|
||||
* chore: fix deps
|
||||
|
||||
* chore: update pubsub docs and examples
|
||||
|
||||
* chore: apply suggestions from code review
|
||||
|
||||
Co-authored-by: Jacob Heun <jacobheun@gmail.com>
|
||||
|
||||
* chore: use new floodsub
|
||||
|
||||
* chore: change validator doc set
|
||||
|
||||
Co-authored-by: Jacob Heun <jacobheun@gmail.com>
|
||||
|
||||
* chore: add new gossipsub src
|
||||
|
||||
Co-authored-by: Jacob Heun <jacobheun@gmail.com>
|
||||
* - All deps used by this module now use Uint8Arrays in place of node Buffers
|
||||
|
||||
* chore: browser fixes
|
||||
|
||||
* chore: remove .only
|
||||
|
||||
* chore: stringify uint8array before parsing
|
||||
|
||||
* chore: update interop suite
|
||||
|
||||
* chore: remove ts from build command
|
||||
|
||||
* chore: update deps
|
||||
|
||||
* fix: update records to use uint8array
|
||||
|
||||
* chore: fix lint
|
||||
|
||||
* chore: update deps
|
||||
|
||||
Co-authored-by: Jacob Heun <jacobheun@gmail.com>
|
||||
* this drops testing support in node 10.
|
||||
|
||||
|
||||
|
||||
<a name="0.29.0-rc.1"></a>
|
||||
# [0.29.0-rc.1](https://github.com/libp2p/js-libp2p/compare/v0.29.0-rc.0...v0.29.0-rc.1) (2020-08-27)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* peer record interop with go ([#739](https://github.com/libp2p/js-libp2p/issues/739)) ([c4c7ef9](https://github.com/libp2p/js-libp2p/commit/c4c7ef9))
|
||||
|
||||
|
||||
|
||||
<a name="0.29.0-rc.0"></a>
|
||||
# [0.29.0-rc.0](https://github.com/libp2p/js-libp2p/compare/v0.28.10...v0.29.0-rc.0) (2020-08-25)
|
||||
|
||||
|
@@ -1220,7 +1220,7 @@ Get the stored information of a given peer, namely its [`PeerId`][peer-id], know
|
||||
|
||||
| Type | Description |
|
||||
|------|-------------|
|
||||
| `{ id: PeerId, addresses: Array<Address>, metadata: Map<string, Buffer>}, protocols: Array<string> }` | Peer information of the provided peer |
|
||||
| `{ id: PeerId, addresses: Array<Address>, protocols: Array<string> }` | Peer information of the provided peer |
|
||||
|
||||
#### Example
|
||||
|
||||
@@ -1247,13 +1247,13 @@ Get all the stored information of every peer.
|
||||
|
||||
| Type | Description |
|
||||
|------|-------------|
|
||||
| `Map<string, { id: PeerId, addresses: Array<Address>, metadata: Map<string, Buffer>}, protocols: Array<string> }>` | Peer data of every peer known |
|
||||
| `Map<string, { id: PeerId, addresses: Array<Address>, protocols: Array<string> }>` | Peer data of every peer known |
|
||||
|
||||
#### Example
|
||||
|
||||
```js
|
||||
for (let [peerIdString, peer] of peerStore.peers.entries()) {
|
||||
// peer { id, addresses, metadata, protocols }
|
||||
// peer { id, addresses, protocols }
|
||||
}
|
||||
```
|
||||
|
||||
|
@@ -277,6 +277,6 @@ With this release you should update the following libp2p modules if you are rely
|
||||
"libp2p-noise": "^2.0.0",
|
||||
"libp2p-secio": "^0.13.1",
|
||||
"libp2p-tcp": "^0.15.1",
|
||||
"libp2p-webrtc-star": "^0.20.0",
|
||||
"libp2p-webrtc-star": "^0.19.0",
|
||||
"libp2p-websockets": "^0.14.0",
|
||||
```
|
||||
|
10
package.json
10
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "libp2p",
|
||||
"version": "0.29.0",
|
||||
"version": "0.29.0-rc.0",
|
||||
"description": "JavaScript implementation of libp2p, a modular peer to peer network stack",
|
||||
"leadMaintainer": "Jacob Heun <jacobheun@gmail.com>",
|
||||
"main": "src/index.js",
|
||||
@@ -65,7 +65,7 @@
|
||||
"merge-options": "^2.0.0",
|
||||
"moving-average": "^1.0.0",
|
||||
"multiaddr": "^8.0.0",
|
||||
"multicodec": "^2.0.0",
|
||||
"multicodec": "^1.0.2",
|
||||
"multistream-select": "^1.0.0",
|
||||
"mutable-proxy": "^1.0.0",
|
||||
"node-forge": "^0.9.1",
|
||||
@@ -92,7 +92,7 @@
|
||||
"cids": "^1.0.0",
|
||||
"delay": "^4.3.0",
|
||||
"dirty-chai": "^2.0.1",
|
||||
"interop-libp2p": "^0.3.0",
|
||||
"interop-libp2p": "libp2p/interop#chore/gossipsub-1.1",
|
||||
"ipfs-http-client": "^46.0.0",
|
||||
"it-concat": "^1.0.0",
|
||||
"it-pair": "^1.0.0",
|
||||
@@ -102,14 +102,14 @@
|
||||
"libp2p-delegated-content-routing": "^0.6.0",
|
||||
"libp2p-delegated-peer-routing": "^0.6.0",
|
||||
"libp2p-floodsub": "^0.23.0",
|
||||
"libp2p-gossipsub": "^0.6.0",
|
||||
"libp2p-gossipsub": "ChainSafe/js-libp2p-gossipsub#chore/use-libp2p-interfaces0.5.1-with-src",
|
||||
"libp2p-kad-dht": "^0.20.0",
|
||||
"libp2p-mdns": "^0.15.0",
|
||||
"libp2p-mplex": "^0.10.0",
|
||||
"libp2p-noise": "^2.0.0",
|
||||
"libp2p-secio": "^0.13.1",
|
||||
"libp2p-tcp": "^0.15.1",
|
||||
"libp2p-webrtc-star": "^0.20.0",
|
||||
"libp2p-webrtc-star": "^0.19.0",
|
||||
"libp2p-websockets": "^0.14.0",
|
||||
"multihashes": "^3.0.1",
|
||||
"nock": "^13.0.3",
|
||||
|
@@ -32,7 +32,6 @@ class PeerStore extends EventEmitter {
|
||||
* @property {PeerId} id peer's peer-id instance.
|
||||
* @property {Array<Address>} addresses peer's addresses containing its multiaddrs and metadata.
|
||||
* @property {Array<string>} protocols peer's supported protocols.
|
||||
* @property {Map<string, Buffer>} metadata peer's metadata map.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@@ -140,7 +140,7 @@ Envelope.createFromProtobuf = async (data) => {
|
||||
*/
|
||||
Envelope.seal = async (record, peerId) => {
|
||||
const domain = record.domain
|
||||
const payloadType = record.codec
|
||||
const payloadType = uint8arraysFromString(record.codec)
|
||||
const payload = record.marshal()
|
||||
|
||||
const signData = formatSignaturePayload(domain, payloadType, payload)
|
||||
|
@@ -3,9 +3,9 @@
|
||||
const multicodec = require('multicodec')
|
||||
|
||||
// The domain string used for peer records contained in a Envelope.
|
||||
module.exports.ENVELOPE_DOMAIN_PEER_RECORD = multicodec.getName(multicodec.LIBP2P_PEER_RECORD)
|
||||
module.exports.ENVELOPE_DOMAIN_PEER_RECORD = 'libp2p-peer-record'
|
||||
|
||||
// The type hint used to identify peer records in a Envelope.
|
||||
// Defined in https://github.com/multiformats/multicodec/blob/master/table.csv
|
||||
// with name "libp2p-peer-record"
|
||||
module.exports.ENVELOPE_PAYLOAD_TYPE_PEER_RECORD = Uint8Array.from([3, 1])
|
||||
module.exports.ENVELOPE_PAYLOAD_TYPE_PEER_RECORD = multicodec.print[multicodec.LIBP2P_PEER_RECORD]
|
||||
|
@@ -311,11 +311,7 @@ describe('Pubsub subsystem operates correctly', () => {
|
||||
expect(handlerSpy.args.map(([message]) => uint8ArrayToString(message.data))).to.include.members(['message1', 'message2'])
|
||||
|
||||
// Disconnect the first connection (this acts as a delayed reconnect)
|
||||
const libp2pConnUpdateSpy = sinon.spy(libp2p.connectionManager.connections, 'set')
|
||||
const remoteLibp2pConnUpdateSpy = sinon.spy(remoteLibp2p.connectionManager.connections, 'set')
|
||||
|
||||
await originalConnection.close()
|
||||
await pWaitFor(() => libp2pConnUpdateSpy.callCount === 1 && remoteLibp2pConnUpdateSpy.callCount === 1)
|
||||
|
||||
// Verify messages go both ways after the disconnect
|
||||
handlerSpy.resetHistory()
|
||||
|
@@ -7,8 +7,6 @@ chai.use(require('chai-bytes'))
|
||||
chai.use(require('chai-as-promised'))
|
||||
const { expect } = chai
|
||||
|
||||
const uint8arrayFromString = require('uint8arrays/from-string')
|
||||
const uint8arrayEquals = require('uint8arrays/equals')
|
||||
const Envelope = require('../../src/record/envelope')
|
||||
const Record = require('libp2p-interfaces/src/record')
|
||||
const { codes: ErrorCodes } = require('../../src/errors')
|
||||
@@ -16,7 +14,7 @@ const { codes: ErrorCodes } = require('../../src/errors')
|
||||
const peerUtils = require('../utils/creators/peer')
|
||||
|
||||
const domain = 'libp2p-testing'
|
||||
const codec = uint8arrayFromString('/libp2p/testdata')
|
||||
const codec = '/libp2p/testdata'
|
||||
|
||||
class TestRecord extends Record {
|
||||
constructor (data) {
|
||||
@@ -25,16 +23,16 @@ class TestRecord extends Record {
|
||||
}
|
||||
|
||||
marshal () {
|
||||
return uint8arrayFromString(this.data)
|
||||
return Buffer.from(this.data)
|
||||
}
|
||||
|
||||
equals (other) {
|
||||
return uint8arrayEquals(this.data, other.data)
|
||||
return Buffer.compare(this.data, other.data)
|
||||
}
|
||||
}
|
||||
|
||||
describe('Envelope', () => {
|
||||
const payloadType = codec
|
||||
const payloadType = Buffer.from(codec)
|
||||
let peerId
|
||||
let testRecord
|
||||
|
||||
@@ -45,7 +43,7 @@ describe('Envelope', () => {
|
||||
|
||||
it('creates an envelope with a random key', () => {
|
||||
const payload = testRecord.marshal()
|
||||
const signature = uint8arrayFromString(Math.random().toString(36).substring(7))
|
||||
const signature = Buffer.from(Math.random().toString(36).substring(7))
|
||||
|
||||
const envelope = new Envelope({
|
||||
peerId,
|
||||
@@ -65,7 +63,7 @@ describe('Envelope', () => {
|
||||
const envelope = await Envelope.seal(testRecord, peerId)
|
||||
expect(envelope).to.exist()
|
||||
expect(envelope.peerId.equals(peerId)).to.eql(true)
|
||||
expect(envelope.payloadType).to.eql(payloadType)
|
||||
expect(envelope.payloadType).to.equalBytes(payloadType)
|
||||
expect(envelope.payload).to.exist()
|
||||
expect(envelope.signature).to.exist()
|
||||
})
|
||||
|
@@ -7,7 +7,6 @@ const { expect } = chai
|
||||
|
||||
const tests = require('libp2p-interfaces/src/record/tests')
|
||||
const multiaddr = require('multiaddr')
|
||||
const PeerId = require('peer-id')
|
||||
|
||||
const Envelope = require('../../src/record/envelope')
|
||||
const PeerRecord = require('../../src/record/peer-record')
|
||||
@@ -33,23 +32,6 @@ describe('PeerRecord', () => {
|
||||
[peerId] = await peerUtils.createPeerId()
|
||||
})
|
||||
|
||||
it('de/serializes the same as a go record', async () => {
|
||||
const privKey = Uint8Array.from([8, 1, 18, 64, 133, 251, 231, 43, 96, 100, 40, 144, 4, 165, 49, 249, 103, 137, 141, 245, 49, 158, 224, 41, 146, 253, 216, 64, 33, 250, 80, 82, 67, 75, 246, 238, 17, 187, 163, 237, 23, 33, 148, 140, 239, 180, 229, 11, 10, 11, 181, 202, 216, 166, 181, 45, 199, 177, 164, 15, 79, 102, 82, 16, 92, 145, 226, 196])
|
||||
const rawEnvelope = Uint8Array.from([10, 36, 8, 1, 18, 32, 17, 187, 163, 237, 23, 33, 148, 140, 239, 180, 229, 11, 10, 11, 181, 202, 216, 166, 181, 45, 199, 177, 164, 15, 79, 102, 82, 16, 92, 145, 226, 196, 18, 2, 3, 1, 26, 170, 1, 10, 38, 0, 36, 8, 1, 18, 32, 17, 187, 163, 237, 23, 33, 148, 140, 239, 180, 229, 11, 10, 11, 181, 202, 216, 166, 181, 45, 199, 177, 164, 15, 79, 102, 82, 16, 92, 145, 226, 196, 16, 216, 184, 224, 191, 147, 145, 182, 151, 22, 26, 10, 10, 8, 4, 1, 2, 3, 4, 6, 0, 0, 26, 10, 10, 8, 4, 1, 2, 3, 4, 6, 0, 1, 26, 10, 10, 8, 4, 1, 2, 3, 4, 6, 0, 2, 26, 10, 10, 8, 4, 1, 2, 3, 4, 6, 0, 3, 26, 10, 10, 8, 4, 1, 2, 3, 4, 6, 0, 4, 26, 10, 10, 8, 4, 1, 2, 3, 4, 6, 0, 5, 26, 10, 10, 8, 4, 1, 2, 3, 4, 6, 0, 6, 26, 10, 10, 8, 4, 1, 2, 3, 4, 6, 0, 7, 26, 10, 10, 8, 4, 1, 2, 3, 4, 6, 0, 8, 26, 10, 10, 8, 4, 1, 2, 3, 4, 6, 0, 9, 42, 64, 177, 151, 247, 107, 159, 40, 138, 242, 180, 103, 254, 102, 111, 119, 68, 118, 40, 112, 73, 180, 36, 183, 57, 117, 200, 134, 14, 251, 2, 55, 45, 2, 106, 121, 149, 132, 84, 26, 215, 47, 38, 84, 52, 100, 133, 188, 163, 236, 227, 100, 98, 183, 209, 177, 57, 28, 141, 39, 109, 196, 171, 139, 202, 11])
|
||||
const peerId = await PeerId.createFromPrivKey(privKey)
|
||||
|
||||
const env = await Envelope.openAndCertify(rawEnvelope, PeerRecord.DOMAIN)
|
||||
expect(peerId.equals(env.peerId))
|
||||
|
||||
const record = PeerRecord.createFromProtobuf(env.payload)
|
||||
|
||||
// The payload isn't going to match because of how the protobuf encodes uint64 values
|
||||
// They are marshalled correctly on both sides, but will be off by 1 value
|
||||
// Signatures will still be validated
|
||||
const jsEnv = await Envelope.seal(record, peerId)
|
||||
expect(env.payloadType).to.eql(jsEnv.payloadType)
|
||||
})
|
||||
|
||||
it('creates a peer record with peerId', () => {
|
||||
const peerRecord = new PeerRecord({ peerId })
|
||||
|
||||
|
Reference in New Issue
Block a user