Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@trezor/blockchain-link

Package Overview
Dependencies
Maintainers
6
Versions
74
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@trezor/blockchain-link - npm Package Compare versions

Comparing version 2.0.0 to 2.1.0

lib/types/electrum.d.ts

8

CHANGELOG.md

@@ -0,1 +1,9 @@

# 2.1.0
#### changes
- Added `proxy` param allowing workers to initialize SocksProxyAgent and use it for proxying communication
- Added support for `Electrum` backend
- Using common utilities from new `@trezor/utils` package
- Updated dependencies
# 2.0.0

@@ -2,0 +10,0 @@

2

lib/index.d.ts
/// <reference types="node" />
import { EventEmitter } from 'events';
import { Deferred } from './utils/deferred';
import { Deferred } from '@trezor/utils/lib/createDeferred';
import type { BlockchainSettings } from './types';

@@ -5,0 +5,0 @@ import type * as ResponseTypes from './types/responses';

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const events_1 = require("events");
const createDeferred_1 = require("@trezor/utils/lib/createDeferred");
const errors_1 = require("./constants/errors");
const constants_1 = require("./constants");
const deferred_1 = require("./utils/deferred");
const workerWrapper = (factory) => {

@@ -15,3 +15,3 @@ if (typeof factory === 'function')

const initWorker = (settings) => {
const dfd = (0, deferred_1.create)(-1);
const dfd = (0, createDeferred_1.createDeferred)(-1);
const worker = workerWrapper(settings.worker);

@@ -110,3 +110,3 @@ if (typeof worker !== 'object' || typeof worker.postMessage !== 'function') {

const worker = await this.getWorker();
const dfd = (0, deferred_1.create)(this.messageId);
const dfd = (0, createDeferred_1.createDeferred)(this.messageId);
this.deferred.push(dfd);

@@ -113,0 +113,0 @@ worker.postMessage(Object.assign({ id: this.messageId }, message));

@@ -0,1 +1,2 @@

import type { SocksProxyAgentOptions } from 'socks-proxy-agent';
import type { Transaction as BlockbookTransaction, VinVout } from './blockbook';

@@ -8,2 +9,3 @@ import type { BlockfrostTransaction } from './blockfrost';

server: string[];
proxy?: string | SocksProxyAgentOptions;
debug?: boolean;

@@ -10,0 +12,0 @@ timeout?: number;

@@ -0,1 +1,2 @@

import * as SocksProxyAgent from 'socks-proxy-agent';
import { WorkerState } from './state';

@@ -11,2 +12,3 @@ import type { Message, Response, BlockchainSettings } from '../types';

api: API | undefined;
proxyAgent: ReturnType<typeof SocksProxyAgent> | undefined;
settings: Partial<BlockchainSettings>;

@@ -13,0 +15,0 @@ endpoints: string[];

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.BaseWorker = exports.CONTEXT = void 0;
const SocksProxyAgent = require("socks-proxy-agent");
const errors_1 = require("../constants/errors");

@@ -72,2 +73,5 @@ const state_1 = require("./state");

this.settings = data.settings;
this.proxyAgent = data.settings.proxy
? SocksProxyAgent(data.settings.proxy)
: undefined;
return true;

@@ -74,0 +78,0 @@ }

@@ -325,2 +325,3 @@ "use strict";

keepAlive,
agent: this.proxyAgent,
});

@@ -327,0 +328,0 @@ try {

/// <reference types="node" />
import * as WebSocket from 'ws';
import { EventEmitter } from 'events';
import { Deferred } from '../../utils/deferred';
import { Deferred } from '@trezor/utils/lib/createDeferred';
import type { BlockNotification, AddressNotification, Send, FiatRatesNotification } from '../../types/blockbook';

@@ -18,2 +18,3 @@ import type { GetFiatRatesForTimestamps, GetFiatRatesTickersList, GetCurrentFiatRates } from '../../types/messages';

keepAlive?: boolean;
agent?: WebSocket.ClientOptions['agent'];
}

@@ -20,0 +21,0 @@ export declare interface BlockbookAPI {

@@ -6,4 +6,4 @@ "use strict";

const events_1 = require("events");
const createDeferred_1 = require("@trezor/utils/lib/createDeferred");
const errors_1 = require("../../constants/errors");
const deferred_1 = require("../../utils/deferred");
const NOT_INITIALIZED = new errors_1.CustomError('websocket_not_initialized');

@@ -23,3 +23,3 @@ const DEFAULT_TIMEOUT = 20 * 1000;

const id = this.messageID.toString();
const dfd = (0, deferred_1.create)(id);
const dfd = (0, createDeferred_1.createDeferred)(id);
const req = {

@@ -134,4 +134,10 @@ id,

this.setConnectionTimeout();
const dfd = (0, deferred_1.create)(-1);
const ws = new WebSocket(url);
const dfd = (0, createDeferred_1.createDeferred)(-1);
const ws = new WebSocket(url, {
agent: this.options.agent,
headers: {
Origin: 'https://node.trezor.io',
'User-Agent': 'Trezor Suite',
},
});
if (typeof ws.setMaxListeners === 'function') {

@@ -138,0 +144,0 @@ ws.setMaxListeners(Infinity);

@@ -252,2 +252,3 @@ "use strict";

keepAlive,
agent: this.proxyAgent,
});

@@ -254,0 +255,0 @@ try {

/// <reference types="node" />
import * as WebSocket from 'ws';
import { EventEmitter } from 'events';
import { Deferred } from '../../utils/deferred';
import { Deferred } from '@trezor/utils/lib/createDeferred';
import type { Send, BlockContent, BlockfrostTransaction } from '../../types/blockfrost';

@@ -17,2 +17,3 @@ import type { AccountInfoParams, EstimateFeeParams, AccountBalanceHistoryParams } from '../../types/params';

keepAlive?: boolean;
agent?: WebSocket.ClientOptions['agent'];
}

@@ -19,0 +20,0 @@ export declare interface BlockfrostAPI {

@@ -6,4 +6,4 @@ "use strict";

const events_1 = require("events");
const createDeferred_1 = require("@trezor/utils/lib/createDeferred");
const errors_1 = require("../../constants/errors");
const deferred_1 = require("../../utils/deferred");
const NOT_INITIALIZED = new errors_1.CustomError('websocket_not_initialized');

@@ -23,3 +23,3 @@ const DEFAULT_TIMEOUT = 20 * 1000;

const id = this.messageID.toString();
const dfd = (0, deferred_1.create)(id);
const dfd = (0, createDeferred_1.createDeferred)(id);
const req = {

@@ -121,4 +121,6 @@ id,

this.setConnectionTimeout();
const dfd = (0, deferred_1.create)(-1);
const ws = new WebSocket(url);
const dfd = (0, createDeferred_1.createDeferred)(-1);
const ws = new WebSocket(url, {
agent: this.options.agent,
});
if (typeof ws.setMaxListeners === 'function') {

@@ -125,0 +127,0 @@ ws.setMaxListeners(Infinity);

@@ -342,2 +342,3 @@ "use strict";

connectionTimeout: this.settings.timeout || DEFAULT_TIMEOUT,
agent: this.proxyAgent,
});

@@ -344,0 +345,0 @@ api.connection.reconnect = () => new Promise(() => { });

{
"name": "@trezor/blockchain-link",
"version": "2.0.0",
"version": "2.1.0",
"author": "Trezor <info@trezor.io>",

@@ -22,10 +22,14 @@ "homepage": "https://github.com/trezor/trezor-suite/packages/blockchain-link",

"main": "./lib/index.js",
"files": ["lib/"],
"files": [
"lib/"
],
"types": "lib/index.d.ts",
"typings": "lib/index.d.ts",
"browser": {
"ws": "./lib/utils/ws.js"
"ws": "./lib/utils/ws.js",
"socks-proxy-agent": "./lib/utils/socks-proxy-agent.js"
},
"scripts": {
"dev": "webpack serve --config ./webpack/dev.js",
"dev:electrum": "ts-node ./src/workers/electrum/devrun.ts",
"dev:module": "USE_MODULES=true webpack serve --config ./webpack/dev.js",

@@ -36,3 +40,3 @@ "build:lib": "rimraf lib && tsc --p ./tsconfig.lib.json && tsc --p ./tsconfig.workers.json",

"build:workers-module": "webpack --config ./webpack/workers.module.js",
"lint": "eslint '**/*.ts'",
"lint": "eslint '**/*.{ts,tsx,js}'",
"test:unit": "jest --verbose -c jest.config.unit.js",

@@ -47,3 +51,3 @@ "test:integration": "jest -c jest.config.integration.js",

"webpack": "^5.55.1",
"webpack-cli": "4.8.0",
"webpack-cli": "4.9.2",
"webpack-dev-server": "^4.7.3",

@@ -53,7 +57,10 @@ "worker-loader": "^3.0.8"

"dependencies": {
"@trezor/utils": "^1.0.0",
"@trezor/utxo-lib": "^1.0.0",
"bignumber.js": "^9.0.1",
"events": "^3.3.0",
"ripple-lib": "1.10.0",
"ws": "^7.4.0"
"socks-proxy-agent": "6.1.1",
"ws": "7.4.6"
}
}

@@ -8,2 +8,3 @@ # @trezor/blockchain-link

- [blockfrost](https://blockfrost.io): third party BE that provides access to the Cardano network.
- [electrum](https://electrumx-spesmilo.readthedocs.io/en/latest/): protocol implemented by multiple third party backends that provide access to the Bitcoin network.

@@ -10,0 +11,0 @@ ## Usage

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