@electrum-cash/network
Advanced tools
Comparing version
import { EventEmitter } from "events"; | ||
import { ElectrumSocket } from "@electrum-cash/sockets"; | ||
type RPCParameter = string | number | boolean | null; | ||
@@ -78,38 +79,6 @@ interface RPCBase { | ||
} | ||
export const DEFAULT_PING_INTERVAL: number; | ||
export const DEFAULT_RECONNECT_INTERVAL: number; | ||
export const DEFAULT_BIG_INTEGERS = false; | ||
/** | ||
* Object containing the commonly used ports and schemes for specific Transports. | ||
* @example const electrum = new ElectrumClient('Electrum client example', '1.4.1', 'bch.imaginary.cash', Transport.WSS.Port, Transport.WSS.Scheme); | ||
* | ||
* @property {object} TCP Port and Scheme to use unencrypted TCP sockets. | ||
* @property {object} TCP_TLS Port and Scheme to use TLS-encrypted TCP sockets. | ||
* @property {object} WS Port and Scheme to use unencrypted WebSockets. | ||
* @property {object} WSS Port and Scheme to use TLS-encrypted WebSockets. | ||
*/ | ||
export const ElectrumTransport: { | ||
TCP: { | ||
Port: number; | ||
Scheme: TransportScheme; | ||
}; | ||
TCP_TLS: { | ||
Port: number; | ||
Scheme: TransportScheme; | ||
}; | ||
WS: { | ||
Port: number; | ||
Scheme: TransportScheme; | ||
}; | ||
WSS: { | ||
Port: number; | ||
Scheme: TransportScheme; | ||
}; | ||
}; | ||
export const DefaultParameters: { | ||
PORT: number; | ||
TRANSPORT_SCHEME: TransportScheme; | ||
RECONNECT: number; | ||
TIMEOUT: number; | ||
PING_INTERVAL: number; | ||
USE_BIG_INT: boolean; | ||
}; | ||
/** | ||
* Triggers when the underlying connection is established. | ||
@@ -135,6 +104,3 @@ * | ||
version: string; | ||
host: string; | ||
port: number; | ||
scheme: TransportScheme; | ||
timeout: number; | ||
socketOrHostname: ElectrumSocket | string; | ||
pingInterval: number; | ||
@@ -168,15 +134,17 @@ reconnectInterval: number; | ||
* | ||
* @param {string} application your application name, used to identify to the electrum host. | ||
* @param {string} version protocol version to use with the host. | ||
* @param {string} host fully qualified domain name or IP number of the host. | ||
* @param {number} port the TCP network port of the host. | ||
* @param {TransportScheme} scheme the transport scheme to use for connection | ||
* @param {number} timeout how long network delays we will wait for before taking action, in milliseconds. | ||
* @param {number} pingInterval the time between sending pings to the electrum host, in milliseconds. | ||
* @param {number} reconnectInterval the time between reconnection attempts to the electrum host, in milliseconds. | ||
* @param {boolean} useBigInt whether to use bigint for numbers in json response. | ||
* @param application - your application name, used to identify to the electrum host. | ||
* @param version - protocol version to use with the host. | ||
* @param socketOrHostname - socket fully qualified domain name or IP number of the host | ||
* @param pingInterval - the time between sending pings to the electrum host, in milliseconds. | ||
* @param reconnectInterval - the time between reconnection attempts to the electrum host, in milliseconds. | ||
* @param useBigInt - whether to use bigint for numbers in json response. | ||
* | ||
* @throws {Error} if `version` is not a valid version string. | ||
*/ | ||
constructor(application: string, version: string, host: string, port?: number, scheme?: TransportScheme, timeout?: number, pingInterval?: number, reconnectInterval?: number, useBigInt?: boolean); | ||
constructor(application: string, version: string, socketOrHostname: ElectrumSocket | string, pingInterval?: number, reconnectInterval?: number, useBigInt?: boolean); | ||
get hostIdentifier(): string; | ||
get host(): string; | ||
get port(): number; | ||
get encrypted(): boolean; | ||
get timeout(): number; | ||
/** | ||
@@ -192,4 +160,4 @@ * Connects to the remote server. | ||
* | ||
* @param {boolean} force disconnect even if the connection has not been fully established yet. | ||
* @param {boolean} retainSubscriptions retain subscription data so they will be restored on reconnection. | ||
* @param force - disconnect even if the connection has not been fully established yet. | ||
* @param retainSubscriptions - retain subscription data so they will be restored on reconnection. | ||
* | ||
@@ -202,4 +170,4 @@ * @returns true if successfully disconnected, or false if there was no connection. | ||
* | ||
* @param {string} method name of the method to call. | ||
* @param {...string} parameters one or more parameters for the method. | ||
* @param method - name of the method to call. | ||
* @param parameters - one or more parameters for the method. | ||
* | ||
@@ -215,4 +183,4 @@ * @throws {Error} if the client is disconnected. | ||
* | ||
* @param {string} method one of the subscribable methods the server supports. | ||
* @param {...string} parameters one or more parameters for the method. | ||
* @param method - one of the subscribable methods the server supports. | ||
* @param parameters - one or more parameters for the method. | ||
* | ||
@@ -227,4 +195,4 @@ * @throws {Error} if the client is disconnected. | ||
* | ||
* @param {string} method a previously subscribed to method. | ||
* @param {...string} parameters one or more parameters for the method. | ||
* @param method - a previously subscribed to method. | ||
* @param parameters - one or more parameters for the method. | ||
* | ||
@@ -239,3 +207,3 @@ * @throws {Error} if no subscriptions exist for the combination of the provided `method` and `parameters. | ||
* | ||
* @param {RPCNotification | RPCResponse} message the response message | ||
* @param message - the response message | ||
* | ||
@@ -242,0 +210,0 @@ * @throws {Error} if the message ID does not match an existing request. |
{ | ||
"name": "@electrum-cash/network", | ||
"version": "4.0.0-development.6655313659", | ||
"version": "4.0.0-development.8017676278", | ||
"description": "@electrum-cash/network is a lightweight JavaScript library that lets you connect with one or more Electrum servers.", | ||
@@ -57,6 +57,4 @@ "keywords": [ | ||
"@vitest/coverage-v8": "^1.3.1", | ||
"better-docs": "^2.7.2", | ||
"cspell": "^8.6.0", | ||
"del-cli": "^5.0.0", | ||
"docdash": "^2.0.1", | ||
"eslint": "^8.42.0", | ||
@@ -72,2 +70,4 @@ "eslint-plugin-import": "^2.23.4", | ||
"dependencies": { | ||
"@electrum-cash/debug-logs": "^1.0.0", | ||
"@electrum-cash/sockets": "^1.1.5", | ||
"@monsterbitar/isomorphic-ws": "^5.3.0", | ||
@@ -74,0 +74,0 @@ "@types/ws": "^8.5.5", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Network access
Supply chain riskThis module accesses the network.
Found 2 instances in 1 package
18
-10%0
-100%136564
-26.31%8
33.33%1153
-24.44%+ Added
+ Added
+ Added