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

Commit

Permalink
deps!: update all deps
Browse files Browse the repository at this point in the history
  • Loading branch information
achingbrain committed Apr 24, 2023
1 parent f45c58d commit dbfd4f2
Show file tree
Hide file tree
Showing 12 changed files with 133 additions and 102 deletions.
4 changes: 3 additions & 1 deletion .aegir.cjs
Expand Up @@ -13,6 +13,7 @@ async function before () {
const { pipe } = await import('it-pipe')
const { multiaddr } = await import('@multiformats/multiaddr')
const { mockUpgrader, mockRegistrar } = await import('@libp2p/interface-mocks')
const { EventEmitter } = await import('@libp2p/interfaces/events')

const REMOTE_MULTIADDR_IP4 = multiaddr('/ip4/127.0.0.1/tcp/12345/http/p2p-webrtc-direct')
const REMOTE_MULTIADDR_IP6 = multiaddr('/ip6/::1/tcp/12346/http/p2p-webrtc-direct')
Expand All @@ -25,7 +26,8 @@ async function before () {
).catch()
})
const upgrader = mockUpgrader({
registrar
registrar,
events: new EventEmitter()
})

const wd = webRTCDirect({
Expand Down
60 changes: 49 additions & 11 deletions .github/workflows/js-test-and-release.yml
Expand Up @@ -2,7 +2,7 @@ name: test & maybe release
on:
push:
branches:
- master # with #262 - ${{{ github.default_branch }}}
- master
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/master' # with #262 - 'refs/heads/${{{ github.default_branch }}}'
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
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 }}
45 changes: 6 additions & 39 deletions .gitignore
@@ -1,42 +1,9 @@
**/node_modules/
**/*.log
test/repo-tests*
**/bundle.js

# Logs
logs
*.log

coverage

# Runtime data
pids
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript

build

# Dependency directory
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
node_modules

lib
build
dist
test/test-data/go-ipfs-repo/LOCK
test/test-data/go-ipfs-repo/LOG
test/test-data/go-ipfs-repo/LOG.old

# while testing npm5
.docs
.coverage
node_modules
package-lock.json
yarn.lock
.vscode
25 changes: 13 additions & 12 deletions package.json
Expand Up @@ -26,7 +26,7 @@
"types": "./dist/src/index.d.ts",
"files": [
"src",
"dist/src",
"dist",
"!dist/test",
"!**/*.tsbuildinfo"
],
Expand Down Expand Up @@ -139,14 +139,14 @@
"release": "aegir release"
},
"dependencies": {
"@libp2p/interface-transport": "^2.0.0",
"@libp2p/interfaces": "^3.0.3",
"@libp2p/interface-connection": "^5.0.1",
"@libp2p/interface-transport": "^4.0.0",
"@libp2p/logger": "^2.0.1",
"@libp2p/utils": "^3.0.2",
"@libp2p/webrtc-peer": "^2.0.0",
"@multiformats/mafmt": "^11.0.3",
"@multiformats/multiaddr": "^11.0.0",
"abortable-iterator": "^4.0.2",
"@multiformats/mafmt": "^12.1.0",
"@multiformats/multiaddr": "^12.1.2",
"abortable-iterator": "^5.0.1",
"err-code": "^3.0.0",
"multiformats": "^11.0.0",
"native-fetch": "^4.0.2",
Expand All @@ -156,13 +156,14 @@
"wherearewe": "^2.0.1"
},
"devDependencies": {
"@libp2p/interface-mocks": "^9.0.0",
"@libp2p/interface-transport-compliance-tests": "^3.0.0",
"@libp2p/interface-mocks": "^11.0.0",
"@libp2p/interface-transport-compliance-tests": "^4.0.0",
"@libp2p/interfaces": "^3.3.1",
"@mapbox/node-pre-gyp": "^1.0.8",
"aegir": "^37.9.1",
"it-all": "^2.0.0",
"it-pipe": "^2.0.3",
"it-stream-types": "^1.0.4",
"aegir": "^38.1.8",
"it-all": "^3.0.1",
"it-pipe": "^3.0.1",
"it-stream-types": "^2.0.1",
"multiaddr": "^10.0.0",
"uint8arraylist": "^2.3.2",
"wrtc": "^0.4.6"
Expand Down
19 changes: 10 additions & 9 deletions src/index.ts
Expand Up @@ -12,6 +12,7 @@ import { Signal, WebRTCInitiator, WebRTCInitiatorInit, WebRTCReceiverInit, WRTC
import { symbol } from '@libp2p/interface-transport'
import type { CreateListenerOptions, DialOptions, Listener, Transport } from '@libp2p/interface-transport'
import type { Multiaddr } from '@multiformats/multiaddr'
import type { Connection } from '@libp2p/interface-connection'

const log = logger('libp2p:webrtc-direct')

Expand All @@ -36,11 +37,11 @@ class WebRTCDirect implements Transport {
return true
}

get [Symbol.toStringTag] () {
get [Symbol.toStringTag] (): string {
return '@libp2p/webrtc-direct'
}

async dial (ma: Multiaddr, options: DialOptions) {
async dial (ma: Multiaddr, options: DialOptions): Promise<Connection> {
const socket = await this._connect(ma, options)
const maConn = toMultiaddrConnection(socket, { remoteAddr: ma, signal: options.signal })
log('new outbound connection %s', maConn.remoteAddr)
Expand All @@ -49,7 +50,7 @@ class WebRTCDirect implements Transport {
return conn
}

async _connect (ma: Multiaddr, options: DialOptions) {
async _connect (ma: Multiaddr, options: DialOptions): Promise<WebRTCInitiator> {
if (options.signal?.aborted === true) {
throw new AbortError()
}
Expand All @@ -73,7 +74,7 @@ class WebRTCDirect implements Transport {

const channel = new WebRTCInitiator(channelOptions)

const onError = (evt: CustomEvent<Error>) => {
const onError = (evt: CustomEvent<Error>): void => {
const err = evt.detail

if (!connected) {
Expand All @@ -85,21 +86,21 @@ class WebRTCDirect implements Transport {
}
}

const onReady = () => {
const onReady = (): void => {
connected = true

log('connection opened %s:%s', cOpts.host, cOpts.port)
done()
}

const onAbort = () => {
const onAbort = (): void => {
log.error('connection aborted %s:%s', cOpts.host, cOpts.port)
void channel.close().finally(() => {
done(new AbortError())
})
}

const done = (err?: Error) => {
const done = (err?: Error): void => {
channel.removeEventListener('error', onError)
channel.removeEventListener('ready', onReady)
options.signal?.removeEventListener('abort', onAbort)
Expand All @@ -122,7 +123,7 @@ class WebRTCDirect implements Transport {
})
options.signal?.addEventListener('abort', onAbort)

const onSignal = async (signal: Signal) => {
const onSignal = async (signal: Signal): Promise<void> => {
if (signal.type !== 'offer') {
// skip candidates, just send the offer as it includes the candidates
return
Expand Down Expand Up @@ -194,7 +195,7 @@ class WebRTCDirect implements Transport {
return false
}

return mafmt.WebRTCDirect.matches(ma.decapsulateCode(CODE_P2P))
return mafmt.P2PWebRTCDirect.matches(ma.decapsulateCode(CODE_P2P))
})
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/listener.browser.ts
@@ -1,4 +1,5 @@
import type { Listener } from '@libp2p/interface-transport'

export function createListener () {
export function createListener (): Listener {
throw new Error('WebRTCDirect Servers can not be created in the browser!')
}

0 comments on commit dbfd4f2

Please sign in to comment.