diff --git a/packages/transport-webrtc/package.json b/packages/transport-webrtc/package.json index b225f72974..5883b6fdbe 100644 --- a/packages/transport-webrtc/package.json +++ b/packages/transport-webrtc/package.json @@ -38,18 +38,24 @@ "test": "aegir test -t browser", "test:chrome": "aegir test -t browser --cov", "test:firefox": "aegir test -t browser -- --browser firefox", + "test:webkit": "aegir test -t browser -- --browser webkit", "lint": "aegir lint", "lint:fix": "aegir lint --fix", "clean": "aegir clean", - "dep-check": "aegir dep-check" + "dep-check": "aegir dep-check -i protons" }, "dependencies": { "@chainsafe/libp2p-noise": "^12.0.1", - "@libp2p/interface": "~0.0.1", - "@libp2p/interface-internal": "~0.0.1", - "@libp2p/logger": "^2.0.0", - "@libp2p/peer-id": "^2.0.0", - "@multiformats/mafmt": "^12.1.2", + "@libp2p/interface-connection": "^5.1.1", + "@libp2p/interface-metrics": "^4.0.8", + "@libp2p/interface-peer-id": "^2.0.2", + "@libp2p/interface-registrar": "^2.0.12", + "@libp2p/interface-stream-muxer": "^4.1.2", + "@libp2p/interface-transport": "^4.0.3", + "@libp2p/interfaces": "^3.3.2", + "@libp2p/logger": "^2.1.1", + "@libp2p/peer-id": "^2.0.4", + "@multiformats/mafmt": "^12.1.5", "@multiformats/multiaddr": "^12.1.3", "abortable-iterator": "^5.0.1", "detect-browser": "^5.3.0", @@ -68,17 +74,18 @@ "uint8arrays": "^4.0.4" }, "devDependencies": { - "@chainsafe/libp2p-yamux": "^4.0.1", - "@libp2p/interface-compliance-tests": "^3.0.0", - "@libp2p/peer-id-factory": "^2.0.0", - "@libp2p/websockets": "^6.0.0", + "@chainsafe/libp2p-yamux": "^4.0.2", + "@libp2p/interface-libp2p": "^3.2.0", + "@libp2p/interface-mocks": "^12.0.1", + "@libp2p/peer-id-factory": "^2.0.4", + "@libp2p/websockets": "^6.0.3", "@types/sinon": "^10.0.15", "aegir": "^39.0.10", "delay": "^6.0.0", "it-length": "^3.0.2", "it-map": "^3.0.3", "it-pair": "^2.0.6", - "libp2p": "^0.45.0", + "libp2p": "^0.45.9", "protons": "^7.0.2", "sinon": "^15.1.2", "sinon-ts": "^1.0.0" diff --git a/packages/transport-webrtc/src/error.ts b/packages/transport-webrtc/src/error.ts index 4c6d3b42df..360b4e3d73 100644 --- a/packages/transport-webrtc/src/error.ts +++ b/packages/transport-webrtc/src/error.ts @@ -1,5 +1,5 @@ -import { CodeError } from '@libp2p/interface/errors' -import type { Direction } from '@libp2p/interface/connection' +import { CodeError } from '@libp2p/interfaces/errors' +import type { Direction } from '@libp2p/interface-connection' export enum codes { ERR_ALREADY_ABORTED = 'ERR_ALREADY_ABORTED', diff --git a/packages/transport-webrtc/src/index.ts b/packages/transport-webrtc/src/index.ts index 0245aefcc9..b35a16ced4 100644 --- a/packages/transport-webrtc/src/index.ts +++ b/packages/transport-webrtc/src/index.ts @@ -1,7 +1,7 @@ import { WebRTCTransport } from './private-to-private/transport.js' import { WebRTCDirectTransport, type WebRTCTransportDirectInit, type WebRTCDirectTransportComponents } from './private-to-public/transport.js' import type { WebRTCTransportComponents, WebRTCTransportInit } from './private-to-private/transport.js' -import type { Transport } from '@libp2p/interface/transport' +import type { Transport } from '@libp2p/interface-transport' /** * @param {WebRTCTransportDirectInit} init - WebRTC direct transport configuration diff --git a/packages/transport-webrtc/src/maconn.ts b/packages/transport-webrtc/src/maconn.ts index 2281db9fa9..3ce4e3c458 100644 --- a/packages/transport-webrtc/src/maconn.ts +++ b/packages/transport-webrtc/src/maconn.ts @@ -1,7 +1,7 @@ import { logger } from '@libp2p/logger' import { nopSink, nopSource } from './util.js' -import type { MultiaddrConnection, MultiaddrConnectionTimeline } from '@libp2p/interface/connection' -import type { CounterGroup } from '@libp2p/interface/metrics' +import type { MultiaddrConnection, MultiaddrConnectionTimeline } from '@libp2p/interface-connection' +import type { CounterGroup } from '@libp2p/interface-metrics' import type { Multiaddr } from '@multiformats/multiaddr' import type { Source, Sink } from 'it-stream-types' diff --git a/packages/transport-webrtc/src/muxer.ts b/packages/transport-webrtc/src/muxer.ts index 93825a923b..95f925cf81 100644 --- a/packages/transport-webrtc/src/muxer.ts +++ b/packages/transport-webrtc/src/muxer.ts @@ -1,9 +1,9 @@ import { createStream } from './stream.js' import { nopSink, nopSource } from './util.js' import type { DataChannelOpts } from './stream.js' -import type { Stream } from '@libp2p/interface/connection' -import type { CounterGroup } from '@libp2p/interface/metrics' -import type { StreamMuxer, StreamMuxerFactory, StreamMuxerInit } from '@libp2p/interface/stream-muxer' +import type { Stream } from '@libp2p/interface-connection' +import type { CounterGroup } from '@libp2p/interface-metrics' +import type { StreamMuxer, StreamMuxerFactory, StreamMuxerInit } from '@libp2p/interface-stream-muxer' import type { Source, Sink } from 'it-stream-types' import type { Uint8ArrayList } from 'uint8arraylist' diff --git a/packages/transport-webrtc/src/private-to-private/handler.ts b/packages/transport-webrtc/src/private-to-private/handler.ts index 9818a224b8..176031b4fe 100644 --- a/packages/transport-webrtc/src/private-to-private/handler.ts +++ b/packages/transport-webrtc/src/private-to-private/handler.ts @@ -6,9 +6,9 @@ import { DataChannelMuxerFactory } from '../muxer.js' import { Message } from './pb/message.js' import { readCandidatesUntilConnected, resolveOnConnected } from './util.js' import type { DataChannelOpts } from '../stream.js' -import type { Stream } from '@libp2p/interface/connection' -import type { StreamMuxerFactory } from '@libp2p/interface/stream-muxer' -import type { IncomingStreamData } from '@libp2p/interface-internal/registrar' +import type { Stream } from '@libp2p/interface-connection' +import type { IncomingStreamData } from '@libp2p/interface-registrar' +import type { StreamMuxerFactory } from '@libp2p/interface-stream-muxer' const DEFAULT_TIMEOUT = 30 * 1000 diff --git a/packages/transport-webrtc/src/private-to-private/listener.ts b/packages/transport-webrtc/src/private-to-private/listener.ts index 1dccac6e25..018e569264 100644 --- a/packages/transport-webrtc/src/private-to-private/listener.ts +++ b/packages/transport-webrtc/src/private-to-private/listener.ts @@ -1,8 +1,7 @@ -import { EventEmitter } from '@libp2p/interface/events' +import { EventEmitter } from '@libp2p/interfaces/events' import { Circuit } from '@multiformats/mafmt' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { ListenerEvents, Listener } from '@libp2p/interface/transport' -import type { TransportManager } from '@libp2p/interface-internal/transport-manager' +import type { PeerId } from '@libp2p/interface-peer-id' +import type { ListenerEvents, Listener, TransportManager } from '@libp2p/interface-transport' import type { Multiaddr } from '@multiformats/multiaddr' export interface ListenerOptions { diff --git a/packages/transport-webrtc/src/private-to-private/transport.ts b/packages/transport-webrtc/src/private-to-private/transport.ts index ca24931930..196854d24e 100644 --- a/packages/transport-webrtc/src/private-to-private/transport.ts +++ b/packages/transport-webrtc/src/private-to-private/transport.ts @@ -1,5 +1,5 @@ -import { CodeError } from '@libp2p/interface/errors' -import { type CreateListenerOptions, type DialOptions, symbol, type Transport, type Listener, type Upgrader } from '@libp2p/interface/transport' +import { type CreateListenerOptions, type DialOptions, type Listener, symbol, type Transport, type Upgrader, type TransportManager } from '@libp2p/interface-transport' +import { CodeError } from '@libp2p/interfaces/errors' import { logger } from '@libp2p/logger' import { peerIdFromString } from '@libp2p/peer-id' import { multiaddr, type Multiaddr, protocols } from '@multiformats/multiaddr' @@ -8,11 +8,10 @@ import { WebRTCMultiaddrConnection } from '../maconn.js' import { initiateConnection, handleIncomingStream } from './handler.js' import { WebRTCPeerListener } from './listener.js' import type { DataChannelOpts } from '../stream.js' -import type { Connection } from '@libp2p/interface/connection' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { Startable } from '@libp2p/interface/startable' -import type { IncomingStreamData, Registrar } from '@libp2p/interface-internal/registrar' -import type { TransportManager } from '@libp2p/interface-internal/transport-manager' +import type { Connection } from '@libp2p/interface-connection' +import type { PeerId } from '@libp2p/interface-peer-id' +import type { IncomingStreamData, Registrar } from '@libp2p/interface-registrar' +import type { Startable } from '@libp2p/interfaces/startable' const log = logger('libp2p:webrtc:peer') diff --git a/packages/transport-webrtc/src/private-to-public/options.ts b/packages/transport-webrtc/src/private-to-public/options.ts index d30bc9f304..838c627ffe 100644 --- a/packages/transport-webrtc/src/private-to-public/options.ts +++ b/packages/transport-webrtc/src/private-to-public/options.ts @@ -1,4 +1,4 @@ -import type { CreateListenerOptions, DialOptions } from '@libp2p/interface/transport' +import type { CreateListenerOptions, DialOptions } from '@libp2p/interface-transport' export interface WebRTCListenerOptions extends CreateListenerOptions {} export interface WebRTCDialOptions extends DialOptions {} diff --git a/packages/transport-webrtc/src/private-to-public/transport.ts b/packages/transport-webrtc/src/private-to-public/transport.ts index c65f823387..c23b715c88 100644 --- a/packages/transport-webrtc/src/private-to-public/transport.ts +++ b/packages/transport-webrtc/src/private-to-public/transport.ts @@ -1,5 +1,5 @@ import { noise as Noise } from '@chainsafe/libp2p-noise' -import { type CreateListenerOptions, symbol, type Transport, type Listener } from '@libp2p/interface/transport' +import { type CreateListenerOptions, type Listener, symbol, type Transport } from '@libp2p/interface-transport' import { logger } from '@libp2p/logger' import * as p from '@libp2p/peer-id' import { protocols } from '@multiformats/multiaddr' @@ -15,9 +15,9 @@ import * as sdp from './sdp.js' import { genUfrag } from './util.js' import type { WebRTCDialOptions } from './options.js' import type { DataChannelOpts } from '../stream.js' -import type { Connection } from '@libp2p/interface/connection' -import type { CounterGroup, Metrics } from '@libp2p/interface/metrics' -import type { PeerId } from '@libp2p/interface/peer-id' +import type { Connection } from '@libp2p/interface-connection' +import type { CounterGroup, Metrics } from '@libp2p/interface-metrics' +import type { PeerId } from '@libp2p/interface-peer-id' import type { Multiaddr } from '@multiformats/multiaddr' const log = logger('libp2p:webrtc:transport') diff --git a/packages/transport-webrtc/src/stream.ts b/packages/transport-webrtc/src/stream.ts index bc997397a8..fe5482bca3 100644 --- a/packages/transport-webrtc/src/stream.ts +++ b/packages/transport-webrtc/src/stream.ts @@ -1,12 +1,12 @@ -import { CodeError } from '@libp2p/interface/errors' -import { AbstractStream, type AbstractStreamInit } from '@libp2p/interface/stream-muxer/stream' +import { AbstractStream, type AbstractStreamInit } from '@libp2p/interface-stream-muxer/stream' +import { CodeError } from '@libp2p/interfaces/errors' import { logger } from '@libp2p/logger' import * as lengthPrefixed from 'it-length-prefixed' import { type Pushable, pushable } from 'it-pushable' import { pEvent, TimeoutError } from 'p-event' import { Uint8ArrayList } from 'uint8arraylist' import { Message } from './pb/message.js' -import type { Direction, Stream } from '@libp2p/interface/connection' +import type { Direction, Stream } from '@libp2p/interface-connection' const log = logger('libp2p:webrtc:stream') diff --git a/packages/transport-webrtc/test/basics.spec.ts b/packages/transport-webrtc/test/basics.spec.ts index a241d15c54..49a7787a76 100644 --- a/packages/transport-webrtc/test/basics.spec.ts +++ b/packages/transport-webrtc/test/basics.spec.ts @@ -14,8 +14,8 @@ import { createLibp2p } from 'libp2p' import { circuitRelayTransport } from 'libp2p/circuit-relay' import { identifyService } from 'libp2p/identify' import { webRTC } from '../src/index.js' -import type { Libp2p } from '@libp2p/interface' -import type { Connection } from '@libp2p/interface/connection' +import type { Connection } from '@libp2p/interface-connection' +import type { Libp2p } from '@libp2p/interface-libp2p' async function createNode (): Promise { return createLibp2p({ @@ -85,16 +85,6 @@ describe('basics', () => { remoteNode = await createNode() }) - afterEach(async () => { - if (localNode != null) { - await localNode.stop() - } - - if (remoteNode != null) { - await remoteNode.stop() - } - }) - it('can dial through a relay', async () => { const connection = await connectNodes() diff --git a/packages/transport-webrtc/test/listener.spec.ts b/packages/transport-webrtc/test/listener.spec.ts index e4e6dc149c..4928ca682c 100644 --- a/packages/transport-webrtc/test/listener.spec.ts +++ b/packages/transport-webrtc/test/listener.spec.ts @@ -3,8 +3,7 @@ import { multiaddr } from '@multiformats/multiaddr' import { expect } from 'aegir/chai' import { stubInterface } from 'sinon-ts' import { WebRTCPeerListener } from '../src/private-to-private/listener' -import type { Listener } from '@libp2p/interface/transport' -import type { TransportManager } from '@libp2p/interface-internal/transport-manager' +import type { Listener, TransportManager } from '@libp2p/interface-transport' describe('webrtc private-to-private listener', () => { it('should only return relay addresses as webrtc listen addresses', async () => { diff --git a/packages/transport-webrtc/test/maconn.browser.spec.ts b/packages/transport-webrtc/test/maconn.browser.spec.ts index a8e91272c4..9a25dc541c 100644 --- a/packages/transport-webrtc/test/maconn.browser.spec.ts +++ b/packages/transport-webrtc/test/maconn.browser.spec.ts @@ -4,7 +4,7 @@ import { multiaddr } from '@multiformats/multiaddr' import { expect } from 'aegir/chai' import { stubObject } from 'sinon-ts' import { WebRTCMultiaddrConnection } from '../src/maconn.js' -import type { CounterGroup } from '@libp2p/interface/metrics' +import type { CounterGroup } from '@libp2p/interface-metrics' describe('Multiaddr Connection', () => { it('can open and close', async () => { diff --git a/packages/transport-webrtc/test/peer.browser.spec.ts b/packages/transport-webrtc/test/peer.browser.spec.ts index ae3b79d325..25fe8284bb 100644 --- a/packages/transport-webrtc/test/peer.browser.spec.ts +++ b/packages/transport-webrtc/test/peer.browser.spec.ts @@ -1,4 +1,4 @@ -import { mockConnection, mockMultiaddrConnection, mockRegistrar, mockStream, mockUpgrader } from '@libp2p/interface-compliance-tests/mocks' +import { mockConnection, mockMultiaddrConnection, mockRegistrar, mockStream, mockUpgrader } from '@libp2p/interface-mocks' import { createEd25519PeerId } from '@libp2p/peer-id-factory' import { multiaddr } from '@multiformats/multiaddr' import { expect } from 'aegir/chai' diff --git a/packages/transport-webrtc/test/stream.browser.spec.ts b/packages/transport-webrtc/test/stream.browser.spec.ts index a098d93a24..ee57a61d84 100644 --- a/packages/transport-webrtc/test/stream.browser.spec.ts +++ b/packages/transport-webrtc/test/stream.browser.spec.ts @@ -4,7 +4,7 @@ import * as lengthPrefixed from 'it-length-prefixed' import { bytes } from 'multiformats' import { Message } from '../src/pb/message.js' import { createStream } from '../src/stream' -import type { Stream } from '@libp2p/interface/connection' +import type { Stream } from '@libp2p/interface-connection' const TEST_MESSAGE = 'test_message' function setup (): { peerConnection: RTCPeerConnection, dataChannel: RTCDataChannel, stream: Stream } { diff --git a/packages/transport-webrtc/test/transport.browser.spec.ts b/packages/transport-webrtc/test/transport.browser.spec.ts index ea7b56d545..dea6c68fbd 100644 --- a/packages/transport-webrtc/test/transport.browser.spec.ts +++ b/packages/transport-webrtc/test/transport.browser.spec.ts @@ -1,14 +1,14 @@ /* eslint-disable @typescript-eslint/no-floating-promises */ -import { type CreateListenerOptions, symbol } from '@libp2p/interface/transport' -import { mockMetrics, mockUpgrader } from '@libp2p/interface-compliance-tests/mocks' +import { mockMetrics, mockUpgrader } from '@libp2p/interface-mocks' +import { type CreateListenerOptions, symbol } from '@libp2p/interface-transport' import { createEd25519PeerId } from '@libp2p/peer-id-factory' import { multiaddr, type Multiaddr } from '@multiformats/multiaddr' import { expect, assert } from 'aegir/chai' import { UnimplementedError } from '../src/error.js' import * as underTest from '../src/private-to-public/transport.js' import { expectError } from './util.js' -import type { Metrics } from '@libp2p/interface/metrics' +import type { Metrics } from '@libp2p/interface-metrics' function ignoredDialOption (): CreateListenerOptions { const upgrader = mockUpgrader({}) diff --git a/packages/transport-webrtc/tsconfig.json b/packages/transport-webrtc/tsconfig.json index 4008808465..aa7a3a98ba 100644 --- a/packages/transport-webrtc/tsconfig.json +++ b/packages/transport-webrtc/tsconfig.json @@ -10,13 +10,31 @@ ], "references": [ { - "path": "../interface" + "path": "../interface-connection" }, { - "path": "../interface-compliance-tests" + "path": "../interface-libp2p" }, { - "path": "../interface-internal" + "path": "../interface-metrics" + }, + { + "path": "../interface-mocks" + }, + { + "path": "../interface-peer-id" + }, + { + "path": "../interface-registrar" + }, + { + "path": "../interface-stream-muxer" + }, + { + "path": "../interface-transport" + }, + { + "path": "../interfaces" }, { "path": "../libp2p"