New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@bloks/link-session-manager

Package Overview
Dependencies
Maintainers
1
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bloks/link-session-manager - npm Package Compare versions

Comparing version 0.2.650 to 0.2.652

5

lib/index.d.ts
/**
* proton-link-session-manager v0.2.650
* proton-link-session-manager v0.2.652
* https://github.com/greymass/proton-link-session-manager

@@ -38,3 +38,2 @@ *

import WebSocket from 'isomorphic-ws';
import NetInfo from '@react-native-community/netinfo';
import { SigningRequestEncodingOptions } from '@bloks/signing-request';

@@ -97,3 +96,2 @@

storage?: ProtonLinkSessionManagerStorage;
netInfo?: typeof NetInfo;
}

@@ -109,3 +107,2 @@ interface ProtonLinkSessionManagerEventHander {

private socket;
private netInfo?;
constructor(options: ProtonLinkSessionManagerOptions);

@@ -112,0 +109,0 @@ addSession(session: ProtonLinkSessionManagerSession): void;

103

lib/index.js
/**
* proton-link-session-manager v0.2.650
* proton-link-session-manager v0.2.652
* https://github.com/greymass/proton-link-session-manager

@@ -110,2 +110,3 @@ *

var _this = this;
if (opts === void 0) { opts = {}; }
this.attempts = 0;

@@ -118,2 +119,17 @@ this.reconnects = -1;

this.connectTimeout = undefined;
this.listeners = {
open: [
function (event) {
if (_this.connectTimeout) {
clearTimeout(_this.connectTimeout);
_this.connectTimeout = undefined;
}
event.reconnects = ++_this.reconnects;
event.attempts = _this.attempts;
_this.attempts = 0;
_this.reconnectWhenOnlineAgain = false;
},
],
close: [function (event) { return _this.reconnect(event); }],
};
this.opts = {

@@ -137,4 +153,2 @@ // the time to wait before a successful connection

},
// React native netinfo
netInfo: undefined,
// Create and connect the WebSocket when the instance is instantiated.

@@ -153,17 +167,2 @@ // Defaults to true to match standard WebSocket behavior

}
this.listeners = {
open: [
function (event) {
if (_this.connectTimeout) {
clearTimeout(_this.connectTimeout);
_this.connectTimeout = undefined;
}
event.reconnects = ++_this.reconnects;
event.attempts = _this.attempts;
_this.attempts = 0;
_this.reconnectWhenOnlineAgain = false;
},
],
close: [function (event) { return _this.reconnect(event); }],
};
if (this.opts.automaticOpen) {

@@ -214,3 +213,2 @@ this.newWebSocket(this.url);

_this.connectTimeout = undefined;
_this.detachConnectivityEvents();
_this.dispatchEvent({

@@ -222,5 +220,2 @@ type: 'timeout',

}, this.opts.timeout);
if (this.opts.netInfo) {
this.initializeConnectivity();
}
};

@@ -233,62 +228,2 @@ RobustWebSocket.prototype.clearPendingReconnectIfNeeded = function () {

};
RobustWebSocket.prototype.detachConnectivityEvents = function () {
if (this.unsubscribeNetInfo) {
this.unsubscribeNetInfo();
this.unsubscribeNetInfo = undefined;
}
};
RobustWebSocket.prototype.initializeConnectivity = function () {
return tslib.__awaiter(this, void 0, void 0, function () {
var _this = this;
return tslib.__generator(this, function (_a) {
if (!this.opts.netInfo) {
return [2 /*return*/];
}
this.detachConnectivityEvents();
this.unsubscribeNetInfo = this.opts.netInfo.addEventListener(function (state) {
var isOnline = state.isConnected && !(_this.netInfoState && _this.netInfoState.isConnected);
var isOffline = !state.isConnected && _this.netInfoState && _this.netInfoState.isConnected;
// Update to latest
_this.netInfoState = state;
// Offline -> Online
if (isOnline && _this.reconnectWhenOnlineAgain) {
console.log('GOING ONLINE');
_this.clearPendingReconnectIfNeeded();
_this.reconnect({ type: 'online', code: 0 });
}
// Online -> Offline
if (isOffline) {
console.log('GOING OFFLINE');
_this.reconnectWhenOnlineAgain = true;
if (_this.realWs) {
_this.realWs.close(1000);
}
}
});
return [2 /*return*/];
});
});
};
RobustWebSocket.prototype.onConnectivityUpdate = function (state) {
if (!state) {
return;
}
var isOnline = state.isConnected && !(this.netInfoState && this.netInfoState.isConnected);
var isOffline = !state.isConnected && this.netInfoState && this.netInfoState.isConnected;
// Update to latest
this.netInfoState = state;
// Offline -> Online
if (isOnline && this.reconnectWhenOnlineAgain) {
this.clearPendingReconnectIfNeeded();
this.reconnect({ type: 'online', code: 0 });
}
// Online -> Offline
if (isOffline) {
console.log('GOING OFFLINE');
this.reconnectWhenOnlineAgain = true;
if (this.realWs) {
this.realWs.close(1000);
}
}
};
RobustWebSocket.prototype.send = function (data) {

@@ -308,3 +243,2 @@ if (this.realWs) {

this.explicitlyClosed = true;
this.detachConnectivityEvents();
if (this.realWs) {

@@ -495,3 +429,2 @@ return this.realWs.close(code, reason);

}
this.netInfo = options.netInfo;
}

@@ -524,3 +457,3 @@ ProtonLinkSessionManager.prototype.addSession = function (session) {

var linkUrl = "wss://" + _this.storage.linkUrl + "/" + _this.storage.linkId;
var ws = new RobustWebSocket(linkUrl, { netInfo: _this.netInfo });
var ws = new RobustWebSocket(linkUrl);
var onSocketEvent = function (type, event) {

@@ -527,0 +460,0 @@ try {

/**
* proton-link-session-manager v0.2.650
* proton-link-session-manager v0.2.652
* https://github.com/greymass/proton-link-session-manager

@@ -84,3 +84,3 @@ *

class RobustWebSocket {
constructor(url, opts) {
constructor(url, opts = {}) {
this.attempts = 0;

@@ -93,2 +93,17 @@ this.reconnects = -1;

this.connectTimeout = undefined;
this.listeners = {
open: [
(event) => {
if (this.connectTimeout) {
clearTimeout(this.connectTimeout);
this.connectTimeout = undefined;
}
event.reconnects = ++this.reconnects;
event.attempts = this.attempts;
this.attempts = 0;
this.reconnectWhenOnlineAgain = false;
},
],
close: [(event) => this.reconnect(event)],
};
this.opts = {

@@ -112,4 +127,2 @@ // the time to wait before a successful connection

},
// React native netinfo
netInfo: undefined,
// Create and connect the WebSocket when the instance is instantiated.

@@ -128,17 +141,2 @@ // Defaults to true to match standard WebSocket behavior

}
this.listeners = {
open: [
(event) => {
if (this.connectTimeout) {
clearTimeout(this.connectTimeout);
this.connectTimeout = undefined;
}
event.reconnects = ++this.reconnects;
event.attempts = this.attempts;
this.attempts = 0;
this.reconnectWhenOnlineAgain = false;
},
],
close: [(event) => this.reconnect(event)],
};
if (this.opts.automaticOpen) {

@@ -174,3 +172,2 @@ this.newWebSocket(this.url);

this.connectTimeout = undefined;
this.detachConnectivityEvents();
this.dispatchEvent({

@@ -182,5 +179,2 @@ type: 'timeout',

}, this.opts.timeout);
if (this.opts.netInfo) {
this.initializeConnectivity();
}
}

@@ -193,56 +187,2 @@ clearPendingReconnectIfNeeded() {

}
detachConnectivityEvents() {
if (this.unsubscribeNetInfo) {
this.unsubscribeNetInfo();
this.unsubscribeNetInfo = undefined;
}
}
async initializeConnectivity() {
if (!this.opts.netInfo) {
return;
}
this.detachConnectivityEvents();
this.unsubscribeNetInfo = this.opts.netInfo.addEventListener((state) => {
const isOnline = state.isConnected && !(this.netInfoState && this.netInfoState.isConnected);
const isOffline = !state.isConnected && this.netInfoState && this.netInfoState.isConnected;
// Update to latest
this.netInfoState = state;
// Offline -> Online
if (isOnline && this.reconnectWhenOnlineAgain) {
console.log('GOING ONLINE');
this.clearPendingReconnectIfNeeded();
this.reconnect({ type: 'online', code: 0 });
}
// Online -> Offline
if (isOffline) {
console.log('GOING OFFLINE');
this.reconnectWhenOnlineAgain = true;
if (this.realWs) {
this.realWs.close(1000);
}
}
});
}
onConnectivityUpdate(state) {
if (!state) {
return;
}
const isOnline = state.isConnected && !(this.netInfoState && this.netInfoState.isConnected);
const isOffline = !state.isConnected && this.netInfoState && this.netInfoState.isConnected;
// Update to latest
this.netInfoState = state;
// Offline -> Online
if (isOnline && this.reconnectWhenOnlineAgain) {
this.clearPendingReconnectIfNeeded();
this.reconnect({ type: 'online', code: 0 });
}
// Online -> Offline
if (isOffline) {
console.log('GOING OFFLINE');
this.reconnectWhenOnlineAgain = true;
if (this.realWs) {
this.realWs.close(1000);
}
}
}
send(data) {

@@ -262,3 +202,2 @@ if (this.realWs) {

this.explicitlyClosed = true;
this.detachConnectivityEvents();
if (this.realWs) {

@@ -432,3 +371,2 @@ return this.realWs.close(code, reason);

}
this.netInfo = options.netInfo;
}

@@ -460,3 +398,3 @@ addSession(session) {

const linkUrl = `wss://${this.storage.linkUrl}/${this.storage.linkId}`;
const ws = new RobustWebSocket(linkUrl, { netInfo: this.netInfo });
const ws = new RobustWebSocket(linkUrl);
const onSocketEvent = (type, event) => {

@@ -463,0 +401,0 @@ try {

{
"name": "@bloks/link-session-manager",
"description": "Session management for signature providers when receiving requests using the Anchor Link protocol",
"version": "0.2.650",
"version": "0.2.652",
"homepage": "https://github.com/greymass/proton-link-session-manager",

@@ -6,0 +6,0 @@ "license": "BSD-3-Clause",

@@ -14,3 +14,2 @@ import WebSocket from 'isomorphic-ws'

import {v4 as uuid} from 'uuid'
import NetInfo from '@react-native-community/netinfo'

@@ -26,3 +25,2 @@ import {SealedMessage} from './link-types'

storage?: ProtonLinkSessionManagerStorage
netInfo?: typeof NetInfo
}

@@ -41,3 +39,2 @@

private socket: WebSocket
private netInfo?: typeof NetInfo

@@ -57,4 +54,2 @@ constructor(options: ProtonLinkSessionManagerOptions) {

}
this.netInfo = options.netInfo
}

@@ -101,3 +96,3 @@

const linkUrl = `wss://${this.storage.linkUrl}/${this.storage.linkId}`
const ws = new RobustWebSocket(linkUrl, {netInfo: this.netInfo})
const ws = new RobustWebSocket(linkUrl)

@@ -104,0 +99,0 @@ const onSocketEvent = (type: string, event: any) => {

@@ -1,7 +0,4 @@

import NetInfo, {NetInfoState, NetInfoSubscription} from '@react-native-community/netinfo'
interface Options {
timeout: number
shouldReconnect: (event: any, ws: RobustWebSocket) => number | undefined
netInfo?: typeof NetInfo
automaticOpen: boolean

@@ -23,7 +20,18 @@ handle1000: boolean

netInfoState?: NetInfoState
unsubscribeNetInfo?: NetInfoSubscription
listeners = {
open: [
(event) => {
if (this.connectTimeout) {
clearTimeout(this.connectTimeout)
this.connectTimeout = undefined
}
event.reconnects = ++this.reconnects
event.attempts = this.attempts
this.attempts = 0
this.reconnectWhenOnlineAgain = false
},
],
close: [(event) => this.reconnect(event)],
}
listeners
opts: Options = {

@@ -46,5 +54,2 @@ // the time to wait before a successful connection

// React native netinfo
netInfo: undefined,
// Create and connect the WebSocket when the instance is instantiated.

@@ -57,3 +62,3 @@ // Defaults to true to match standard WebSocket behavior

constructor(url, opts: Partial<Options>) {
constructor(url, opts: Partial<Options> = {}) {
this.url = url

@@ -75,18 +80,2 @@

this.listeners = {
open: [
(event) => {
if (this.connectTimeout) {
clearTimeout(this.connectTimeout)
this.connectTimeout = undefined
}
event.reconnects = ++this.reconnects
event.attempts = this.attempts
this.attempts = 0
this.reconnectWhenOnlineAgain = false
},
],
close: [(event) => this.reconnect(event)],
}
if (this.opts.automaticOpen) {

@@ -130,3 +119,2 @@ this.newWebSocket(this.url)

this.connectTimeout = undefined
this.detachConnectivityEvents()

@@ -139,6 +127,2 @@ this.dispatchEvent({

}, this.opts.timeout) as unknown as number
if (this.opts.netInfo) {
this.initializeConnectivity()
}
}

@@ -153,71 +137,2 @@

detachConnectivityEvents() {
if (this.unsubscribeNetInfo) {
this.unsubscribeNetInfo()
this.unsubscribeNetInfo = undefined
}
}
async initializeConnectivity() {
if (!this.opts.netInfo) {
return
}
this.detachConnectivityEvents()
this.unsubscribeNetInfo = this.opts.netInfo.addEventListener((state: NetInfoState) => {
const isOnline =
state.isConnected && !(this.netInfoState && this.netInfoState.isConnected)
const isOffline =
!state.isConnected && this.netInfoState && this.netInfoState.isConnected
// Update to latest
this.netInfoState = state
// Offline -> Online
if (isOnline && this.reconnectWhenOnlineAgain) {
console.log('GOING ONLINE')
this.clearPendingReconnectIfNeeded()
this.reconnect({type: 'online', code: 0})
}
// Online -> Offline
if (isOffline) {
console.log('GOING OFFLINE')
this.reconnectWhenOnlineAgain = true
if (this.realWs) {
this.realWs.close(1000)
}
}
})
}
onConnectivityUpdate(state: NetInfoState) {
if (!state) {
return
}
const isOnline = state.isConnected && !(this.netInfoState && this.netInfoState.isConnected)
const isOffline = !state.isConnected && this.netInfoState && this.netInfoState.isConnected
// Update to latest
this.netInfoState = state
// Offline -> Online
if (isOnline && this.reconnectWhenOnlineAgain) {
this.clearPendingReconnectIfNeeded()
this.reconnect({type: 'online', code: 0})
}
// Online -> Offline
if (isOffline) {
console.log('GOING OFFLINE')
this.reconnectWhenOnlineAgain = true
if (this.realWs) {
this.realWs.close(1000)
}
}
}
send(data) {

@@ -240,3 +155,2 @@ if (this.realWs) {

this.explicitlyClosed = true
this.detachConnectivityEvents()

@@ -243,0 +157,0 @@ if (this.realWs) {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc