Skip to content
This repository has been archived by the owner on Jun 19, 2023. It is now read-only.

deps!: update all libp2p deps for compat with libp2p@0.45.x #160

Merged
merged 6 commits into from
May 11, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 49 additions & 11 deletions .github/workflows/js-test-and-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: test & maybe release
on:
push:
branches:
- main # with #262 - ${{{ github.default_branch }}}
- main
pull_request:

jobs:
Expand Down Expand Up @@ -33,7 +33,7 @@ jobs:
node-version: ${{ matrix.node }}
- uses: ipfs/aegir/actions/cache-node-modules@master
- run: npm run --if-present test:node
- uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0
- uses: codecov/codecov-action@d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70 # v3.1.1
with:
flags: node

Expand All @@ -47,7 +47,7 @@ jobs:
node-version: lts/*
- uses: ipfs/aegir/actions/cache-node-modules@master
- run: npm run --if-present test:chrome
- uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0
- uses: codecov/codecov-action@d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70 # v3.1.1
with:
flags: chrome

Expand All @@ -61,7 +61,7 @@ jobs:
node-version: lts/*
- uses: ipfs/aegir/actions/cache-node-modules@master
- run: npm run --if-present test:chrome-webworker
- uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0
- uses: codecov/codecov-action@d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70 # v3.1.1
with:
flags: chrome-webworker

Expand All @@ -75,7 +75,7 @@ jobs:
node-version: lts/*
- uses: ipfs/aegir/actions/cache-node-modules@master
- run: npm run --if-present test:firefox
- uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0
- uses: codecov/codecov-action@d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70 # v3.1.1
with:
flags: firefox

Expand All @@ -89,10 +89,48 @@ jobs:
node-version: lts/*
- uses: ipfs/aegir/actions/cache-node-modules@master
- run: npm run --if-present test:firefox-webworker
- uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0
- uses: codecov/codecov-action@d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70 # v3.1.1
with:
flags: firefox-webworker

test-webkit:
needs: check
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
node: [lts/*]
fail-fast: true
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: lts/*
- uses: ipfs/aegir/actions/cache-node-modules@master
- run: npm run --if-present test:webkit
- uses: codecov/codecov-action@d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70 # v3.1.1
with:
flags: webkit

test-webkit-webworker:
needs: check
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
node: [lts/*]
fail-fast: true
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: lts/*
- uses: ipfs/aegir/actions/cache-node-modules@master
- run: npm run --if-present test:webkit-webworker
- uses: codecov/codecov-action@d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70 # v3.1.1
with:
flags: webkit-webworker

test-electron-main:
needs: check
runs-on: ubuntu-latest
Expand All @@ -103,7 +141,7 @@ jobs:
node-version: lts/*
- uses: ipfs/aegir/actions/cache-node-modules@master
- run: npx xvfb-maybe npm run --if-present test:electron-main
- uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0
- uses: codecov/codecov-action@d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70 # v3.1.1
with:
flags: electron-main

Expand All @@ -117,14 +155,14 @@ jobs:
node-version: lts/*
- uses: ipfs/aegir/actions/cache-node-modules@master
- run: npx xvfb-maybe npm run --if-present test:electron-renderer
- uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0
- uses: codecov/codecov-action@d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70 # v3.1.1
with:
flags: electron-renderer

release:
needs: [test-node, test-chrome, test-chrome-webworker, test-firefox, test-firefox-webworker, test-electron-main, test-electron-renderer]
needs: [test-node, test-chrome, test-chrome-webworker, test-firefox, test-firefox-webworker, test-webkit, test-webkit-webworker, test-electron-main, test-electron-renderer]
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main' # with #262 - 'refs/heads/${{{ github.default_branch }}}'
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v3
with:
Expand All @@ -139,5 +177,5 @@ jobs:
docker-username: ${{ secrets.DOCKER_USERNAME }}
- run: npm run --if-present release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.UCI_GITHUB_TOKEN || github.token }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
51 changes: 6 additions & 45 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,48 +1,9 @@
lib-cov
*.seed
*.log
*.csv
*.dat
*.out
*.pid
*.gz
*.swp

pids
logs
results
tmp

# Build
public/css/main.css

# Coverage reports
coverage
node_modules
build
dist
.docs
.coverage
.nyc_output

# API keys and secrets
.env

# Dependency directory
node_modules
bower_components

# Editors
.idea
*.iml
.vscode/launch.json

# OS metadata
.DS_Store
Thumbs.db

# Ignore built ts files
dist/
types/

# ignore yarn.lock
yarn.lock
package-lock.json


yarn.lock
.vscode
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![libp2p.io](https://img.shields.io/badge/project-libp2p-yellow.svg?style=flat-square)](http://libp2p.io/)
[![Discuss](https://img.shields.io/discourse/https/discuss.libp2p.io/posts.svg?style=flat-square)](https://discuss.libp2p.io)
[![codecov](https://img.shields.io/codecov/c/github/libp2p/js-libp2p-webrtc.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p-webrtc)
[![CI](https://img.shields.io/github/workflow/status/libp2p/js-libp2p-webrtc/test%20&%20maybe%20release/main?style=flat-square)](https://github.com/libp2p/js-libp2p-webrtc/actions/workflows/js-test-and-release.yml)
[![CI](https://img.shields.io/github/actions/workflow/status/libp2p/js-libp2p-webrtc/js-test-and-release.yml?branch=main\&style=flat-square)](https://github.com/libp2p/js-libp2p-webrtc/actions/workflows/js-test-and-release.yml?query=branch%3Amain)

> A libp2p transport using WebRTC connections

Expand All @@ -24,7 +24,7 @@
- [Clean](#clean)
- [Check Dependencies](#check-dependencies)
- [License](#license)
- [Contribute](#contribute)
- [Contribution](#contribution)

## Install

Expand Down Expand Up @@ -178,6 +178,6 @@ Licensed under either of
- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)
- MIT ([LICENSE-MIT](LICENSE-MIT) / <http://opensource.org/licenses/MIT>)

## Contribute
## Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
8 changes: 1 addition & 7 deletions examples/browser-to-browser/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,7 @@ node.addEventListener("peer:disconnect", (event) => {
updateConnList()
})

node.peerStore.addEventListener("change:multiaddrs", (event) => {
const { peerId } = event.detail

if (node.getMultiaddrs().length === 0 || !node.peerId.equals(peerId)) {
return
}

node.addEventListener("self:peer:update", (event) => {
node.getMultiaddrs().forEach((ma) => {
if (ma.protoCodes().includes(CIRCUIT_RELAY_CODE)) {
if (ma.protos().pop()?.name === 'p2p') {
Expand Down
2 changes: 1 addition & 1 deletion examples/browser-to-browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"@multiformats/multiaddr": "^12.0.0",
"it-pushable": "^3.1.0",
"js-libp2p-webrtc": "file:../../",
"libp2p": "^0.43.0",
"libp2p": "^0.45.0",
"vite": "^4.2.1"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion examples/browser-to-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"@multiformats/multiaddr": "^12.0.0",
"it-pushable": "^3.1.0",
"@libp2p/webrtc": "file:../../",
"libp2p": "^0.43.2",
"libp2p": "^0.45.0",
"vite": "^4.2.1"
},
"devDependencies": {
Expand Down
14 changes: 6 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"url": "https://github.com/libp2p/js-libp2p-webrtc/issues"
},
"engines": {
"node": ">=16.0.0",
"npm": ">=7.0.0"
"node": ">=18.0.0",
"npm": ">=8.6.0"
},
"type": "module",
"types": "./dist/src/index.d.ts",
Expand Down Expand Up @@ -137,11 +137,10 @@
"release": "aegir release"
},
"dependencies": {
"@chainsafe/libp2p-noise": "^11.0.4",
"@chainsafe/libp2p-noise": "^12.0.0",
"@libp2p/interface-connection": "^5.0.2",
"@libp2p/interface-metrics": "^4.0.8",
"@libp2p/interface-peer-id": "^2.0.2",
"@libp2p/interface-peer-store": "^2.0.2",
"@libp2p/interface-registrar": "^2.0.12",
"@libp2p/interface-stream-muxer": "^4.0.1",
"@libp2p/interface-transport": "^4.0.2",
Expand All @@ -150,9 +149,9 @@
"@libp2p/peer-id": "^2.0.3",
"@multiformats/multiaddr": "^12.1.2",
"@protobuf-ts/runtime": "^2.9.0",
"abortable-iterator": "^4.0.2",
"abortable-iterator": "^5.0.1",
"detect-browser": "^5.3.0",
"it-length-prefixed": "^8.0.3",
"it-length-prefixed": "^9.0.1",
"it-merge": "^3.0.0",
"it-pb-stream": "^4.0.1",
"it-pipe": "^3.0.1",
Expand All @@ -166,12 +165,11 @@
"uint8arrays": "^4.0.3"
},
"devDependencies": {
"@libp2p/interface-mocks": "^11.0.2",
"@libp2p/interface-mocks": "^12.0.1",
"@libp2p/peer-id-factory": "^2.0.3",
"@protobuf-ts/protoc": "^2.9.0",
"@types/sinon": "^10.0.14",
"aegir": "^39.0.6",
"eslint-plugin-etc": "^2.0.2",
"it-pair": "^2.0.6",
"protons": "^7.0.2",
"sinon": "^15.0.4",
Expand Down
2 changes: 0 additions & 2 deletions src/peer_transport/transport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { initiateConnection, handleIncomingStream } from './handler.js'
import { WebRTCPeerListener } from './listener.js'
import type { Connection } from '@libp2p/interface-connection'
import type { PeerId } from '@libp2p/interface-peer-id'
import type { PeerStore } from '@libp2p/interface-peer-store'
import type { IncomingStreamData, Registrar } from '@libp2p/interface-registrar'
import type { Startable } from '@libp2p/interfaces/startable'

Expand All @@ -28,7 +27,6 @@ export interface WebRTCTransportComponents {
registrar: Registrar
upgrader: Upgrader
transportManager: TransportManager
peerStore: PeerStore
}

export class WebRTCTransport implements Transport, Startable {
Expand Down
2 changes: 1 addition & 1 deletion src/stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ export class WebRTCStream implements Stream {
// surface data from the `Message.message` field through a source.
this._src = pipe(
this._innersrc,
lengthPrefixed.decode(),
(source) => lengthPrefixed.decode(source),
(source) => (async function * () {
for await (const buf of source) {
const message = self.processIncomingProtobuf(buf.subarray())
Expand Down
12 changes: 5 additions & 7 deletions src/transport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,15 +189,13 @@ export class WebRTCDirectTransport implements Transport {
const wrappedDuplex = {
...wrappedChannel,
sink: wrappedChannel.sink.bind(wrappedChannel),
source: {
[Symbol.asyncIterator]: async function * () {
for await (const list of wrappedChannel.source) {
for (const buf of list) {
yield buf
}
source: (async function * () {
for await (const list of wrappedChannel.source) {
for (const buf of list) {
yield buf
}
}
}
}())
}

// Creating the connection before completion of the noise
Expand Down
3 changes: 1 addition & 2 deletions test/peer.browser.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@ describe('webrtc filter', () => {
transportManager: sinon.stub() as any,
peerId: sinon.stub() as any,
registrar: mockRegistrar(),
upgrader: mockUpgrader({}),
peerStore: sinon.stub() as any
upgrader: mockUpgrader({})
}, {})

const valid = [
Expand Down