From d2fb9924c7210ec8c8e0f2a5e55464b1b9c9bf02 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 6 Jun 2023 14:09:29 +0000 Subject: [PATCH 1/2] deps(dev): bump aegir from 38.1.8 to 39.0.9 Bumps [aegir](https://github.com/ipfs/aegir) from 38.1.8 to 39.0.9. - [Release notes](https://github.com/ipfs/aegir/releases) - [Changelog](https://github.com/ipfs/aegir/blob/master/CHANGELOG.md) - [Commits](https://github.com/ipfs/aegir/compare/v38.1.8...v39.0.9) --- updated-dependencies: - dependency-name: aegir dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ca5ae56..6e1efde 100644 --- a/package.json +++ b/package.json @@ -178,7 +178,7 @@ "devDependencies": { "@libp2p/interface-mocks": "^11.0.0", "@libp2p/interface-transport-compliance-tests": "^4.0.0", - "aegir": "^38.1.7", + "aegir": "^39.0.9", "is-loopback-addr": "^2.0.1", "it-all": "^3.0.1", "it-drain": "^3.0.1", From c66ad6f956acea0d5204a3eb16dff1f7f4224d84 Mon Sep 17 00:00:00 2001 From: achingbrain Date: Tue, 6 Jun 2023 15:10:43 +0100 Subject: [PATCH 2/2] chore: fix linting --- src/filters.ts | 2 +- src/index.ts | 20 ++++++++------------ src/listener.ts | 12 ++++++------ src/socket-to-conn.ts | 6 +++--- test/browser.ts | 16 ++++++++-------- test/compliance.node.ts | 4 ++-- test/node.ts | 20 ++++++++++---------- 7 files changed, 38 insertions(+), 42 deletions(-) diff --git a/src/filters.ts b/src/filters.ts index e848d92..8536e7c 100644 --- a/src/filters.ts +++ b/src/filters.ts @@ -1,5 +1,4 @@ import * as mafmt from '@multiformats/mafmt' -import type { Multiaddr } from '@multiformats/multiaddr' import { CODE_CIRCUIT, CODE_P2P, @@ -7,6 +6,7 @@ import { CODE_WS, CODE_WSS } from './constants.js' +import type { Multiaddr } from '@multiformats/multiaddr' export function all (multiaddrs: Multiaddr[]): Multiaddr[] { return multiaddrs.filter((ma) => { diff --git a/src/index.ts b/src/index.ts index 392f8d9..0ce23bd 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,19 +1,19 @@ -import { connect, WebSocketOptions } from 'it-ws/client' -import { multiaddrToUri as toUri } from '@multiformats/multiaddr-to-uri' +import { type Transport, type MultiaddrFilter, symbol, type CreateListenerOptions, type DialOptions, type Listener } from '@libp2p/interface-transport' import { AbortError } from '@libp2p/interfaces/errors' -import pDefer from 'p-defer' import { logger } from '@libp2p/logger' +import { multiaddrToUri as toUri } from '@multiformats/multiaddr-to-uri' +import { connect, type WebSocketOptions } from 'it-ws/client' +import pDefer from 'p-defer' import { isBrowser, isWebWorker } from 'wherearewe' +import * as filters from './filters.js' import { createListener } from './listener.js' import { socketToMaConn } from './socket-to-conn.js' -import * as filters from './filters.js' -import { Transport, MultiaddrFilter, symbol, CreateListenerOptions, DialOptions, Listener } from '@libp2p/interface-transport' import type { Connection } from '@libp2p/interface-connection' import type { AbortOptions } from '@libp2p/interfaces' import type { Multiaddr } from '@multiformats/multiaddr' +import type { Server } from 'http' import type { DuplexWebSocket } from 'it-ws/duplex' import type { ClientOptions } from 'ws' -import type { Server } from 'http' const log = logger('libp2p:websockets') @@ -30,13 +30,9 @@ class WebSockets implements Transport { this.init = init } - get [Symbol.toStringTag] (): string { - return '@libp2p/websockets' - } + readonly [Symbol.toStringTag] = '@libp2p/websockets' - get [symbol] (): true { - return true - } + readonly [symbol] = true async dial (ma: Multiaddr, options: DialOptions): Promise { log('dialing %s', ma) diff --git a/src/listener.ts b/src/listener.ts index 64d7bac..abb63aa 100644 --- a/src/listener.ts +++ b/src/listener.ts @@ -1,16 +1,16 @@ import os from 'os' +import { EventEmitter, CustomEvent } from '@libp2p/interfaces/events' +import { logger } from '@libp2p/logger' +import { ipPortToMultiaddr as toMultiaddr } from '@libp2p/utils/ip-port-to-multiaddr' import { multiaddr, protocols } from '@multiformats/multiaddr' import { createServer } from 'it-ws/server' -import { logger } from '@libp2p/logger' import { socketToMaConn } from './socket-to-conn.js' -import { ipPortToMultiaddr as toMultiaddr } from '@libp2p/utils/ip-port-to-multiaddr' +import type { Connection } from '@libp2p/interface-connection' import type { Listener, ListenerEvents, CreateListenerOptions } from '@libp2p/interface-transport' +import type { Multiaddr } from '@multiformats/multiaddr' import type { Server } from 'http' -import type { WebSocketServer } from 'it-ws/server' import type { DuplexWebSocket } from 'it-ws/duplex' -import { EventEmitter, CustomEvent } from '@libp2p/interfaces/events' -import type { Connection } from '@libp2p/interface-connection' -import type { Multiaddr } from '@multiformats/multiaddr' +import type { WebSocketServer } from 'it-ws/server' const log = logger('libp2p:websockets:listener') diff --git a/src/socket-to-conn.ts b/src/socket-to-conn.ts index c41aeab..a3bf2b8 100644 --- a/src/socket-to-conn.ts +++ b/src/socket-to-conn.ts @@ -1,9 +1,9 @@ +import { logger } from '@libp2p/logger' import { abortableSource } from 'abortable-iterator' -import { CLOSE_TIMEOUT } from './constants.js' import pTimeout from 'p-timeout' -import { logger } from '@libp2p/logger' -import type { AbortOptions } from '@libp2p/interfaces' +import { CLOSE_TIMEOUT } from './constants.js' import type { MultiaddrConnection } from '@libp2p/interface-connection' +import type { AbortOptions } from '@libp2p/interfaces' import type { Multiaddr } from '@multiformats/multiaddr' import type { DuplexWebSocket } from 'it-ws/duplex' diff --git a/test/browser.ts b/test/browser.ts index ed51580..5fc89b6 100644 --- a/test/browser.ts +++ b/test/browser.ts @@ -1,16 +1,16 @@ /* eslint-env mocha */ -import { expect } from 'aegir/chai' +import { mockUpgrader } from '@libp2p/interface-mocks' +import { EventEmitter } from '@libp2p/interfaces/events' import { multiaddr } from '@multiformats/multiaddr' -import { pipe } from 'it-pipe' +import { expect } from 'aegir/chai' import all from 'it-all' +import { pipe } from 'it-pipe' import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string' -import { webSockets } from '../src/index.js' -import { mockUpgrader } from '@libp2p/interface-mocks' import { isBrowser, isWebWorker } from 'wherearewe' +import { webSockets } from '../src/index.js' import type { Connection } from '@libp2p/interface-connection' import type { Transport } from '@libp2p/interface-transport' -import { EventEmitter } from '@libp2p/interfaces/events' const protocol = '/echo/1.0.0' @@ -39,7 +39,7 @@ describe('libp2p-websockets', () => { const res = await pipe( [data], stream, - async (source) => await all(source) + async (source) => all(source) ) expect(res[0].subarray()).to.equalBytes(data) @@ -69,7 +69,7 @@ describe('libp2p-websockets', () => { const res = await pipe( [data], stream, - async (source) => await all(source) + async (source) => all(source) ) expect(res[0].subarray()).to.deep.equal(data) @@ -85,7 +85,7 @@ describe('libp2p-websockets', () => { const res = await pipe( data, stream, - async (source) => await all(source) + async (source) => all(source) ) expect(res.map(list => list.subarray())).to.deep.equal(data) diff --git a/test/compliance.node.ts b/test/compliance.node.ts index f347c99..eef8273 100644 --- a/test/compliance.node.ts +++ b/test/compliance.node.ts @@ -1,10 +1,10 @@ /* eslint-env mocha */ +import http from 'http' import tests from '@libp2p/interface-transport-compliance-tests' import { multiaddr } from '@multiformats/multiaddr' -import http from 'http' -import { webSockets } from '../src/index.js' import * as filters from '../src/filters.js' +import { webSockets } from '../src/index.js' import type { WebSocketListenerInit } from '../src/listener.js' import type { Listener } from '@libp2p/interface-transport' diff --git a/test/node.ts b/test/node.ts index 56ef415..43d88d5 100644 --- a/test/node.ts +++ b/test/node.ts @@ -1,27 +1,27 @@ /* eslint-env mocha */ /* eslint max-nested-callbacks: ["error", 6] */ -import https from 'https' -import http from 'http' import fs from 'fs' -import { expect } from 'aegir/chai' +import http from 'http' +import https from 'https' +import { mockRegistrar, mockUpgrader } from '@libp2p/interface-mocks' +import { EventEmitter } from '@libp2p/interfaces/events' import { multiaddr } from '@multiformats/multiaddr' -import { goodbye } from 'it-goodbye' +import { expect } from 'aegir/chai' import { isLoopbackAddr } from 'is-loopback-addr' import all from 'it-all' +import drain from 'it-drain' +import { goodbye } from 'it-goodbye' import { pipe } from 'it-pipe' -import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string' -import { mockRegistrar, mockUpgrader } from '@libp2p/interface-mocks' import defer from 'p-defer' import waitFor from 'p-wait-for' -import { webSockets } from '../src/index.js' +import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string' import * as filters from '../src/filters.js' -import drain from 'it-drain' +import { webSockets } from '../src/index.js' import type { Listener, Transport } from '@libp2p/interface-transport' -import type { Uint8ArrayList } from 'uint8arraylist' import type { Source } from 'it-stream-types' +import type { Uint8ArrayList } from 'uint8arraylist' import './compliance.node.js' -import { EventEmitter } from '@libp2p/interfaces/events' async function * toBuffers (source: Source): AsyncGenerator { for await (const list of source) {