Compare commits

..

13 Commits

Author SHA1 Message Date
b948972c5b chore: release version v0.8.4 2021-03-22 10:03:40 +01:00
edcedf093d chore: update contributors 2021-03-22 10:03:39 +01:00
3b960d516f fix: specify connection direction (#86)
The comment says it can be 'inbound' or 'outbound' so constrain the type to those values.
2021-03-22 09:58:10 +01:00
2429e7246f chore: release version v0.8.3 2021-01-26 09:24:52 +01:00
22a7f6a9f1 chore: update contributors 2021-01-26 09:24:52 +01:00
fb9fce8713 chore: update deps (#82)
* chore: update deps

* chore: add prepare script
2021-01-26 09:11:00 +01:00
91dba97125 chore: release version v0.8.2 2021-01-20 10:19:40 +01:00
93d712bb0e chore: update contributors 2021-01-20 10:19:40 +01:00
ca520775eb fix: event emitter types with local types (#80) 2021-01-20 10:15:40 +01:00
ceb91c672e chore: add github actions badge (#78) 2020-12-17 11:31:12 +01:00
30ffad42c8 chore: release version v0.8.1 2020-12-11 10:06:07 +01:00
c365399e4f chore: update contributors 2020-12-11 10:06:07 +01:00
5b99e6b56b fix: pubsub publish message should be uint8array (#77) 2020-12-11 10:01:39 +01:00
9 changed files with 79 additions and 25 deletions

View File

@ -1,3 +1,34 @@
## [0.8.4](https://github.com/libp2p/js-interfaces/compare/v0.8.3...v0.8.4) (2021-03-22)
### Bug Fixes
* specify connection direction ([#86](https://github.com/libp2p/js-interfaces/issues/86)) ([3b960d5](https://github.com/libp2p/js-interfaces/commit/3b960d516f70f7e198574a736cb09000ddd7a94c))
## [0.8.3](https://github.com/libp2p/js-interfaces/compare/v0.8.2...v0.8.3) (2021-01-26)
## [0.8.2](https://github.com/libp2p/js-interfaces/compare/v0.8.1...v0.8.2) (2021-01-20)
### Bug Fixes
* event emitter types with local types ([#80](https://github.com/libp2p/js-interfaces/issues/80)) ([ca52077](https://github.com/libp2p/js-interfaces/commit/ca520775eb26f5ed501375fdb24ba698c9a8c8c8))
## [0.8.1](https://github.com/libp2p/js-interfaces/compare/v0.8.0...v0.8.1) (2020-12-11)
### Bug Fixes
* pubsub publish message should be uint8array ([#77](https://github.com/libp2p/js-interfaces/issues/77)) ([5b99e6b](https://github.com/libp2p/js-interfaces/commit/5b99e6b56b10439a82ee88fb4e31fb95c182264f))
# [0.8.0](https://github.com/libp2p/js-interfaces/compare/v0.7.2...v0.8.0) (2020-12-10)

View File

@ -4,6 +4,8 @@
[![](https://img.shields.io/badge/project-libp2p-yellow.svg?style=flat-square)](http://libp2p.io/)
[![](https://img.shields.io/badge/freenode-%23libp2p-yellow.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23libp2p)
[![](https://img.shields.io/discourse/https/discuss.libp2p.io/posts.svg)](https://discuss.libp2p.io)
[![codecov](https://img.shields.io/codecov/c/github/libp2p/js-libp2p-interfaces.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p-interfaces)
[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/libp2p/js-libp2p-interfaces/ci?label=ci&style=flat-square)](https://github.com/libp2p/js-libp2p-interfaces/actions?query=branch%3Amaster+workflow%3Aci+)
> Contains test suites and interfaces you can use to implement the various components of libp2p.

View File

@ -1,6 +1,6 @@
{
"name": "libp2p-interfaces",
"version": "0.8.0",
"version": "0.8.4",
"description": "Interfaces for JS Libp2p",
"leadMaintainer": "Jacob Heun <jacobheun@gmail.com>",
"main": "src/index.js",
@ -24,6 +24,7 @@
"scripts": {
"lint": "aegir lint",
"build": "aegir build",
"prepare": "aegir build --no-bundle",
"test": "aegir test",
"test:node": "aegir test --target node",
"test:browser": "aegir test --target browser",
@ -51,33 +52,33 @@
"abortable-iterator": "^3.0.0",
"chai": "^4.2.0",
"chai-checkmark": "^1.0.1",
"debug": "^4.1.1",
"delay": "^4.3.0",
"debug": "^4.3.1",
"delay": "^4.4.0",
"detect-node": "^2.0.4",
"dirty-chai": "^2.0.1",
"err-code": "^2.0.0",
"it-goodbye": "^2.0.1",
"err-code": "^2.0.3",
"it-goodbye": "^2.0.2",
"it-length-prefixed": "^3.1.0",
"it-pair": "^1.0.0",
"it-pipe": "^1.1.0",
"it-pushable": "^1.4.0",
"libp2p-crypto": "^0.18.0",
"libp2p-crypto": "^0.19.0",
"libp2p-tcp": "^0.15.0",
"multiaddr": "^8.0.0",
"multibase": "^3.0.0",
"multihashes": "^3.0.1",
"multiaddr": "^8.1.2",
"multibase": "^3.1.1",
"multihashes": "^3.1.1",
"p-defer": "^3.0.0",
"p-limit": "^2.3.0",
"p-wait-for": "^3.1.0",
"peer-id": "^0.14.0",
"p-limit": "^3.1.0",
"p-wait-for": "^3.2.0",
"peer-id": "^0.14.2",
"protons": "^2.0.0",
"sinon": "^9.0.2",
"streaming-iterables": "^5.0.2",
"uint8arrays": "^1.1.0"
"sinon": "^9.2.4",
"streaming-iterables": "^5.0.4",
"uint8arrays": "^2.0.5"
},
"devDependencies": {
"aegir": "^29.2.0",
"it-handshake": "^1.0.1",
"it-handshake": "^1.0.2",
"rimraf": "^3.0.2"
},
"contributors": [

View File

@ -19,7 +19,7 @@ const connectionSymbol = Symbol.for('@libp2p/interface-connection/connection')
* @property {number} [close]
*
* @typedef {Object} ConectionStat
* @property {string} direction - connection establishment direction ("inbound" or "outbound").
* @property {'inbound' | 'outbound'} direction - connection establishment direction
* @property {Timeline} timeline - connection relevant events timestamp.
* @property {string} [multiplexer] - connection multiplexing identifier.
* @property {string} [encryption] - connection encryption method identifier.

View File

@ -1,7 +1,9 @@
'use strict'
const debug = require('debug')
const { EventEmitter } = require('events')
/** @typedef {import('../types').EventEmitterFactory} Events */
/** @type Events */
const EventEmitter = require('events')
const errcode = require('err-code')
const { pipe } = require('it-pipe')
@ -644,7 +646,7 @@ class PubsubBaseProtocol extends EventEmitter {
*
* @override
* @param {string} topic
* @param {Buffer} message
* @param {Uint8Array} message
* @returns {Promise<void>}
*/
async publish (topic, message) {

View File

@ -1,11 +1,11 @@
'use strict'
const { EventEmitter } = require('events')
/** @typedef {import('../types').EventEmitterFactory} Events */
/** @type Events */
const EventEmitter = require('events')
const lp = require('it-length-prefixed')
/** @type {typeof import('it-pushable').default} */
// @ts-ignore
const pushable = require('it-pushable')
const { pipe } = require('it-pipe')
const { source: abortable } = require('abortable-iterator')

View File

@ -111,10 +111,10 @@ exports.normalizeInRpcMessage = (message, peerId) => {
*/
exports.normalizeOutRpcMessage = (message) => {
const m = Object.assign({}, message)
if (typeof message.from === 'string' || message.from instanceof String) {
if (typeof message.from === 'string') {
m.from = uint8ArrayFromString(message.from, 'base58btc')
}
if (typeof message.data === 'string' || message.data instanceof String) {
if (typeof message.data === 'string') {
m.data = uint8ArrayFromString(message.data)
}
return m

View File

@ -4,7 +4,7 @@ const { expect } = require('chai')
const pair = require('it-pair/duplex')
const { pipe } = require('it-pipe')
const pLimit = require('p-limit').default
const pLimit = require('p-limit')
const { collect, tap, consume } = require('streaming-iterables')
module.exports = async (Muxer, nStreams, nMsg, limit) => {

18
src/types.ts Normal file
View File

@ -0,0 +1,18 @@
export interface EventEmitterFactory {
new(): EventEmitter;
}
export interface EventEmitter {
addListener(event: string | symbol, listener: (...args: any[]) => void);
on(event: string | symbol, listener: (...args: any[]) => void);
once(event: string | symbol, listener: (...args: any[]) => void);
removeListener(event: string | symbol, listener: (...args: any[]) => void);
off(event: string | symbol, listener: (...args: any[]) => void);
removeAllListeners(event?: string | symbol);
setMaxListeners(n: number);
getMaxListeners(): number;
listeners(event: string | symbol): Function[]; // eslint-disable-line @typescript-eslint/ban-types
rawListeners(event: string | symbol): Function[]; // eslint-disable-line @typescript-eslint/ban-types
emit(event: string | symbol, ...args: any[]): boolean;
listenerCount(event: string | symbol): number;
}