diff --git a/.aegir.js b/.aegir.js index d5ec69f..daf5fab 100644 --- a/.aegir.js +++ b/.aegir.js @@ -3,6 +3,6 @@ export default { config: { platform: 'node' }, - bundlesizeMax: '31KB' + bundlesizeMax: '117KB' } } diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 290ad02..0bc3b42 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -6,3 +6,6 @@ updates: interval: daily time: "10:00" open-pull-requests-limit: 10 + commit-message: + prefix: "deps" + prefix-development: "deps(dev)" diff --git a/.github/workflows/automerge.yml b/.github/workflows/automerge.yml index 3833fc2..d57c2a0 100644 --- a/.github/workflows/automerge.yml +++ b/.github/workflows/automerge.yml @@ -1,6 +1,3 @@ -# File managed by web3-bot. DO NOT EDIT. -# See https://github.com/protocol/.github/ for details. - name: Automerge on: [ pull_request ] diff --git a/.github/workflows/js-test-and-release.yml b/.github/workflows/js-test-and-release.yml index 2426eb1..1051cb3 100644 --- a/.github/workflows/js-test-and-release.yml +++ b/.github/workflows/js-test-and-release.yml @@ -4,9 +4,6 @@ on: branches: - main # with #262 - ${{{ github.default_branch }}} pull_request: - branches: - - main # with #262 - ${{{ github.default_branch }}} - - develop jobs: @@ -14,19 +11,38 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: actions/setup-node@v2 + - uses: actions/setup-node@v3 with: node-version: lts/* - uses: ipfs/aegir/actions/cache-node-modules@master - run: npm run --if-present lint - run: npm run --if-present dep-check + test-node: + needs: check + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [windows-latest, ubuntu-latest, macos-latest] + node: [lts/*] + fail-fast: true + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + 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 + with: + flags: node + test-chrome: needs: check runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: actions/setup-node@v2 + - uses: actions/setup-node@v3 with: node-version: lts/* - uses: ipfs/aegir/actions/cache-node-modules@master @@ -35,12 +51,26 @@ jobs: with: flags: chrome + test-chrome-webworker: + needs: check + runs-on: ubuntu-latest + 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:chrome-webworker + - uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0 + with: + flags: chrome-webworker + test-firefox: needs: check runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: actions/setup-node@v2 + - uses: actions/setup-node@v3 with: node-version: lts/* - uses: ipfs/aegir/actions/cache-node-modules@master @@ -49,15 +79,57 @@ jobs: with: flags: firefox + test-firefox-webworker: + needs: check + runs-on: ubuntu-latest + 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:firefox-webworker + - uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0 + with: + flags: firefox-webworker + + test-electron-main: + needs: check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + 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 + with: + flags: electron-main + + test-electron-renderer: + needs: check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + 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 + with: + flags: electron-renderer + release: - needs: [test-chrome, test-firefox] + needs: [test-node, test-chrome, test-chrome-webworker, test-firefox, test-firefox-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/main' # with #262 - 'refs/heads/${{{ github.default_branch }}}' steps: - uses: actions/checkout@v3 with: fetch-depth: 0 - - uses: actions/setup-node@v2 + - uses: actions/setup-node@v3 with: node-version: lts/* - uses: ipfs/aegir/actions/cache-node-modules@master diff --git a/.nvmrc b/.nvmrc deleted file mode 100644 index 975215f..0000000 --- a/.nvmrc +++ /dev/null @@ -1 +0,0 @@ -16.17.0 \ No newline at end of file diff --git a/.prettierrc b/.prettierrc deleted file mode 100644 index 45dab6f..0000000 --- a/.prettierrc +++ /dev/null @@ -1,14 +0,0 @@ -{ - "printWidth":180, - "tabWidth":2, - "useTabs":false, - "semi":true, - "singleQuote":true, - "trailingComma":"es5", - "bracketSpacing":true, - "jsxBracketSameLine":false, - "arrowParens":"always", - "requirePragma":false, - "insertPragma":false, - "proseWrap":"preserve" -} diff --git a/README.md b/README.md index 7c09902..f789710 100644 --- a/README.md +++ b/README.md @@ -1,36 +1,43 @@ # @libp2p/webrtc [![libp2p.io](https://img.shields.io/badge/project-libp2p-yellow.svg?style=flat-square)](http://libp2p.io/) -[![IRC](https://img.shields.io/badge/freenode-%23libp2p-yellow.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23libp2p) [![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/little-bear-labs/js-libp2p-webrtc.svg?style=flat-square)](https://codecov.io/gh/little-bear-labs/js-libp2p-webrtc) -[![CI](https://img.shields.io/github/workflow/status/libp2p/js-libp2p-interfaces/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/little-bear-labs/js-libp2p-webrtc/actions/workflows/js-test-and-release.yml) +[![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) -> The browser implementation of the WebRTC module for libp2p. +> A libp2p transport using WebRTC connections ## Table of contents - [Install](#install) + - [Browser ` ``` ## Usage @@ -52,13 +59,14 @@ const node = await createLibp2p({ await node.start() const ma = multiaddr('/ip4/0.0.0.0/udp/56093/webrtc/certhash/uEiByaEfNSLBexWBNFZy_QB1vAKEj7JAXDizRs4_SnTflsQ') -const stream = await node.dialProtocol(ma, ['/my-protocol/1.0.0']) +const stream = await node.dialProtocol(ma, ['/my-protocol/1.0.0']) const message = `Hello js-libp2p-webrtc\n` const response = await pipe([fromString(message)], stream, async (source) => await first(source)) const responseDecoded = toString(response.slice(0, response.length)) ``` ## Examples + Examples can be found in the [examples folder](examples/README.md). ## Interfaces @@ -106,7 +114,7 @@ interface MultiaddrConnection extends Duplex { class WebRTCMultiaddrConnection implements MultiaddrConnection { } ``` -## Contribute +## Development Contributions are welcome! The libp2p implementation in JavaScript is a work in progress. As such, there's a few things you can do right now to help out: @@ -119,9 +127,10 @@ Please be aware that all interactions related to libp2p are subject to the IPFS Small note: If editing the README, please conform to the [standard-readme](https://github.com/RichardLitt/standard-readme) specification. -This module leans heavily on (Aegir)[https://github.com/ipfs/aegir] for most of the `package.json` scripts. +This module leans heavily on (Aegir)\[] for most of the `package.json` scripts. ### Build + The build script is a wrapper to `aegir build`. To build this package: ```shell @@ -142,7 +151,7 @@ To run all tests: npm test ``` -To run tests for Chome only: +To run tests for Chrome only: ```shell npm run test:chrome @@ -155,8 +164,9 @@ npm run test:firefox ``` ### Lint + Aegir is also used to lint the code, which follows the [Standard](https://github.com/standard/standard) JS linter. -The VS Code plugin for this standard is located at https://marketplace.visualstudio.com/items?itemName=standard.vscode-standard. +The VS Code plugin for this standard is located at . To lint this repo: ```shell @@ -181,11 +191,6 @@ npm run clean npm run deps-check ``` -### Build a Release - -```shell -npm run release -``` ## License Licensed under either of @@ -193,6 +198,6 @@ Licensed under either of - Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) - MIT ([LICENSE-MIT](LICENSE-MIT) / ) -## Contribution +## Contribute -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. \ No newline at end of file +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. diff --git a/examples/browser-to-server/index.js b/examples/browser-to-server/index.js index fdd5487..8817151 100644 --- a/examples/browser-to-server/index.js +++ b/examples/browser-to-server/index.js @@ -6,34 +6,34 @@ import { pipe } from "it-pipe"; import { fromString, toString } from "uint8arrays"; import { webRTC } from 'js-libp2p-webrtc' - let stream; - const output = document.getElementById('output') - const sendSection = document.getElementById('send-section') - const appendOutput = (line) => output.innerText += `${line}\n` - const clean = (line) => line.replaceAll('\n', '') +let stream; +const output = document.getElementById('output') +const sendSection = document.getElementById('send-section') +const appendOutput = (line) => output.innerText += `${line}\n` +const clean = (line) => line.replaceAll('\n', '') - const node = await createLibp2p({ - transports: [webRTC()], - connectionEncryption: [() => new Noise()], - }); - - await node.start() +const node = await createLibp2p({ + transports: [webRTC()], + connectionEncryption: [() => new Noise()], +}); - node.connectionManager.addEventListener('peer:connect', (connection) => { - appendOutput(`Peer connected '${node.getConnections().map(c => c.remoteAddr.toString())}'`) - sendSection.style.display = 'block' - }) - - window.connect.onclick = async () => { - const ma = multiaddr(window.peer.value) - appendOutput(`Dialing ${ma}`) - stream = await node.dialProtocol(ma, ['/echo/1.0.0']) - } - - window.send.onclick = async () => { - const message = `${window.message.value}\n` - appendOutput(`Sending message '${clean(message)}'`) - const response = await pipe([fromString(message)], stream, async (source) => await first(source)) - const responseDecoded = toString(response.slice(0, response.length)); - appendOutput(`Received message '${clean(responseDecoded)}'`) - } \ No newline at end of file +await node.start() + +node.connectionManager.addEventListener('peer:connect', (connection) => { + appendOutput(`Peer connected '${node.getConnections().map(c => c.remoteAddr.toString())}'`) + sendSection.style.display = 'block' +}) + +window.connect.onclick = async () => { + const ma = multiaddr(window.peer.value) + appendOutput(`Dialing ${ma}`) + stream = await node.dialProtocol(ma, ['/echo/1.0.0']) +} + +window.send.onclick = async () => { + const message = `${window.message.value}\n` + appendOutput(`Sending message '${clean(message)}'`) + const response = await pipe([fromString(message)], stream, async (source) => await first(source)) + const responseDecoded = toString(response.slice(0, response.length)); + appendOutput(`Received message '${clean(responseDecoded)}'`) +} diff --git a/package.json b/package.json index 2ab4028..0337a92 100644 --- a/package.json +++ b/package.json @@ -1,52 +1,127 @@ { - "name": "js-libp2p-webrtc", - "version": "1.0.0", - "description": "Dial peer using webrtc", + "name": "@libp2p/webrtc", + "version": "0.0.0", + "description": "A libp2p transport using WebRTC connections", "author": "", - "license": "Apache-2.0 or MIT", - "type": "module", - "types": "./dist/src/index.d.ts", - "typesVersions": { - "*": { - "*": [ - "*", - "dist/*", - "dist/src/*", - "dist/proto_ts/*", - "dist/src/*/index" - ], - "src/*": [ - "*", - "dist/*", - "dist/src/*", - "dist/src/*/index" - ] - } + "license": "Apache-2.0 OR MIT", + "homepage": "https://github.com/libp2p/js-libp2p-webrtc#readme", + "repository": { + "type": "git", + "url": "git+https://github.com/libp2p/js-libp2p-webrtc.git" }, - "eslintConfig": { - "extends": "ipfs", - "parserOptions": { - "sourceType": "module" - } + "bugs": { + "url": "https://github.com/libp2p/js-libp2p-webrtc/issues" }, "engines": { "node": ">=16.0.0", "npm": ">=7.0.0" }, + "type": "module", + "types": "./dist/src/index.d.ts", + "files": [ + "src", + "dist", + "!dist/test", + "!**/*.tsbuildinfo", + "proto_ts" + ], "exports": { ".": { "types": "./src/index.d.ts", "import": "./dist/src/index.js" } }, - "files": [ - "src", - "proto_ts", - "dist/src", - "dist/proto_ts", - "!dist/test", - "!**/*.tsbuildinfo" - ], + "eslintConfig": { + "extends": "ipfs", + "parserOptions": { + "sourceType": "module" + } + }, + "release": { + "branches": [ + "main" + ], + "plugins": [ + [ + "@semantic-release/commit-analyzer", + { + "preset": "conventionalcommits", + "releaseRules": [ + { + "breaking": true, + "release": "major" + }, + { + "revert": true, + "release": "patch" + }, + { + "type": "feat", + "release": "minor" + }, + { + "type": "fix", + "release": "patch" + }, + { + "type": "docs", + "release": "patch" + }, + { + "type": "test", + "release": "patch" + }, + { + "type": "deps", + "release": "patch" + }, + { + "scope": "no-release", + "release": false + } + ] + } + ], + [ + "@semantic-release/release-notes-generator", + { + "preset": "conventionalcommits", + "presetConfig": { + "types": [ + { + "type": "feat", + "section": "Features" + }, + { + "type": "fix", + "section": "Bug Fixes" + }, + { + "type": "chore", + "section": "Trivial Changes" + }, + { + "type": "docs", + "section": "Documentation" + }, + { + "type": "deps", + "section": "Dependencies" + }, + { + "type": "test", + "section": "Tests" + } + ] + } + } + ], + "@semantic-release/changelog", + "@semantic-release/npm", + "@semantic-release/github", + "@semantic-release/git" + ] + }, "scripts": { "generate:proto": "npx protoc --ts_out proto_ts --proto_path src src/*.proto", "build": "aegir build", @@ -59,32 +134,13 @@ "dep-check": "aegir dep-check", "release": "aegir release" }, - "devDependencies": { - "@libp2p/interface-mocks": "^8.0.1", - "@libp2p/peer-id-factory": "^1.0.19", - "@protobuf-ts/plugin": "^2.8.0", - "@protobuf-ts/protoc": "^2.8.0", - "@types/uuid": "^8.3.4", - "@typescript-eslint/parser": "^5.32.0", - "aegir": "^37.4.6", - "chai": "^4.3.6", - "chai-bytes": "^0.1.2", - "it-first": "^2.0.0", - "libp2p": "^0.40.0", - "npm-run-all": "^4.1.5", - "prettier": "^2.7.1", - "typescript": "^4.7.4" - }, "dependencies": { "@chainsafe/libp2p-noise": "^10.0.0", - "@libp2p/components": "^3.0.2", "@libp2p/interface-connection": "^3.0.2", "@libp2p/interface-peer-id": "^1.0.5", "@libp2p/interface-stream-muxer": "^3.0.0", "@libp2p/interface-transport": "^2.0.0", - "@libp2p/interfaces": "^3.0.2", "@libp2p/logger": "^2.0.0", - "@libp2p/multistream-select": "^3.0.2", "@libp2p/peer-id": "^1.1.15", "@multiformats/multiaddr": "^11.0.3", "@protobuf-ts/runtime": "^2.8.0", @@ -97,9 +153,18 @@ "multiformats": "^10.0.0", "multihashes": "^4.0.3", "p-defer": "^4.0.0", - "timeout-abort-controller": "^3.0.0", "uint8arraylist": "^2.3.3", "uint8arrays": "^4.0.2", "uuid": "^9.0.0" + }, + "devDependencies": { + "@libp2p/interface-mocks": "^8.0.1", + "@libp2p/peer-id-factory": "^1.0.19", + "@protobuf-ts/plugin": "^2.8.0", + "@protobuf-ts/protoc": "^2.8.0", + "@types/uuid": "^8.3.4", + "aegir": "^37.6.6", + "it-first": "^2.0.0", + "libp2p": "^0.40.0" } } diff --git a/proto_ts/message.ts b/proto_ts/message.ts index 5d0560f..2a96f67 100644 --- a/proto_ts/message.ts +++ b/proto_ts/message.ts @@ -1,6 +1,7 @@ // @generated by protobuf-ts 2.8.1 // @generated from protobuf file "message.proto" (package "webrtc.pb", syntax proto2) // tslint:disable +// @ts-nocheck import type { BinaryWriteOptions } from "@protobuf-ts/runtime"; import type { IBinaryWriter } from "@protobuf-ts/runtime"; import { WireType } from "@protobuf-ts/runtime"; diff --git a/src/error.ts b/src/error.ts index f22136a..fe05ec1 100644 --- a/src/error.ts +++ b/src/error.ts @@ -1,5 +1,5 @@ import errCode from 'err-code' -import { Direction } from '@libp2p/interface-connection' +import type { Direction } from '@libp2p/interface-connection' export enum codes { ERR_ALREADY_ABORTED = 'ERR_ALREADY_ABORTED', diff --git a/src/index.ts b/src/index.ts index fd48910..826069a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,4 @@ -import { Transport } from '@libp2p/interface-transport' +import type { Transport } from '@libp2p/interface-transport' import { WebRTCTransport, WebRTCTransportComponents } from './transport.js' export function webRTC (): (components: WebRTCTransportComponents) => Transport { diff --git a/src/maconn.ts b/src/maconn.ts index cd9d30d..49c67e1 100644 --- a/src/maconn.ts +++ b/src/maconn.ts @@ -1,7 +1,7 @@ -import { MultiaddrConnection, MultiaddrConnectionTimeline } from '@libp2p/interface-connection' +import type { MultiaddrConnection, MultiaddrConnectionTimeline } from '@libp2p/interface-connection' import { logger } from '@libp2p/logger' -import { Multiaddr } from '@multiformats/multiaddr' -import { Source, Sink } from 'it-stream-types' +import type { Multiaddr } from '@multiformats/multiaddr' +import type { Source, Sink } from 'it-stream-types' import { nopSink, nopSource } from './util.js' diff --git a/src/muxer.ts b/src/muxer.ts index b4c9f9d..7b0eb83 100644 --- a/src/muxer.ts +++ b/src/muxer.ts @@ -1,6 +1,6 @@ -import { Stream } from '@libp2p/interface-connection' -import { StreamMuxer, StreamMuxerFactory, StreamMuxerInit } from '@libp2p/interface-stream-muxer' -import { Source, Sink } from 'it-stream-types' +import type { Stream } from '@libp2p/interface-connection' +import type { StreamMuxer, StreamMuxerFactory, StreamMuxerInit } from '@libp2p/interface-stream-muxer' +import type { Source, Sink } from 'it-stream-types' import { WebRTCStream } from './stream.js' import { nopSink, nopSource } from './util.js' diff --git a/src/options.ts b/src/options.ts index debd186..838c627 100644 --- a/src/options.ts +++ b/src/options.ts @@ -1,4 +1,4 @@ -import { 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/src/sdp.ts b/src/sdp.ts index f7302d8..10b1591 100644 --- a/src/sdp.ts +++ b/src/sdp.ts @@ -1,5 +1,5 @@ import { logger } from '@libp2p/logger' -import { Multiaddr } from '@multiformats/multiaddr' +import type { Multiaddr } from '@multiformats/multiaddr' import { bases } from 'multiformats/basics' import * as multihashes from 'multihashes' diff --git a/src/stream.ts b/src/stream.ts index 54b2870..77ca333 100644 --- a/src/stream.ts +++ b/src/stream.ts @@ -1,11 +1,11 @@ -import { Stream, StreamStat, Direction } from '@libp2p/interface-connection' +import type { Stream, StreamStat, Direction } from '@libp2p/interface-connection' import { logger } from '@libp2p/logger' import * as lengthPrefixed from 'it-length-prefixed' import merge from 'it-merge' import { pipe } from 'it-pipe' import { pushable } from 'it-pushable' import defer, { DeferredPromise } from 'p-defer' -import { Source, Sink } from 'it-stream-types' +import type { Source, Sink } from 'it-stream-types' import { Uint8ArrayList } from 'uint8arraylist' import * as pb from '../proto_ts/message.js' diff --git a/src/transport.ts b/src/transport.ts index 44bfd0d..6fc10bd 100644 --- a/src/transport.ts +++ b/src/transport.ts @@ -1,10 +1,10 @@ import { noise as Noise } from '@chainsafe/libp2p-noise' -import { Connection } from '@libp2p/interface-connection' +import type { Connection } from '@libp2p/interface-connection' import type { PeerId } from '@libp2p/interface-peer-id' import { CreateListenerOptions, Listener, symbol, Transport } from '@libp2p/interface-transport' import { logger } from '@libp2p/logger' import * as p from '@libp2p/peer-id' -import { Multiaddr } from '@multiformats/multiaddr' +import type { Multiaddr } from '@multiformats/multiaddr' import * as multihashes from 'multihashes' import defer from 'p-defer' import { v4 as genUuid } from 'uuid' @@ -14,7 +14,7 @@ import { concat } from 'uint8arrays/concat' import { dataChannelError, inappropriateMultiaddr, unimplemented, invalidArgument } from './error.js' import { WebRTCMultiaddrConnection } from './maconn.js' import { DataChannelMuxerFactory } from './muxer.js' -import { WebRTCDialOptions } from './options.js' +import type { WebRTCDialOptions } from './options.js' import * as sdp from './sdp.js' import { WebRTCStream } from './stream.js' diff --git a/test/maconn.browser.spec.ts b/test/maconn.browser.spec.ts index ff4c2dc..ffc68f7 100644 --- a/test/maconn.browser.spec.ts +++ b/test/maconn.browser.spec.ts @@ -1,8 +1,8 @@ /* eslint-disable @typescript-eslint/no-unused-expressions */ import { multiaddr } from '@multiformats/multiaddr' -import { expect } from 'chai' -import { WebRTCMultiaddrConnection } from './../src/maconn' +import { expect } from 'aegir/chai' +import { WebRTCMultiaddrConnection } from './../src/maconn.js' describe('Multiaddr Connection', () => { it('can open and close', async () => { diff --git a/test/sdp.spec.ts b/test/sdp.spec.ts index 8055cc0..8472f0d 100644 --- a/test/sdp.spec.ts +++ b/test/sdp.spec.ts @@ -1,6 +1,6 @@ import { multiaddr } from '@multiformats/multiaddr' -import { expect } from 'chai' -import * as underTest from '../src/sdp' +import { expect } from 'aegir/chai' +import * as underTest from '../src/sdp.js' const sampleMultiAddr = multiaddr('/ip4/0.0.0.0/udp/56093/webrtc/certhash/uEiByaEfNSLBexWBNFZy_QB1vAKEj7JAXDizRs4_SnTflsQ') const sampleCerthash = 'uEiByaEfNSLBexWBNFZy_QB1vAKEj7JAXDizRs4_SnTflsQ' diff --git a/test/stream.browser.spec.ts b/test/stream.browser.spec.ts index 0d962c8..4418bbf 100644 --- a/test/stream.browser.spec.ts +++ b/test/stream.browser.spec.ts @@ -1,5 +1,5 @@ import * as underTest from '../src/stream' -import { expect, assert } from 'chai' +import { expect, assert } from 'aegir/chai' function setup (): { peerConnection: RTCPeerConnection, datachannel: RTCDataChannel, webrtcStream: underTest.WebRTCStream } { const peerConnection = new RTCPeerConnection() diff --git a/test/transport.browser.spec.ts b/test/transport.browser.spec.ts index 8cc58cc..e52946c 100644 --- a/test/transport.browser.spec.ts +++ b/test/transport.browser.spec.ts @@ -1,13 +1,13 @@ /* eslint-disable @typescript-eslint/no-floating-promises */ -import * as underTest from './../src/transport' -import { expectError } from './util' -import { UnimplementedError } from './../src/error' +import * as underTest from './../src/transport.js' +import { expectError } from './util.js' +import { UnimplementedError } from './../src/error.js' import { mockUpgrader } from '@libp2p/interface-mocks' import { CreateListenerOptions, symbol } from '@libp2p/interface-transport' import { multiaddr, Multiaddr } from '@multiformats/multiaddr' import { createEd25519PeerId } from '@libp2p/peer-id-factory' -import { expect, assert } from 'chai' +import { expect, assert } from 'aegir/chai' function ignoredDialOption (): CreateListenerOptions { const upgrader = mockUpgrader({}) diff --git a/test/util.ts b/test/util.ts index 415e643..e13bbf7 100644 --- a/test/util.ts +++ b/test/util.ts @@ -1,4 +1,4 @@ -import { expect } from 'chai' +import { expect } from 'aegir/chai' export const expectError = (error: unknown, message: string) => { if (error instanceof Error) { diff --git a/tsconfig.json b/tsconfig.json index 0849b1c..933f467 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,17 +1,11 @@ { - "extends": "aegir/src/config/tsconfig.aegir.json", - "compilerOptions": { - "allowJs": true, - "allowSyntheticDefaultImports": true, - "emitDeclarationOnly": false, - "importsNotUsedAsValues": "preserve", - "module": "ES2020", - "moduleResolution": "node", - "outDir": "dist" - }, - "include": [ - "src", - "test", - "proto_ts" - ] + "extends": "aegir/src/config/tsconfig.aegir.json", + "compilerOptions": { + "outDir": "dist" + }, + "include": [ + "src", + "test", + "proto_ts" + ] }