diff --git a/src/transports/base.ts b/src/transports/base.ts index f34bfe2..ba865bc 100644 --- a/src/transports/base.ts +++ b/src/transports/base.ts @@ -3,15 +3,15 @@ import { URL } from "url"; import NodeId from "#nodeId.js"; export abstract class BasePeer implements Peer { - connectionUris: Array; + connectionUris: URL[]; isConnected: boolean = false; challenge: Uint8Array; protected _socket: any; - constructor(_socket: any, connectionUris: URL[]) { - this.connectionUris = connectionUris.map((uri) => new URL(uri.toString())); + constructor({ socket, uri }: { socket: any; uri: URL[] }) { + this.connectionUris = uri.map((uri) => new URL(uri.toString())); this.challenge = new Uint8Array(); - this._socket = _socket; + this._socket = socket; } private _id?: NodeId; diff --git a/src/types.ts b/src/types.ts index 464a58f..cb67475 100644 --- a/src/types.ts +++ b/src/types.ts @@ -32,7 +32,7 @@ export interface Peer { // Define the static side of the class export interface PeerStatic { - new (_socket: any, uri: URL[]): Peer; + new ({ socket, uri }: { socket: any; uri: URL[] }): Peer; connect(uri: URL): Promise; }