@trezor/blockchain-link
Advanced tools
Comparing version 2.0.0 to 2.1.0
@@ -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 @@ |
/// <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 |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 2 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
220541
114
5792
102
7
2
+ Added@trezor/utils@^1.0.0
+ Added@trezor/utxo-lib@^1.0.0
+ Addedsocks-proxy-agent@6.1.1
+ Added@noble/hashes@1.6.1(transitive)
+ Added@trezor/utils@1.0.19.0.14(transitive)
+ Added@trezor/utxo-lib@1.0.12(transitive)
+ Added@types/node@22.10.0(transitive)
+ Addedbase-x@4.0.0(transitive)
+ Addedbchaddrjs@0.5.2(transitive)
+ Addedbech32@2.0.0(transitive)
+ Addedbig-integer@1.6.36(transitive)
+ Addedbindings@1.5.0(transitive)
+ Addedbip66@1.1.5(transitive)
+ Addedbitcoin-ops@1.4.1(transitive)
+ Addedblake-hash@2.0.0(transitive)
+ Addedblakejs@1.2.1(transitive)
+ Addedbs58@4.0.15.0.0(transitive)
+ Addedbs58check@2.1.23.0.1(transitive)
+ Addedcashaddrjs@0.4.4(transitive)
+ Addedcreate-hmac@1.1.7(transitive)
+ Addedfile-uri-to-path@1.0.0(transitive)
+ Addedint64-buffer@1.0.1(transitive)
+ Addedip-address@9.0.5(transitive)
+ Addedjsbn@1.1.0(transitive)
+ Addednan@2.22.0(transitive)
+ Addednode-addon-api@3.2.1(transitive)
+ Addednode-gyp-build@4.8.4(transitive)
+ Addedpushdata-bitcoin@1.0.1(transitive)
+ Addedsmart-buffer@4.2.0(transitive)
+ Addedsocks@2.8.3(transitive)
+ Addedsocks-proxy-agent@6.1.1(transitive)
+ Addedsprintf-js@1.1.3(transitive)
+ Addedstream-browserify@3.0.0(transitive)
+ Addedtiny-secp256k1@1.1.7(transitive)
+ Addedtypeforce@1.18.0(transitive)
+ Addedundici-types@6.20.0(transitive)
+ Addedvaruint-bitcoin@1.1.2(transitive)
+ Addedwif@2.0.6(transitive)
+ Addedws@7.4.6(transitive)
- Removed@types/node@22.9.1(transitive)
- Removedundici-types@6.19.8(transitive)
- Removedws@7.5.10(transitive)
Updatedws@7.4.6