@aurox/persistent-websocket-connection
Advanced tools
Comparing version 0.4.1 to 0.5.0
@@ -9,1 +9,2 @@ "use strict"; | ||
exports.DEFAULT_PERSISTENT_WEBSOCKET_CONNECTION_KEEP_ALIVE_INTERVAL = 5000; | ||
//# sourceMappingURL=constants.js.map |
import { PersistentWebsocketConnectionOptions } from './types'; | ||
declare type DeepRequired<T> = T extends Function ? T : T extends object ? { | ||
type DeepRequired<T> = T extends (...args: any[]) => any ? T : T extends object ? { | ||
[P in keyof T]-?: DeepRequired<T[P]>; | ||
} : Required<T>; | ||
export declare function getOptionsWithDefaults(options: PersistentWebsocketConnectionOptions): DeepRequired<PersistentWebsocketConnectionOptions>; | ||
type RequiredPersistentWebsocketConnectionOptions = DeepRequired<Omit<PersistentWebsocketConnectionOptions, 'agent'>> & Pick<PersistentWebsocketConnectionOptions, 'agent'>; | ||
export declare function getOptionsWithDefaults(options: PersistentWebsocketConnectionOptions): RequiredPersistentWebsocketConnectionOptions; | ||
export {}; |
@@ -27,5 +27,8 @@ "use strict"; | ||
backoffOffset: (options.reconnectBackoff && options.reconnectBackoff.backoffOffset) || 1, | ||
backoffIncrement: (options.reconnectBackoff && options.reconnectBackoff.backoffIncrement) || constants_1.DEFAULT_PERSISTENT_WEBSOCKET_CONNECTION_RECONNECT_TIMEOUT, | ||
maxBackedOffTimeout: (options.reconnectBackoff && options.reconnectBackoff.maxBackedOffTimeout) || (constants_1.DEFAULT_PERSISTENT_WEBSOCKET_CONNECTION_RECONNECT_TIMEOUT * 10), | ||
backoffIncrementResetTimeout: (options.reconnectBackoff && options.reconnectBackoff.backoffIncrementResetTimeout) || (constants_1.DEFAULT_PERSISTENT_WEBSOCKET_CONNECTION_RECONNECT_TIMEOUT * 10), | ||
backoffIncrement: (options.reconnectBackoff && options.reconnectBackoff.backoffIncrement) || | ||
constants_1.DEFAULT_PERSISTENT_WEBSOCKET_CONNECTION_RECONNECT_TIMEOUT, | ||
maxBackedOffTimeout: (options.reconnectBackoff && options.reconnectBackoff.maxBackedOffTimeout) || | ||
constants_1.DEFAULT_PERSISTENT_WEBSOCKET_CONNECTION_RECONNECT_TIMEOUT * 10, | ||
backoffIncrementResetTimeout: (options.reconnectBackoff && options.reconnectBackoff.backoffIncrementResetTimeout) || | ||
constants_1.DEFAULT_PERSISTENT_WEBSOCKET_CONNECTION_RECONNECT_TIMEOUT * 10, | ||
}, | ||
@@ -61,4 +64,6 @@ connectionCheckInterval: options.connectionCheckInterval || constants_1.DEFAULT_PERSISTENT_WEBSOCKET_CONNECTION_CONNECTION_CHECK_INTERVAL, | ||
onConnectionLost: options.onConnectionLost || noop, | ||
agent: options.agent, | ||
}; | ||
} | ||
exports.getOptionsWithDefaults = getOptionsWithDefaults; | ||
//# sourceMappingURL=defaults.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const tslib_1 = require("tslib"); | ||
(0, tslib_1.__exportStar)(require("./constants"), exports); | ||
(0, tslib_1.__exportStar)(require("./types"), exports); | ||
tslib_1.__exportStar(require("./constants"), exports); | ||
tslib_1.__exportStar(require("./types"), exports); | ||
const PersistentWebsocketConnection_1 = require("./PersistentWebsocketConnection"); | ||
exports.default = PersistentWebsocketConnection_1.PersistentWebsocketConnection; | ||
//# sourceMappingURL=index.js.map |
@@ -20,2 +20,3 @@ import { TypedEmitter } from 'tiny-typed-emitter'; | ||
private connectionCheckInterval; | ||
private agent; | ||
private pingPongOptions; | ||
@@ -22,0 +23,0 @@ private keepAliveOptions; |
@@ -5,6 +5,14 @@ "use strict"; | ||
const tslib_1 = require("tslib"); | ||
const isomorphic_ws_1 = (0, tslib_1.__importDefault)(require("isomorphic-ws")); | ||
const isomorphic_ws_1 = tslib_1.__importDefault(require("isomorphic-ws")); | ||
const tiny_typed_emitter_1 = require("tiny-typed-emitter"); | ||
const defaults_1 = require("./defaults"); | ||
class PersistentWebsocketConnection extends tiny_typed_emitter_1.TypedEmitter { | ||
get isConnected() { | ||
var _a, _b; | ||
return ((_a = this.connection) === null || _a === void 0 ? void 0 : _a.readyState) === ((_b = this.connection) === null || _b === void 0 ? void 0 : _b.OPEN); | ||
} | ||
get isConnecting() { | ||
var _a, _b; | ||
return ((_a = this.connection) === null || _a === void 0 ? void 0 : _a.readyState) === ((_b = this.connection) === null || _b === void 0 ? void 0 : _b.CONNECTING); | ||
} | ||
constructor(options) { | ||
@@ -308,3 +316,3 @@ super(); | ||
this.logger.debug(`Attempting to connect to ${this.url}.`); | ||
this.connection = new isomorphic_ws_1.default(this.url); | ||
this.connection = new isomorphic_ws_1.default(this.url, { agent: this.agent }); | ||
this.onConnecting(this.connection); | ||
@@ -322,2 +330,3 @@ this.emit('connecting'); | ||
this.connectionCheckInterval = optionsWithDefaults.connectionCheckInterval; | ||
this.agent = optionsWithDefaults.agent; | ||
this.pingPongOptions = optionsWithDefaults.pingPong; | ||
@@ -335,11 +344,4 @@ this.keepAliveOptions = optionsWithDefaults.keepAlive; | ||
} | ||
get isConnected() { | ||
var _a, _b; | ||
return ((_a = this.connection) === null || _a === void 0 ? void 0 : _a.readyState) === ((_b = this.connection) === null || _b === void 0 ? void 0 : _b.OPEN); | ||
} | ||
get isConnecting() { | ||
var _a, _b; | ||
return ((_a = this.connection) === null || _a === void 0 ? void 0 : _a.readyState) === ((_b = this.connection) === null || _b === void 0 ? void 0 : _b.CONNECTING); | ||
} | ||
} | ||
exports.PersistentWebsocketConnection = PersistentWebsocketConnection; | ||
//# sourceMappingURL=PersistentWebsocketConnection.js.map |
@@ -0,2 +1,4 @@ | ||
/// <reference types="node" /> | ||
import WebSocket, { MessageEvent } from 'ws'; | ||
import type { Agent } from 'http'; | ||
export interface PersistentWebsocketConnectionPingPongOptions { | ||
@@ -19,3 +21,3 @@ enabled: boolean; | ||
} | ||
export declare type ConnectionLostReason = 'pong-or-heartbeat-timeout' | 'closed-unexpectedly' | 'error'; | ||
export type ConnectionLostReason = 'pong-or-heartbeat-timeout' | 'closed-unexpectedly' | 'error'; | ||
export interface ConnectionLostEvent { | ||
@@ -52,2 +54,3 @@ reason: ConnectionLostReason; | ||
keepAlive?: Partial<PersistentWebsocketConnectionKeepAlive>; | ||
agent?: Agent; | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
//# sourceMappingURL=types.js.map |
{ | ||
"name": "@aurox/persistent-websocket-connection", | ||
"version": "0.4.1", | ||
"version": "0.5.0", | ||
"description": "Aurox Persistent Websocket Connection", | ||
@@ -14,2 +14,3 @@ "main": "dist/index.js", | ||
"dist", | ||
"src", | ||
"README.md" | ||
@@ -19,18 +20,21 @@ ], | ||
"license": "ISC", | ||
"dependencies": { | ||
"@types/node": "^18.11.18", | ||
"@types/ws": "^8.5.3", | ||
"isomorphic-ws": "^5.0.0", | ||
"tiny-typed-emitter": "^2.1.0", | ||
"tslib": "^2.4.1", | ||
"ws": "^8.11.0" | ||
}, | ||
"devDependencies": { | ||
"@typescript-eslint/eslint-plugin": "^4.31.0", | ||
"@typescript-eslint/parser": "^4.31.0", | ||
"eslint": "^7.32.0", | ||
"@typescript-eslint/eslint-plugin": "^5.47.1", | ||
"@typescript-eslint/parser": "^5.47.1", | ||
"eslint": "^8.30.0", | ||
"eslint-config-prettier": "^8.5.0", | ||
"eslint-plugin-prettier": "^4.2.1", | ||
"prettier": "^2.8.1", | ||
"rimraf": "^3.0.2", | ||
"ts-node": "^10.2.1", | ||
"typescript": "^4.4.2" | ||
}, | ||
"dependencies": { | ||
"@types/node": "^16.9.1", | ||
"@types/ws": "^7.4.7", | ||
"isomorphic-ws": "^4.0.1", | ||
"tiny-typed-emitter": "^2.1.0", | ||
"tslib": "^2.3.1", | ||
"ws": "^8.2.2" | ||
"ts-node": "^10.9.1", | ||
"typescript": "^4.9.4" | ||
} | ||
} |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
64996
21
1059
9
1
+ Added@types/node@18.19.76(transitive)
+ Added@types/ws@8.5.14(transitive)
+ Addedisomorphic-ws@5.0.0(transitive)
+ Addedundici-types@5.26.5(transitive)
- Removed@types/node@16.18.126(transitive)
- Removed@types/ws@7.4.7(transitive)
- Removedisomorphic-ws@4.0.1(transitive)
Updated@types/node@^18.11.18
Updated@types/ws@^8.5.3
Updatedisomorphic-ws@^5.0.0
Updatedtslib@^2.4.1
Updatedws@^8.11.0