@trezor/connect 9.0.5 → 9.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -2
- package/README.md +1 -1
- package/lib/api/authorizeCoinjoin.d.ts +7 -0
- package/lib/api/{authorizeCoinJoin.js → authorizeCoinjoin.js} +3 -3
- package/lib/api/bitcoin/refTx.js +1 -1
- package/lib/api/checkFirmwareAuthenticity.js +3 -1
- package/lib/api/index.d.ts +1 -1
- package/lib/api/index.js +3 -3
- package/lib/api/signTransaction.d.ts +2 -0
- package/lib/api/signTransaction.js +41 -38
- package/lib/core/index.d.ts +2 -2
- package/lib/core/index.js +18 -9
- package/lib/core/method.d.ts +1 -1
- package/lib/data/DataManager.d.ts +1 -1
- package/lib/data/DataManager.js +3 -2
- package/lib/data/config.js +3 -6
- package/lib/data/connectSettings.js +4 -1
- package/lib/data/version.d.ts +1 -1
- package/lib/data/version.js +1 -1
- package/lib/device/Device.d.ts +2 -2
- package/lib/device/Device.js +11 -8
- package/lib/device/DeviceCommands.js +4 -6
- package/lib/device/DeviceList.d.ts +1 -1
- package/lib/device/DeviceList.js +12 -14
- package/lib/events/transport.d.ts +7 -2
- package/lib/events/transport.js +1 -1
- package/lib/events/ui-request.d.ts +2 -2
- package/lib/factory.d.ts +2 -1
- package/lib/factory.js +3 -2
- package/lib/index-browser.js +1 -0
- package/lib/index.js +10 -2
- package/lib/types/api/{authorizeCoinJoin.d.ts → authorizeCoinjoin.d.ts} +3 -3
- package/lib/types/api/{authorizeCoinJoin.js → authorizeCoinjoin.js} +1 -1
- package/lib/types/api/dispose.d.ts +1 -1
- package/lib/types/api/index.d.ts +4 -2
- package/lib/types/api/requestWebUSBDevice.d.ts +2 -0
- package/lib/types/api/requestWebUSBDevice.js +3 -0
- package/lib/types/params.d.ts +1 -0
- package/lib/types/settings.d.ts +2 -0
- package/package.json +14 -12
- package/lib/api/authorizeCoinJoin.d.ts +0 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# 9.0.7
|
|
2
|
+
|
|
3
|
+
- feat(connect-ui): connect UI will now display a warning in case it was opened by an application listed in https://github.com/MetaMask/eth-phishing-detect (#7488)
|
|
4
|
+
- fix(connect-ui): set max pin input length to 50 instead of 9 (#7668)
|
|
5
|
+
- fix(connect): ltc spending problem (#7666)
|
|
6
|
+
- change(connect): TrezorConnect.init `webusb` option is now deprecated. It was replaced with `transports` param `('BridgeTransport' | 'WebUsbTransport')[]`. (#7411)
|
|
7
|
+
|
|
8
|
+
# 9.0.6
|
|
9
|
+
|
|
10
|
+
- fix: list tslib as direct dependency
|
|
11
|
+
- fix: various improvement and fixes regarding RBF (https://github.com/trezor/trezor-suite/pull/7378)
|
|
12
|
+
- change: increase handshake timeout in popup to 90 seconds
|
|
13
|
+
- change: TrezorConnect.dispose is now async and resolves only after connected device is released
|
|
14
|
+
|
|
1
15
|
# 9.0.5
|
|
2
16
|
|
|
3
17
|
- added: analytics in popup
|
|
@@ -15,7 +29,7 @@
|
|
|
15
29
|
- added `setBusy` method
|
|
16
30
|
- added `goerli` (TGOR) coin support
|
|
17
31
|
- added `serialize` and `coinjoinRequest` option to `signTransaction` method
|
|
18
|
-
- added `preauthorized` option to `
|
|
32
|
+
- added `preauthorized` option to `authorizeCoinjoin` method
|
|
19
33
|
- Cardano: added support for [CIP36 Catalyst registration format](https://cips.cardano.org/cips/cip36/) in `cardanoSignTransaction` method
|
|
20
34
|
- `auxiliaryData.catalystRegistrationParameters` is deprecated, use `auxiliaryData.governanceRegistrationParameters` instead
|
|
21
35
|
|
|
@@ -62,6 +76,6 @@
|
|
|
62
76
|
|
|
63
77
|
- `getOwnershipId` method
|
|
64
78
|
- `getOwnershipProof` method
|
|
65
|
-
- `
|
|
79
|
+
- `authorizeCoinjoin` method
|
|
66
80
|
- `getFirmwareHash` method
|
|
67
81
|
- [support for babbage features in cardano](https://github.com/trezor/trezor-suite/commit/efe9c78a2f74a1b7653b3fddf6cca35ba38d3ae9)
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @trezor/connect
|
|
2
2
|
|
|
3
|
-
API version 9.0.
|
|
3
|
+
API version 9.0.7
|
|
4
4
|
|
|
5
5
|
[](https://github.com/trezor/trezor-suite/actions/workflows/connect-test.yml)
|
|
6
6
|
[](https://www.npmjs.org/package/@trezor/connect)
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AbstractMethod } from '../core/AbstractMethod';
|
|
2
|
+
import { PROTO } from '../constants';
|
|
3
|
+
export default class AuthorizeCoinjoin extends AbstractMethod<'authorizeCoinjoin', PROTO.AuthorizeCoinJoin> {
|
|
4
|
+
init(): void;
|
|
5
|
+
run(): Promise<PROTO.Success>;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=authorizeCoinjoin.d.ts.map
|
|
@@ -4,7 +4,7 @@ const AbstractMethod_1 = require("../core/AbstractMethod");
|
|
|
4
4
|
const paramsValidator_1 = require("./common/paramsValidator");
|
|
5
5
|
const pathUtils_1 = require("../utils/pathUtils");
|
|
6
6
|
const coinInfo_1 = require("../data/coinInfo");
|
|
7
|
-
class
|
|
7
|
+
class AuthorizeCoinjoin extends AbstractMethod_1.AbstractMethod {
|
|
8
8
|
init() {
|
|
9
9
|
const { payload } = this;
|
|
10
10
|
(0, paramsValidator_1.validateParams)(payload, [
|
|
@@ -45,5 +45,5 @@ class AuthorizeCoinJoin extends AbstractMethod_1.AbstractMethod {
|
|
|
45
45
|
return response.message;
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
-
exports.default =
|
|
49
|
-
//# sourceMappingURL=
|
|
48
|
+
exports.default = AuthorizeCoinjoin;
|
|
49
|
+
//# sourceMappingURL=authorizeCoinjoin.js.map
|
package/lib/api/bitcoin/refTx.js
CHANGED
|
@@ -161,7 +161,7 @@ exports.transformReferencedTransactions = transformReferencedTransactions;
|
|
|
161
161
|
const validateReferencedTransactions = (txs, inputs, outputs) => {
|
|
162
162
|
if (!Array.isArray(txs) || txs.length === 0)
|
|
163
163
|
return;
|
|
164
|
-
const refTxs = (0, exports.getReferencedTransactions)(inputs);
|
|
164
|
+
const refTxs = (0, exports.requireReferencedTransactions)(inputs) ? (0, exports.getReferencedTransactions)(inputs) : [];
|
|
165
165
|
const origTxs = (0, exports.getOrigTransactions)(inputs, outputs);
|
|
166
166
|
const transformedTxs = txs.map(tx => {
|
|
167
167
|
(0, paramsValidator_1.validateParams)(tx, [
|
|
@@ -28,7 +28,9 @@ class CheckFirmwareAuthenticity extends AbstractMethod_1.AbstractMethod {
|
|
|
28
28
|
throw constants_1.ERRORS.TypedError('Runtime', 'checkFirmwareAuthenticity: firmware binary not found');
|
|
29
29
|
}
|
|
30
30
|
const { hash: expectedFirmwareHash, challenge } = (0, firmware_1.calculateFirmwareHash)(device.features.major_version, (0, firmware_1.stripFwHeaders)(fw), (0, randombytes_1.default)(32));
|
|
31
|
-
const result = await this.device
|
|
31
|
+
const result = await this.device
|
|
32
|
+
.getCommands()
|
|
33
|
+
.typedCall('GetFirmwareHash', 'FirmwareHash', {
|
|
32
34
|
challenge,
|
|
33
35
|
});
|
|
34
36
|
const { message } = result;
|
package/lib/api/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { default as applyFlags } from './applyFlags';
|
|
2
2
|
export { default as applySettings } from './applySettings';
|
|
3
|
-
export { default as
|
|
3
|
+
export { default as authorizeCoinjoin } from './authorizeCoinjoin';
|
|
4
4
|
export { default as backupDevice } from './backupDevice';
|
|
5
5
|
export { default as binanceGetAddress } from './binanceGetAddress';
|
|
6
6
|
export { default as binanceGetPublicKey } from './binanceGetPublicKey';
|
package/lib/api/index.js
CHANGED
|
@@ -3,14 +3,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.requestLogin = exports.recoveryDevice = exports.rebootToBootloader = exports.pushTransaction = exports.nemSignTransaction = exports.nemGetAddress = exports.getSettings = exports.getPublicKey = exports.getOwnershipProof = exports.getOwnershipId = exports.getFirmwareHash = exports.getFeatures = exports.getDeviceState = exports.getCoinInfo = exports.getAddress = exports.getAccountInfo = exports.firmwareUpdate = exports.ethereumVerifyMessage = exports.ethereumSignTypedData = exports.ethereumSignTransaction = exports.ethereumSignMessage = exports.ethereumGetPublicKey = exports.ethereumGetAddress = exports.eosSignTransaction = exports.eosGetPublicKey = exports.composeTransaction = exports.cipherKeyValue = exports.changePin = exports.cardanoSignTransaction = exports.cardanoGetPublicKey = exports.cardanoGetNativeScriptHash = exports.cardanoGetAddress = exports.blockchainUnsubscribeFiatRates = exports.blockchainUnsubscribe = exports.blockchainSubscribeFiatRates = exports.blockchainSubscribe = exports.blockchainSetCustomBackend = exports.blockchainGetTransactions = exports.blockchainGetFiatRatesForTimestamps = exports.blockchainGetCurrentFiatRates = exports.blockchainGetAccountBalanceHistory = exports.blockchainEstimateFee = exports.blockchainDisconnect = exports.binanceSignTransaction = exports.binanceGetPublicKey = exports.binanceGetAddress = exports.backupDevice = exports.
|
|
6
|
+
exports.requestLogin = exports.recoveryDevice = exports.rebootToBootloader = exports.pushTransaction = exports.nemSignTransaction = exports.nemGetAddress = exports.getSettings = exports.getPublicKey = exports.getOwnershipProof = exports.getOwnershipId = exports.getFirmwareHash = exports.getFeatures = exports.getDeviceState = exports.getCoinInfo = exports.getAddress = exports.getAccountInfo = exports.firmwareUpdate = exports.ethereumVerifyMessage = exports.ethereumSignTypedData = exports.ethereumSignTransaction = exports.ethereumSignMessage = exports.ethereumGetPublicKey = exports.ethereumGetAddress = exports.eosSignTransaction = exports.eosGetPublicKey = exports.composeTransaction = exports.cipherKeyValue = exports.changePin = exports.cardanoSignTransaction = exports.cardanoGetPublicKey = exports.cardanoGetNativeScriptHash = exports.cardanoGetAddress = exports.blockchainUnsubscribeFiatRates = exports.blockchainUnsubscribe = exports.blockchainSubscribeFiatRates = exports.blockchainSubscribe = exports.blockchainSetCustomBackend = exports.blockchainGetTransactions = exports.blockchainGetFiatRatesForTimestamps = exports.blockchainGetCurrentFiatRates = exports.blockchainGetAccountBalanceHistory = exports.blockchainEstimateFee = exports.blockchainDisconnect = exports.binanceSignTransaction = exports.binanceGetPublicKey = exports.binanceGetAddress = exports.backupDevice = exports.authorizeCoinjoin = exports.applySettings = exports.applyFlags = void 0;
|
|
7
7
|
exports.checkFirmwareAuthenticity = exports.wipeDevice = exports.verifyMessage = exports.unlockPath = exports.tezosSignTransaction = exports.tezosGetPublicKey = exports.tezosGetAddress = exports.stellarSignTransaction = exports.stellarGetAddress = exports.signTransaction = exports.signMessage = exports.setProxy = exports.setBusy = exports.rippleSignTransaction = exports.rippleGetAddress = exports.resetDevice = void 0;
|
|
8
8
|
var applyFlags_1 = require("./applyFlags");
|
|
9
9
|
Object.defineProperty(exports, "applyFlags", { enumerable: true, get: function () { return __importDefault(applyFlags_1).default; } });
|
|
10
10
|
var applySettings_1 = require("./applySettings");
|
|
11
11
|
Object.defineProperty(exports, "applySettings", { enumerable: true, get: function () { return __importDefault(applySettings_1).default; } });
|
|
12
|
-
var
|
|
13
|
-
Object.defineProperty(exports, "
|
|
12
|
+
var authorizeCoinjoin_1 = require("./authorizeCoinjoin");
|
|
13
|
+
Object.defineProperty(exports, "authorizeCoinjoin", { enumerable: true, get: function () { return __importDefault(authorizeCoinjoin_1).default; } });
|
|
14
14
|
var backupDevice_1 = require("./backupDevice");
|
|
15
15
|
Object.defineProperty(exports, "backupDevice", { enumerable: true, get: function () { return __importDefault(backupDevice_1).default; } });
|
|
16
16
|
var binanceGetAddress_1 = require("./binanceGetAddress");
|
|
@@ -85,46 +85,49 @@ class SignTransaction extends AbstractMethod_1.AbstractMethod {
|
|
|
85
85
|
};
|
|
86
86
|
this.params.options = (0, bitcoin_1.enhanceSignTx)(this.params.options, coinInfo);
|
|
87
87
|
}
|
|
88
|
-
async
|
|
89
|
-
const { device, params } = this;
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
const requiredRefTxs = (0, bitcoin_1.requireReferencedTransactions)(params.inputs, params.options, params.coinInfo);
|
|
94
|
-
const refTxsIds = (0, bitcoin_1.getReferencedTransactions)(params.inputs);
|
|
95
|
-
if (requiredRefTxs && refTxsIds.length > 0) {
|
|
96
|
-
(0, BlockchainLink_1.isBackendSupported)(params.coinInfo);
|
|
97
|
-
const blockchain = await (0, BlockchainLink_1.initBlockchain)(params.coinInfo, this.postMessage);
|
|
98
|
-
const rawTxs = await blockchain.getTransactions(refTxsIds);
|
|
99
|
-
(0, bitcoin_1.enhanceTrezorInputs)(this.params.inputs, rawTxs);
|
|
100
|
-
refTxs = (0, bitcoin_1.transformReferencedTransactions)(rawTxs, params.coinInfo);
|
|
101
|
-
const origTxsIds = (0, bitcoin_1.getOrigTransactions)(params.inputs, params.outputs);
|
|
102
|
-
if (!useLegacySignProcess && origTxsIds.length > 0) {
|
|
103
|
-
const rawOrigTxs = await blockchain.getTransactions(origTxsIds);
|
|
104
|
-
let { addresses } = params;
|
|
105
|
-
if (!addresses) {
|
|
106
|
-
const accountPath = params.inputs.find(i => i.address_n);
|
|
107
|
-
if (!accountPath || !accountPath.address_n) {
|
|
108
|
-
throw constants_1.ERRORS.TypedError('Runtime', 'Account not found');
|
|
109
|
-
}
|
|
110
|
-
const address_n = accountPath.address_n.slice(0, 3);
|
|
111
|
-
const node = await device
|
|
112
|
-
.getCommands()
|
|
113
|
-
.getHDNode({ address_n }, { coinInfo: params.coinInfo });
|
|
114
|
-
const account = await blockchain.getAccountInfo({
|
|
115
|
-
descriptor: node.xpubSegwit || node.xpub,
|
|
116
|
-
details: 'tokens',
|
|
117
|
-
});
|
|
118
|
-
addresses = account.addresses;
|
|
119
|
-
}
|
|
120
|
-
const origRefTxs = (0, bitcoin_1.transformOrigTransactions)(rawOrigTxs, params.coinInfo, addresses);
|
|
121
|
-
refTxs = refTxs.concat(origRefTxs);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
88
|
+
async fetchAddresses(blockchain) {
|
|
89
|
+
const { device, params: { inputs, coinInfo }, } = this;
|
|
90
|
+
const accountPath = inputs.find(i => i.address_n);
|
|
91
|
+
if (!accountPath || !accountPath.address_n) {
|
|
92
|
+
throw constants_1.ERRORS.TypedError('Runtime', 'Account not found');
|
|
124
93
|
}
|
|
125
|
-
|
|
126
|
-
|
|
94
|
+
const address_n = accountPath.address_n.slice(0, 3);
|
|
95
|
+
const node = await device.getCommands().getHDNode({ address_n }, { coinInfo });
|
|
96
|
+
const account = await blockchain.getAccountInfo({
|
|
97
|
+
descriptor: node.xpubSegwit || node.xpub,
|
|
98
|
+
details: 'tokens',
|
|
99
|
+
});
|
|
100
|
+
return account.addresses;
|
|
101
|
+
}
|
|
102
|
+
async fetchRefTxs(useLegacySignProcess) {
|
|
103
|
+
const { params: { inputs, outputs, options, coinInfo, addresses }, } = this;
|
|
104
|
+
const requiredRefTxs = (0, bitcoin_1.requireReferencedTransactions)(inputs, options, coinInfo);
|
|
105
|
+
const refTxsIds = requiredRefTxs ? (0, bitcoin_1.getReferencedTransactions)(inputs) : [];
|
|
106
|
+
const origTxsIds = !useLegacySignProcess ? (0, bitcoin_1.getOrigTransactions)(inputs, outputs) : [];
|
|
107
|
+
if (!refTxsIds.length && !origTxsIds.length) {
|
|
108
|
+
return [];
|
|
127
109
|
}
|
|
110
|
+
(0, BlockchainLink_1.isBackendSupported)(coinInfo);
|
|
111
|
+
const blockchain = await (0, BlockchainLink_1.initBlockchain)(coinInfo, this.postMessage);
|
|
112
|
+
const refTxs = !refTxsIds.length
|
|
113
|
+
? []
|
|
114
|
+
: await blockchain.getTransactions(refTxsIds).then(rawTxs => {
|
|
115
|
+
(0, bitcoin_1.enhanceTrezorInputs)(this.params.inputs, rawTxs);
|
|
116
|
+
return (0, bitcoin_1.transformReferencedTransactions)(rawTxs, coinInfo);
|
|
117
|
+
});
|
|
118
|
+
const origTxs = !origTxsIds.length
|
|
119
|
+
? []
|
|
120
|
+
: await blockchain.getTransactions(origTxsIds).then(async (rawOrigTxs) => {
|
|
121
|
+
const accountAddresses = addresses !== null && addresses !== void 0 ? addresses : (await this.fetchAddresses(blockchain));
|
|
122
|
+
return (0, bitcoin_1.transformOrigTransactions)(rawOrigTxs, coinInfo, accountAddresses);
|
|
123
|
+
});
|
|
124
|
+
return refTxs.concat(origTxs);
|
|
125
|
+
}
|
|
126
|
+
async run() {
|
|
127
|
+
var _a;
|
|
128
|
+
const { device, params } = this;
|
|
129
|
+
const useLegacySignProcess = !!device.unavailableCapabilities.replaceTransaction;
|
|
130
|
+
const refTxs = (_a = params.refTxs) !== null && _a !== void 0 ? _a : (await this.fetchRefTxs(useLegacySignProcess));
|
|
128
131
|
if (this.preauthorized) {
|
|
129
132
|
await device.getCommands().preauthorize(true);
|
|
130
133
|
}
|
package/lib/core/index.d.ts
CHANGED
|
@@ -6,8 +6,8 @@ export declare const handleMessage: (message: CoreMessage, isTrustedOrigin?: boo
|
|
|
6
6
|
export declare const onCall: (message: CoreMessage) => Promise<void>;
|
|
7
7
|
export declare class Core extends EventEmitter {
|
|
8
8
|
handleMessage(message: any, isTrustedOrigin: boolean): void;
|
|
9
|
-
dispose(): void
|
|
10
|
-
getCurrentMethod(): (import("../api").applyFlags | import("../api").applySettings | import("../api").
|
|
9
|
+
dispose(): Promise<void>;
|
|
10
|
+
getCurrentMethod(): (import("../api").applyFlags | import("../api").applySettings | import("../api").authorizeCoinjoin | import("../api").backupDevice | import("../api").binanceGetAddress | import("../api").binanceGetPublicKey | import("../api").binanceSignTransaction | import("../api").blockchainDisconnect | import("../api").blockchainEstimateFee | import("../api").blockchainGetAccountBalanceHistory | import("../api").blockchainGetCurrentFiatRates | import("../api").blockchainGetFiatRatesForTimestamps | import("../api").blockchainGetTransactions | import("../api").blockchainSetCustomBackend | import("../api").blockchainSubscribe | import("../api").blockchainSubscribeFiatRates | import("../api").blockchainUnsubscribe | import("../api").blockchainUnsubscribeFiatRates | import("../api").cardanoGetAddress | import("../api").cardanoGetNativeScriptHash | import("../api").cardanoGetPublicKey | import("../api").cardanoSignTransaction | import("../api").changePin | import("../api").cipherKeyValue | import("../api").composeTransaction | import("../api").eosGetPublicKey | import("../api").eosSignTransaction | import("../api").ethereumGetAddress | import("../api").ethereumGetPublicKey | import("../api").ethereumSignMessage | import("../api").ethereumSignTransaction | import("../api").ethereumSignTypedData | import("../api").ethereumVerifyMessage | import("../api").firmwareUpdate | import("../api").getAccountInfo | import("../api").getAddress | import("../api").getCoinInfo | import("../api").getDeviceState | import("../api").getFeatures | import("../api").getFirmwareHash | import("../api").getOwnershipId | import("../api").getOwnershipProof | import("../api").getPublicKey | import("../api").getSettings | import("../api").nemGetAddress | import("../api").nemSignTransaction | import("../api").pushTransaction | import("../api").rebootToBootloader | import("../api").recoveryDevice | import("../api").requestLogin | import("../api").resetDevice | import("../api").rippleGetAddress | import("../api").rippleSignTransaction | import("../api").setBusy | import("../api").setProxy | import("../api").signMessage | import("../api").signTransaction | import("../api").stellarGetAddress | import("../api").stellarSignTransaction | import("../api").tezosGetAddress | import("../api").tezosGetPublicKey | import("../api").tezosSignTransaction | import("../api").unlockPath | import("../api").verifyMessage | import("../api").wipeDevice | import("../api").checkFirmwareAuthenticity)[];
|
|
11
11
|
getTransportInfo(): TransportInfo;
|
|
12
12
|
}
|
|
13
13
|
export declare const initCore: () => Core;
|
package/lib/core/index.js
CHANGED
|
@@ -74,6 +74,9 @@ const handleMessage = (message, isTrustedOrigin = false) => {
|
|
|
74
74
|
case events_2.TRANSPORT.DISABLE_WEBUSB:
|
|
75
75
|
disableWebUSBTransport();
|
|
76
76
|
break;
|
|
77
|
+
case events_2.TRANSPORT.REQUEST_DEVICE:
|
|
78
|
+
_deviceList === null || _deviceList === void 0 ? void 0 : _deviceList.enumerate();
|
|
79
|
+
break;
|
|
77
80
|
case events_2.UI.RECEIVE_DEVICE:
|
|
78
81
|
case events_2.UI.RECEIVE_CONFIRMATION:
|
|
79
82
|
case events_2.UI.RECEIVE_PERMISSION:
|
|
@@ -103,7 +106,7 @@ const initDevice = async (method) => {
|
|
|
103
106
|
if (!_deviceList) {
|
|
104
107
|
throw constants_1.ERRORS.TypedError('Transport_Missing');
|
|
105
108
|
}
|
|
106
|
-
const isWebUsb = _deviceList.transportType() === '
|
|
109
|
+
const isWebUsb = _deviceList.transportType() === 'WebUsbTransport';
|
|
107
110
|
let device;
|
|
108
111
|
let showDeviceSelection = isWebUsb;
|
|
109
112
|
if (method.devicePath) {
|
|
@@ -499,7 +502,7 @@ const handleDeviceSelectionChanges = (interruptDevice) => {
|
|
|
499
502
|
const uiPromise = findUiPromise(events_2.UI.RECEIVE_DEVICE);
|
|
500
503
|
if (uiPromise && _deviceList) {
|
|
501
504
|
const list = _deviceList.asArray();
|
|
502
|
-
const isWebUsb = _deviceList.transportType()
|
|
505
|
+
const isWebUsb = _deviceList.transportType() === 'WebUsbTransport';
|
|
503
506
|
if (list.length === 1 && !isWebUsb) {
|
|
504
507
|
uiPromise.resolve({
|
|
505
508
|
type: events_2.UI.RECEIVE_DEVICE,
|
|
@@ -587,12 +590,12 @@ class Core extends events_1.default {
|
|
|
587
590
|
handleMessage(message, isTrustedOrigin) {
|
|
588
591
|
(0, exports.handleMessage)(message, isTrustedOrigin);
|
|
589
592
|
}
|
|
590
|
-
dispose() {
|
|
591
|
-
if (_deviceList) {
|
|
592
|
-
_deviceList.dispose();
|
|
593
|
-
}
|
|
593
|
+
async dispose() {
|
|
594
594
|
(0, BlockchainLink_1.dispose)();
|
|
595
595
|
this.removeAllListeners();
|
|
596
|
+
if (_deviceList) {
|
|
597
|
+
await _deviceList.dispose();
|
|
598
|
+
}
|
|
596
599
|
}
|
|
597
600
|
getCurrentMethod() {
|
|
598
601
|
return _callMethods;
|
|
@@ -644,14 +647,20 @@ const initTransport = async (settings) => {
|
|
|
644
647
|
};
|
|
645
648
|
exports.initTransport = initTransport;
|
|
646
649
|
const disableWebUSBTransport = async () => {
|
|
650
|
+
var _a, _b;
|
|
647
651
|
if (!_deviceList)
|
|
648
652
|
return;
|
|
649
|
-
if (_deviceList.transportType() !== '
|
|
653
|
+
if (_deviceList.transportType() !== 'WebUsbTransport')
|
|
650
654
|
return;
|
|
651
655
|
const settings = DataManager_1.DataManager.getSettings();
|
|
652
|
-
settings.
|
|
656
|
+
if ((_a = settings.transports) === null || _a === void 0 ? void 0 : _a.includes('WebUsbTransport')) {
|
|
657
|
+
settings.transports.splice(settings.transports.indexOf('WebUsbTransport'));
|
|
658
|
+
}
|
|
659
|
+
if (!((_b = settings.transports) === null || _b === void 0 ? void 0 : _b.includes('BridgeTransport'))) {
|
|
660
|
+
settings.transports.unshift('BridgeTransport');
|
|
661
|
+
}
|
|
653
662
|
try {
|
|
654
|
-
_deviceList.dispose();
|
|
663
|
+
await _deviceList.dispose();
|
|
655
664
|
await initDeviceList(settings);
|
|
656
665
|
}
|
|
657
666
|
catch (error) {
|
package/lib/core/method.d.ts
CHANGED
|
@@ -2,5 +2,5 @@ import * as Methods from '../api';
|
|
|
2
2
|
import type { IFrameCallMessage } from '../events';
|
|
3
3
|
export declare const getMethod: (message: IFrameCallMessage & {
|
|
4
4
|
id?: number;
|
|
5
|
-
}) => Methods.applyFlags | Methods.applySettings | Methods.
|
|
5
|
+
}) => Methods.applyFlags | Methods.applySettings | Methods.authorizeCoinjoin | Methods.backupDevice | Methods.binanceGetAddress | Methods.binanceGetPublicKey | Methods.binanceSignTransaction | Methods.blockchainDisconnect | Methods.blockchainEstimateFee | Methods.blockchainGetAccountBalanceHistory | Methods.blockchainGetCurrentFiatRates | Methods.blockchainGetFiatRatesForTimestamps | Methods.blockchainGetTransactions | Methods.blockchainSetCustomBackend | Methods.blockchainSubscribe | Methods.blockchainSubscribeFiatRates | Methods.blockchainUnsubscribe | Methods.blockchainUnsubscribeFiatRates | Methods.cardanoGetAddress | Methods.cardanoGetNativeScriptHash | Methods.cardanoGetPublicKey | Methods.cardanoSignTransaction | Methods.changePin | Methods.cipherKeyValue | Methods.composeTransaction | Methods.eosGetPublicKey | Methods.eosSignTransaction | Methods.ethereumGetAddress | Methods.ethereumGetPublicKey | Methods.ethereumSignMessage | Methods.ethereumSignTransaction | Methods.ethereumSignTypedData | Methods.ethereumVerifyMessage | Methods.firmwareUpdate | Methods.getAccountInfo | Methods.getAddress | Methods.getCoinInfo | Methods.getDeviceState | Methods.getFeatures | Methods.getFirmwareHash | Methods.getOwnershipId | Methods.getOwnershipProof | Methods.getPublicKey | Methods.getSettings | Methods.nemGetAddress | Methods.nemSignTransaction | Methods.pushTransaction | Methods.rebootToBootloader | Methods.recoveryDevice | Methods.requestLogin | Methods.resetDevice | Methods.rippleGetAddress | Methods.rippleSignTransaction | Methods.setBusy | Methods.setProxy | Methods.signMessage | Methods.signTransaction | Methods.stellarGetAddress | Methods.stellarSignTransaction | Methods.tezosGetAddress | Methods.tezosGetPublicKey | Methods.tezosSignTransaction | Methods.unlockPath | Methods.verifyMessage | Methods.wipeDevice | Methods.checkFirmwareAuthenticity;
|
|
6
6
|
//# sourceMappingURL=method.d.ts.map
|
|
@@ -16,7 +16,7 @@ export declare class DataManager {
|
|
|
16
16
|
static isManagementAllowed(): {
|
|
17
17
|
origin: string;
|
|
18
18
|
} | undefined;
|
|
19
|
-
static getPriority(whitelist?: typeof config['whitelist'][0]): number;
|
|
19
|
+
static getPriority(whitelist?: (typeof config)['whitelist'][0]): number;
|
|
20
20
|
static getHostLabel(origin: string): {
|
|
21
21
|
origin: string;
|
|
22
22
|
label: string;
|
package/lib/data/DataManager.js
CHANGED
|
@@ -11,6 +11,7 @@ const transportInfo_1 = require("./transportInfo");
|
|
|
11
11
|
const config_1 = require("./config");
|
|
12
12
|
class DataManager {
|
|
13
13
|
static async load(settings, withAssets = true) {
|
|
14
|
+
var _a;
|
|
14
15
|
const ts = settings.env === 'web' ? `?r=${settings.timestamp}` : '';
|
|
15
16
|
this.settings = settings;
|
|
16
17
|
const isLocalhost = typeof window !== 'undefined' && window.location
|
|
@@ -30,8 +31,8 @@ class DataManager {
|
|
|
30
31
|
this.settings.hostLabel = knownHost.label;
|
|
31
32
|
this.settings.hostIcon = knownHost.icon;
|
|
32
33
|
}
|
|
33
|
-
if (this.settings.popup && this.settings.
|
|
34
|
-
this.settings.
|
|
34
|
+
if (this.settings.popup && this.settings.env !== 'webextension') {
|
|
35
|
+
this.settings.transports = (_a = this.settings.transports) === null || _a === void 0 ? void 0 : _a.filter((transport) => transport !== 'WebUsbTransport');
|
|
35
36
|
}
|
|
36
37
|
if (!withAssets)
|
|
37
38
|
return;
|
package/lib/data/config.js
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.config = void 0;
|
|
4
|
+
const transport_1 = require("@trezor/transport");
|
|
4
5
|
exports.config = {
|
|
5
|
-
webusb:
|
|
6
|
-
{ vendorId: 0x534c, productId: 0x0001 },
|
|
7
|
-
{ vendorId: 0x1209, productId: 0x53c0 },
|
|
8
|
-
{ vendorId: 0x1209, productId: 0x53c1 },
|
|
9
|
-
],
|
|
6
|
+
webusb: transport_1.TREZOR_DESCS,
|
|
10
7
|
whitelist: [
|
|
11
8
|
{ origin: 'chrome-extension://imloifkgjagghnncjkhggdhalmcnfklk', priority: 1 },
|
|
12
9
|
{ origin: 'chrome-extension://niebkpllfhmpfbffbfifagfgoamhpflf', priority: 1 },
|
|
@@ -185,7 +182,7 @@ exports.config = {
|
|
|
185
182
|
},
|
|
186
183
|
{
|
|
187
184
|
capabilities: ['coinjoin'],
|
|
188
|
-
methods: ['
|
|
185
|
+
methods: ['authorizeCoinjoin', 'getOwnershipId', 'getOwnershipProof'],
|
|
189
186
|
min: ['0', '2.5.3'],
|
|
190
187
|
},
|
|
191
188
|
],
|
|
@@ -14,7 +14,7 @@ const initialSettings = {
|
|
|
14
14
|
popup: true,
|
|
15
15
|
popupSrc: `${version_1.DEFAULT_DOMAIN}popup.html`,
|
|
16
16
|
webusbSrc: `${version_1.DEFAULT_DOMAIN}webusb.html`,
|
|
17
|
-
|
|
17
|
+
transports: undefined,
|
|
18
18
|
pendingTransportEvent: true,
|
|
19
19
|
supportedBrowser: typeof navigator !== 'undefined' ? !/Trident|MSIE|Edge/.test(navigator.userAgent) : true,
|
|
20
20
|
env: 'web',
|
|
@@ -113,6 +113,9 @@ const parseConnectSettings = (input = {}) => {
|
|
|
113
113
|
if (typeof input.webusb === 'boolean') {
|
|
114
114
|
settings.webusb = input.webusb;
|
|
115
115
|
}
|
|
116
|
+
if (Array.isArray(input.transports)) {
|
|
117
|
+
settings.transports = input.transports;
|
|
118
|
+
}
|
|
116
119
|
if (typeof input.popup === 'boolean') {
|
|
117
120
|
settings.popup = input.popup;
|
|
118
121
|
}
|
package/lib/data/version.d.ts
CHANGED
package/lib/data/version.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DEFAULT_DOMAIN = exports.VERSION = void 0;
|
|
4
|
-
exports.VERSION = '9.0.
|
|
4
|
+
exports.VERSION = '9.0.7';
|
|
5
5
|
const versionN = exports.VERSION.split('.').map(s => parseInt(s, 10));
|
|
6
6
|
exports.DEFAULT_DOMAIN = `https://connect.trezor.io/${versionN[0]}/`;
|
|
7
7
|
//# sourceMappingURL=version.js.map
|
package/lib/device/Device.d.ts
CHANGED
|
@@ -44,7 +44,7 @@ export declare class Device extends EventEmitter {
|
|
|
44
44
|
inconsistent: boolean;
|
|
45
45
|
firstRunPromise: Deferred<boolean>;
|
|
46
46
|
activitySessionID?: string | null;
|
|
47
|
-
commands
|
|
47
|
+
commands?: DeviceCommands;
|
|
48
48
|
keepSession: boolean;
|
|
49
49
|
instance: number;
|
|
50
50
|
internalState: string[];
|
|
@@ -93,7 +93,7 @@ export declare class Device extends EventEmitter {
|
|
|
93
93
|
getDevicePath(): string;
|
|
94
94
|
isT1(): boolean;
|
|
95
95
|
hasUnexpectedMode(allow: string[], require: string[]): "ui-device_bootloader_mode" | "ui-device_not_in_bootloader_mode" | "ui-device_not_initialized" | "ui-device_seedless" | null;
|
|
96
|
-
dispose(): void;
|
|
96
|
+
dispose(): Promise<void> | undefined;
|
|
97
97
|
getMode(): "normal" | "bootloader" | "initialize" | "seedless";
|
|
98
98
|
toMessageObject(): DeviceTyped;
|
|
99
99
|
_getNetworkTypeState(): "bitcoin" | "ethereum" | "nem" | "eos" | "stellar" | "cardano" | "ripple" | "tezos" | "binance";
|
package/lib/device/Device.js
CHANGED
|
@@ -123,8 +123,7 @@ class Device extends events_1.default {
|
|
|
123
123
|
await this.deferredActions[events_2.DEVICE.ACQUIRE].promise;
|
|
124
124
|
}
|
|
125
125
|
if (this.runPromise) {
|
|
126
|
-
this.
|
|
127
|
-
this.runPromise = null;
|
|
126
|
+
await this.interruptionFromUser(error);
|
|
128
127
|
}
|
|
129
128
|
if (!this.keepSession && this.deferredActions[events_2.DEVICE.RELEASE]) {
|
|
130
129
|
await this.deferredActions[events_2.DEVICE.RELEASE].promise;
|
|
@@ -152,7 +151,8 @@ class Device extends events_1.default {
|
|
|
152
151
|
}
|
|
153
152
|
}
|
|
154
153
|
async _runInner(fn, options) {
|
|
155
|
-
|
|
154
|
+
var _a;
|
|
155
|
+
if (!this.isUsedHere() || ((_a = this.commands) === null || _a === void 0 ? void 0 : _a.disposed) || !this.getExternalState()) {
|
|
156
156
|
await this.acquire();
|
|
157
157
|
try {
|
|
158
158
|
if (fn) {
|
|
@@ -201,6 +201,9 @@ class Device extends events_1.default {
|
|
|
201
201
|
}
|
|
202
202
|
}
|
|
203
203
|
getCommands() {
|
|
204
|
+
if (!this.commands) {
|
|
205
|
+
throw constants_1.ERRORS.TypedError('Runtime', `Device: commands not defined`);
|
|
206
|
+
}
|
|
204
207
|
return this.commands;
|
|
205
208
|
}
|
|
206
209
|
setInstance(instance = 0) {
|
|
@@ -245,13 +248,13 @@ class Device extends events_1.default {
|
|
|
245
248
|
if (!this.features)
|
|
246
249
|
return;
|
|
247
250
|
if (!this.features.unlocked && preauthorized) {
|
|
248
|
-
if (await this.
|
|
251
|
+
if (await this.getCommands().preauthorize(false)) {
|
|
249
252
|
return;
|
|
250
253
|
}
|
|
251
254
|
}
|
|
252
255
|
const altMode = this._altModeChange(networkType);
|
|
253
256
|
const expectedState = altMode ? undefined : this.getExternalState();
|
|
254
|
-
const state = await this.
|
|
257
|
+
const state = await this.getCommands().getDeviceState(networkType);
|
|
255
258
|
const uniqueState = `${state}@${this.features.device_id || 'device_id'}:${this.instance}`;
|
|
256
259
|
if (!this.useLegacyPassphrase() && this.features.session_id) {
|
|
257
260
|
this.setInternalState(this.features.session_id);
|
|
@@ -284,11 +287,11 @@ class Device extends events_1.default {
|
|
|
284
287
|
}
|
|
285
288
|
}
|
|
286
289
|
}
|
|
287
|
-
const { message } = await this.
|
|
290
|
+
const { message } = await this.getCommands().typedCall('Initialize', 'Features', payload);
|
|
288
291
|
this._updateFeatures(message);
|
|
289
292
|
}
|
|
290
293
|
async getFeatures() {
|
|
291
|
-
const { message } = await this.
|
|
294
|
+
const { message } = await this.getCommands().typedCall('GetFeatures', 'Features', {});
|
|
292
295
|
this._updateFeatures(message);
|
|
293
296
|
}
|
|
294
297
|
_updateFeatures(feat) {
|
|
@@ -452,7 +455,7 @@ class Device extends events_1.default {
|
|
|
452
455
|
if (this.commands) {
|
|
453
456
|
this.commands.cancel();
|
|
454
457
|
}
|
|
455
|
-
this.transport.release(this.activitySessionID, true
|
|
458
|
+
return this.transport.release(this.activitySessionID, true);
|
|
456
459
|
}
|
|
457
460
|
catch (err) {
|
|
458
461
|
}
|
|
@@ -474,15 +474,13 @@ class DeviceCommands {
|
|
|
474
474
|
if (this.disposed) {
|
|
475
475
|
return;
|
|
476
476
|
}
|
|
477
|
-
const {
|
|
478
|
-
if (
|
|
479
|
-
activeName === 'BridgeTransport' &&
|
|
480
|
-
(0, versionUtils_1.versionCompare)(version, '2.0.28') < 1) {
|
|
477
|
+
const { name, version } = this.transport;
|
|
478
|
+
if (name === 'BridgeTransport' && (0, versionUtils_1.versionCompare)(version, '2.0.28') < 1) {
|
|
481
479
|
await this.device.legacyForceRelease();
|
|
482
480
|
}
|
|
483
481
|
else {
|
|
484
|
-
await this.transport.post(this.sessionId, 'Cancel', {}, false);
|
|
485
|
-
await this.transport.read(this.sessionId, false);
|
|
482
|
+
await this.transport.post(this.sessionId, 'Cancel', {}, false).catch(() => { });
|
|
483
|
+
await this.transport.read(this.sessionId, false).catch(() => { });
|
|
486
484
|
}
|
|
487
485
|
}
|
|
488
486
|
}
|
|
@@ -60,7 +60,7 @@ export declare class DeviceList extends EventEmitter {
|
|
|
60
60
|
length(): number;
|
|
61
61
|
transportType(): string;
|
|
62
62
|
getTransportInfo(): TransportInfo;
|
|
63
|
-
dispose(): void
|
|
63
|
+
dispose(): Promise<void>;
|
|
64
64
|
disconnectDevices(): void;
|
|
65
65
|
enumerate(): void;
|
|
66
66
|
addAuthPenalty(device: Device): void;
|
package/lib/device/DeviceList.js
CHANGED
|
@@ -25,12 +25,16 @@ class DeviceList extends events_1.default {
|
|
|
25
25
|
this.creatingDevicesDescriptors = {};
|
|
26
26
|
this.transportStartPending = 0;
|
|
27
27
|
this.penalizedDevices = {};
|
|
28
|
-
const { env
|
|
28
|
+
const { env } = DataManager_1.DataManager.settings;
|
|
29
|
+
let { transports: transportSettings } = DataManager_1.DataManager.settings;
|
|
29
30
|
const transports = [];
|
|
31
|
+
if (!(transportSettings === null || transportSettings === void 0 ? void 0 : transportSettings.length)) {
|
|
32
|
+
transportSettings = ['BridgeTransport', 'WebUsbTransport'];
|
|
33
|
+
}
|
|
30
34
|
if (env === 'react-native' && typeof workers_1.ReactNativeUsbPlugin !== 'undefined') {
|
|
31
35
|
transports.push((0, workers_1.ReactNativeUsbPlugin)());
|
|
32
36
|
}
|
|
33
|
-
else {
|
|
37
|
+
else if (transportSettings === null || transportSettings === void 0 ? void 0 : transportSettings.includes('BridgeTransport')) {
|
|
34
38
|
const bridgeLatestVersion = (0, transportInfo_1.getBridgeInfo)().version.join('.');
|
|
35
39
|
const bridge = new BridgeV2(undefined, undefined);
|
|
36
40
|
bridge.setBridgeLatestVersion(bridgeLatestVersion);
|
|
@@ -41,7 +45,7 @@ class DeviceList extends events_1.default {
|
|
|
41
45
|
BridgeV2.setFetch(fetchWithSignal, isNode);
|
|
42
46
|
transports.push(bridge);
|
|
43
47
|
}
|
|
44
|
-
if (
|
|
48
|
+
if ((transportSettings === null || transportSettings === void 0 ? void 0 : transportSettings.includes('WebUsbTransport')) && typeof workers_1.WebUsbPlugin !== 'undefined') {
|
|
45
49
|
transports.push((0, workers_1.WebUsbPlugin)());
|
|
46
50
|
}
|
|
47
51
|
this.transport = new Fallback(transports);
|
|
@@ -56,7 +60,7 @@ class DeviceList extends events_1.default {
|
|
|
56
60
|
await transport.configure(JSON.stringify(this.messages));
|
|
57
61
|
_log.debug('Configuring transports done');
|
|
58
62
|
const { activeName } = transport;
|
|
59
|
-
if (activeName === '
|
|
63
|
+
if (activeName === 'WebUsbTransport') {
|
|
60
64
|
this.transportPlugin = transport.activeTransport.plugin;
|
|
61
65
|
}
|
|
62
66
|
await this._initStream();
|
|
@@ -156,15 +160,9 @@ class DeviceList extends events_1.default {
|
|
|
156
160
|
return this.asArray().length;
|
|
157
161
|
}
|
|
158
162
|
transportType() {
|
|
159
|
-
const { transport
|
|
163
|
+
const { transport } = this;
|
|
160
164
|
const { activeName } = transport;
|
|
161
|
-
|
|
162
|
-
return 'bridge';
|
|
163
|
-
}
|
|
164
|
-
if (transportPlugin) {
|
|
165
|
-
return transportPlugin.name;
|
|
166
|
-
}
|
|
167
|
-
return transport.name;
|
|
165
|
+
return activeName || 'UnknownTransport';
|
|
168
166
|
}
|
|
169
167
|
getTransportInfo() {
|
|
170
168
|
return {
|
|
@@ -173,11 +171,12 @@ class DeviceList extends events_1.default {
|
|
|
173
171
|
outdated: this.transport.isOutdated,
|
|
174
172
|
};
|
|
175
173
|
}
|
|
176
|
-
dispose() {
|
|
174
|
+
async dispose() {
|
|
177
175
|
this.removeAllListeners();
|
|
178
176
|
if (this.stream) {
|
|
179
177
|
this.stream.stop();
|
|
180
178
|
}
|
|
179
|
+
await Promise.all(this.allDevices().map(device => device.dispose()));
|
|
181
180
|
if (this.transport) {
|
|
182
181
|
this.transport.stop();
|
|
183
182
|
}
|
|
@@ -185,7 +184,6 @@ class DeviceList extends events_1.default {
|
|
|
185
184
|
this.fetchController.abort();
|
|
186
185
|
this.fetchController = null;
|
|
187
186
|
}
|
|
188
|
-
this.allDevices().forEach(device => device.dispose());
|
|
189
187
|
}
|
|
190
188
|
disconnectDevices() {
|
|
191
189
|
this.allDevices().forEach(device => {
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { MessageFactoryFn } from '../types/utils';
|
|
2
|
+
import type { Transport } from '@trezor/transport';
|
|
2
3
|
export declare const TRANSPORT_EVENT = "TRANSPORT_EVENT";
|
|
3
4
|
export declare const TRANSPORT: {
|
|
4
5
|
readonly START: "transport-start";
|
|
5
6
|
readonly ERROR: "transport-error";
|
|
6
7
|
readonly UPDATE: "transport-update";
|
|
7
8
|
readonly STREAM: "transport-stream";
|
|
8
|
-
readonly
|
|
9
|
+
readonly REQUEST_DEVICE: "transport-request_device";
|
|
9
10
|
readonly DISABLE_WEBUSB: "transport-disable_webusb";
|
|
10
11
|
readonly START_PENDING: "transport-start_pending";
|
|
11
12
|
};
|
|
@@ -32,7 +33,7 @@ export interface UdevInfo {
|
|
|
32
33
|
}[];
|
|
33
34
|
}
|
|
34
35
|
export interface TransportInfo {
|
|
35
|
-
type:
|
|
36
|
+
type: Transport['name'];
|
|
36
37
|
version: string;
|
|
37
38
|
outdated: boolean;
|
|
38
39
|
bridge?: BridgeInfo;
|
|
@@ -54,6 +55,10 @@ export interface TransportDisableWebUSB {
|
|
|
54
55
|
type: typeof TRANSPORT.DISABLE_WEBUSB;
|
|
55
56
|
payload?: undefined;
|
|
56
57
|
}
|
|
58
|
+
export interface TransportRequestWebUSBDevice {
|
|
59
|
+
type: typeof TRANSPORT.REQUEST_DEVICE;
|
|
60
|
+
payload?: undefined;
|
|
61
|
+
}
|
|
57
62
|
export type TransportEventMessage = TransportEvent & {
|
|
58
63
|
event: typeof TRANSPORT_EVENT;
|
|
59
64
|
};
|
package/lib/events/transport.js
CHANGED
|
@@ -8,7 +8,7 @@ exports.TRANSPORT = {
|
|
|
8
8
|
ERROR: 'transport-error',
|
|
9
9
|
UPDATE: 'transport-update',
|
|
10
10
|
STREAM: 'transport-stream',
|
|
11
|
-
|
|
11
|
+
REQUEST_DEVICE: 'transport-request_device',
|
|
12
12
|
DISABLE_WEBUSB: 'transport-disable_webusb',
|
|
13
13
|
START_PENDING: 'transport-start_pending',
|
|
14
14
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { EventTypeDeviceSelected } from '@trezor/connect-analytics';
|
|
2
2
|
import type { PROTO } from '../constants';
|
|
3
|
-
import type { TransportDisableWebUSB } from './transport';
|
|
3
|
+
import type { TransportDisableWebUSB, TransportRequestWebUSBDevice } from './transport';
|
|
4
4
|
import type { Device, CoinInfo, BitcoinNetworkInfo } from '../types';
|
|
5
5
|
import type { DiscoveryAccountType, DiscoveryAccount, SelectFeeLevel } from '../types/account';
|
|
6
6
|
import type { MessageFactoryFn } from '../types/utils';
|
|
@@ -200,7 +200,7 @@ export interface FirmwareProgress {
|
|
|
200
200
|
progress: number;
|
|
201
201
|
};
|
|
202
202
|
}
|
|
203
|
-
export type UiEvent = UiRequestWithoutPayload | UiRequestDeviceAction | UiRequestButton | UiRequestPermission | UiRequestConfirmation | UiRequestSelectDevice | UiRequestUnexpectedDeviceMode | UiRequestSelectAccount | UiRequestSelectFee | UpdateCustomFee | BundleProgress<any> | FirmwareProgress | FirmwareException | UiRequestAddressValidation | UiRequestSetOperation | TransportDisableWebUSB;
|
|
203
|
+
export type UiEvent = UiRequestWithoutPayload | UiRequestDeviceAction | UiRequestButton | UiRequestPermission | UiRequestConfirmation | UiRequestSelectDevice | UiRequestUnexpectedDeviceMode | UiRequestSelectAccount | UiRequestSelectFee | UpdateCustomFee | BundleProgress<any> | FirmwareProgress | FirmwareException | UiRequestAddressValidation | UiRequestSetOperation | TransportDisableWebUSB | TransportRequestWebUSBDevice;
|
|
204
204
|
export type UiEventMessage = UiEvent & {
|
|
205
205
|
event: typeof UI_EVENT;
|
|
206
206
|
};
|
package/lib/factory.d.ts
CHANGED
|
@@ -11,9 +11,10 @@ interface Dependencies {
|
|
|
11
11
|
uiResponse: TrezorConnect['uiResponse'];
|
|
12
12
|
renderWebUSBButton: TrezorConnect['renderWebUSBButton'];
|
|
13
13
|
disableWebUSB: TrezorConnect['disableWebUSB'];
|
|
14
|
+
requestWebUSBDevice: TrezorConnect['requestWebUSBDevice'];
|
|
14
15
|
cancel: TrezorConnect['cancel'];
|
|
15
16
|
dispose: TrezorConnect['dispose'];
|
|
16
17
|
}
|
|
17
|
-
export declare const factory: ({ eventEmitter, manifest, init, call, requestLogin, uiResponse, renderWebUSBButton, disableWebUSB, cancel, dispose, }: Dependencies) => TrezorConnect;
|
|
18
|
+
export declare const factory: ({ eventEmitter, manifest, init, call, requestLogin, uiResponse, renderWebUSBButton, disableWebUSB, requestWebUSBDevice, cancel, dispose, }: Dependencies) => TrezorConnect;
|
|
18
19
|
export {};
|
|
19
20
|
//# sourceMappingURL=factory.d.ts.map
|
package/lib/factory.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.factory = void 0;
|
|
4
4
|
const events_1 = require("./events");
|
|
5
|
-
const factory = ({ eventEmitter, manifest, init, call, requestLogin, uiResponse, renderWebUSBButton, disableWebUSB, cancel, dispose, }) => {
|
|
5
|
+
const factory = ({ eventEmitter, manifest, init, call, requestLogin, uiResponse, renderWebUSBButton, disableWebUSB, requestWebUSBDevice, cancel, dispose, }) => {
|
|
6
6
|
const api = {
|
|
7
7
|
manifest,
|
|
8
8
|
init,
|
|
@@ -110,7 +110,7 @@ const factory = ({ eventEmitter, manifest, init, call, requestLogin, uiResponse,
|
|
|
110
110
|
checkFirmwareAuthenticity: params => call({ ...params, method: 'checkFirmwareAuthenticity' }),
|
|
111
111
|
applyFlags: params => call({ ...params, method: 'applyFlags' }),
|
|
112
112
|
applySettings: params => call({ ...params, method: 'applySettings' }),
|
|
113
|
-
|
|
113
|
+
authorizeCoinjoin: params => call({ ...params, method: 'authorizeCoinjoin' }),
|
|
114
114
|
backupDevice: params => call({ ...params, method: 'backupDevice' }),
|
|
115
115
|
changePin: params => call({ ...params, method: 'changePin' }),
|
|
116
116
|
firmwareUpdate: params => call({ ...params, method: 'firmwareUpdate' }),
|
|
@@ -123,6 +123,7 @@ const factory = ({ eventEmitter, manifest, init, call, requestLogin, uiResponse,
|
|
|
123
123
|
cancel,
|
|
124
124
|
renderWebUSBButton,
|
|
125
125
|
disableWebUSB,
|
|
126
|
+
requestWebUSBDevice,
|
|
126
127
|
};
|
|
127
128
|
return api;
|
|
128
129
|
};
|
package/lib/index-browser.js
CHANGED
package/lib/index.js
CHANGED
|
@@ -22,11 +22,11 @@ const manifest = (data) => {
|
|
|
22
22
|
manifest: data,
|
|
23
23
|
});
|
|
24
24
|
};
|
|
25
|
-
const dispose = () => {
|
|
25
|
+
const dispose = async () => {
|
|
26
26
|
exports.eventEmitter.removeAllListeners();
|
|
27
27
|
_settings = (0, connectSettings_1.parseConnectSettings)();
|
|
28
28
|
if (_core) {
|
|
29
|
-
_core.dispose();
|
|
29
|
+
await _core.dispose();
|
|
30
30
|
_core = null;
|
|
31
31
|
}
|
|
32
32
|
};
|
|
@@ -90,6 +90,7 @@ function postMessage(message, usePromise = true) {
|
|
|
90
90
|
_core.handleMessage(message, true);
|
|
91
91
|
}
|
|
92
92
|
const init = async (settings = {}) => {
|
|
93
|
+
var _a;
|
|
93
94
|
if (_core) {
|
|
94
95
|
throw constants_1.ERRORS.TypedError('Init_AlreadyInitialized');
|
|
95
96
|
}
|
|
@@ -100,6 +101,9 @@ const init = async (settings = {}) => {
|
|
|
100
101
|
if (!_settings.manifest) {
|
|
101
102
|
throw constants_1.ERRORS.TypedError('Init_ManifestMissing');
|
|
102
103
|
}
|
|
104
|
+
if (!((_a = _settings.transports) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
105
|
+
_settings.transports = ['BridgeTransport'];
|
|
106
|
+
}
|
|
103
107
|
if (_settings.lazyLoad) {
|
|
104
108
|
_settings.lazyLoad = false;
|
|
105
109
|
return;
|
|
@@ -186,6 +190,9 @@ const renderWebUSBButton = (_className) => {
|
|
|
186
190
|
const disableWebUSB = () => {
|
|
187
191
|
throw constants_1.ERRORS.TypedError('Method_InvalidPackage');
|
|
188
192
|
};
|
|
193
|
+
const requestWebUSBDevice = () => {
|
|
194
|
+
throw constants_1.ERRORS.TypedError('Method_InvalidPackage');
|
|
195
|
+
};
|
|
189
196
|
const TrezorConnect = (0, factory_1.factory)({
|
|
190
197
|
eventEmitter: exports.eventEmitter,
|
|
191
198
|
manifest,
|
|
@@ -195,6 +202,7 @@ const TrezorConnect = (0, factory_1.factory)({
|
|
|
195
202
|
uiResponse,
|
|
196
203
|
renderWebUSBButton,
|
|
197
204
|
disableWebUSB,
|
|
205
|
+
requestWebUSBDevice,
|
|
198
206
|
cancel,
|
|
199
207
|
dispose,
|
|
200
208
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { PROTO } from '../../constants';
|
|
2
2
|
import type { Params, Response } from '../params';
|
|
3
|
-
export interface
|
|
3
|
+
export interface AuthorizeCoinjoin {
|
|
4
4
|
path: string | number[];
|
|
5
5
|
coordinator: string;
|
|
6
6
|
maxRounds: number;
|
|
@@ -11,5 +11,5 @@ export interface AuthorizeCoinJoin {
|
|
|
11
11
|
amountUnit?: PROTO.AmountUnit;
|
|
12
12
|
preauthorized?: boolean;
|
|
13
13
|
}
|
|
14
|
-
export declare function
|
|
15
|
-
//# sourceMappingURL=
|
|
14
|
+
export declare function authorizeCoinjoin(params: Params<AuthorizeCoinjoin>): Response<PROTO.Success>;
|
|
15
|
+
//# sourceMappingURL=authorizeCoinjoin.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function dispose(): void
|
|
1
|
+
export declare function dispose(): Promise<void>;
|
|
2
2
|
//# sourceMappingURL=dispose.d.ts.map
|
package/lib/types/api/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { applyFlags } from './applyFlags';
|
|
2
2
|
import { applySettings } from './applySettings';
|
|
3
|
-
import {
|
|
3
|
+
import { authorizeCoinjoin } from './authorizeCoinjoin';
|
|
4
4
|
import { backupDevice } from './backupDevice';
|
|
5
5
|
import { binanceGetAddress } from './binanceGetAddress';
|
|
6
6
|
import { binanceGetPublicKey } from './binanceGetPublicKey';
|
|
@@ -57,6 +57,7 @@ import { recoveryDevice } from './recoveryDevice';
|
|
|
57
57
|
import { removeAllListeners } from './removeAllListeners';
|
|
58
58
|
import { renderWebUSBButton } from './renderWebUSBButton';
|
|
59
59
|
import { requestLogin } from './requestLogin';
|
|
60
|
+
import { requestWebUSBDevice } from './requestWebUSBDevice';
|
|
60
61
|
import { resetDevice } from './resetDevice';
|
|
61
62
|
import { rippleGetAddress } from './rippleGetAddress';
|
|
62
63
|
import { rippleSignTransaction } from './rippleSignTransaction';
|
|
@@ -77,7 +78,7 @@ import { checkFirmwareAuthenticity } from './checkFirmwareAuthenticity';
|
|
|
77
78
|
export interface TrezorConnect {
|
|
78
79
|
applyFlags: typeof applyFlags;
|
|
79
80
|
applySettings: typeof applySettings;
|
|
80
|
-
|
|
81
|
+
authorizeCoinjoin: typeof authorizeCoinjoin;
|
|
81
82
|
backupDevice: typeof backupDevice;
|
|
82
83
|
binanceGetAddress: typeof binanceGetAddress;
|
|
83
84
|
binanceGetPublicKey: typeof binanceGetPublicKey;
|
|
@@ -102,6 +103,7 @@ export interface TrezorConnect {
|
|
|
102
103
|
cipherKeyValue: typeof cipherKeyValue;
|
|
103
104
|
composeTransaction: typeof composeTransaction;
|
|
104
105
|
disableWebUSB: typeof disableWebUSB;
|
|
106
|
+
requestWebUSBDevice: typeof requestWebUSBDevice;
|
|
105
107
|
dispose: typeof dispose;
|
|
106
108
|
eosGetPublicKey: typeof eosGetPublicKey;
|
|
107
109
|
eosSignTransaction: typeof eosSignTransaction;
|
package/lib/types/params.d.ts
CHANGED
package/lib/types/settings.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { BlockchainSettings } from '@trezor/blockchain-link';
|
|
2
|
+
import type { Transport } from '@trezor/transport';
|
|
2
3
|
export interface Manifest {
|
|
3
4
|
appUrl: string;
|
|
4
5
|
email: string;
|
|
@@ -13,6 +14,7 @@ export interface ConnectSettings {
|
|
|
13
14
|
popup?: boolean;
|
|
14
15
|
transportReconnect?: boolean;
|
|
15
16
|
webusb?: boolean;
|
|
17
|
+
transports?: Transport['name'][];
|
|
16
18
|
pendingTransportEvent?: boolean;
|
|
17
19
|
lazyLoad?: boolean;
|
|
18
20
|
interactionTimeout?: number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trezor/connect",
|
|
3
|
-
"version": "9.0.
|
|
3
|
+
"version": "9.0.7",
|
|
4
4
|
"author": "Trezor <info@trezor.io>",
|
|
5
5
|
"homepage": "https://github.com/trezor/trezor-suite/tree/develop/packages/connect",
|
|
6
6
|
"description": "High-level javascript interface for Trezor hardware wallet.",
|
|
@@ -49,18 +49,19 @@
|
|
|
49
49
|
"prepublish": "yarn tsx ../../scripts/prepublish.js"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@trezor/blockchain-link": "^2.1.
|
|
53
|
-
"@trezor/connect-common": "0.0.
|
|
54
|
-
"@trezor/transport": "^1.1.
|
|
55
|
-
"@trezor/utils": "^9.0.
|
|
56
|
-
"@trezor/utxo-lib": "^1.0.
|
|
57
|
-
"bignumber.js": "^9.1.
|
|
52
|
+
"@trezor/blockchain-link": "^2.1.8",
|
|
53
|
+
"@trezor/connect-common": "0.0.12",
|
|
54
|
+
"@trezor/transport": "^1.1.8",
|
|
55
|
+
"@trezor/utils": "^9.0.6",
|
|
56
|
+
"@trezor/utxo-lib": "^1.0.4",
|
|
57
|
+
"bignumber.js": "^9.1.1",
|
|
58
58
|
"blakejs": "^1.2.1",
|
|
59
59
|
"bowser": "^2.11.0",
|
|
60
60
|
"cross-fetch": "^3.1.5",
|
|
61
61
|
"events": "^3.3.0",
|
|
62
62
|
"parse-uri": "1.0.7",
|
|
63
|
-
"randombytes": "2.1.0"
|
|
63
|
+
"randombytes": "2.1.0",
|
|
64
|
+
"tslib": "2.5.0"
|
|
64
65
|
},
|
|
65
66
|
"devDependencies": {
|
|
66
67
|
"@trezor/connect-analytics": "1.0.0",
|
|
@@ -74,11 +75,12 @@
|
|
|
74
75
|
"karma-chrome-launcher": "^3.1.1",
|
|
75
76
|
"karma-jasmine": "^5.1.0",
|
|
76
77
|
"karma-jasmine-async": "^0.0.1",
|
|
77
|
-
"karma-sourcemap-loader": "^0.
|
|
78
|
+
"karma-sourcemap-loader": "^0.4.0",
|
|
78
79
|
"karma-webpack": "^5.0.0",
|
|
79
|
-
"rimraf": "^
|
|
80
|
+
"rimraf": "^4.1.2",
|
|
81
|
+
"ts-loader": "^9.4.2",
|
|
80
82
|
"ts-node": "^10.9.1",
|
|
81
|
-
"tsx": "^3.
|
|
82
|
-
"typescript": "4.9.
|
|
83
|
+
"tsx": "^3.12.3",
|
|
84
|
+
"typescript": "4.9.5"
|
|
83
85
|
}
|
|
84
86
|
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { AbstractMethod } from '../core/AbstractMethod';
|
|
2
|
-
import { PROTO } from '../constants';
|
|
3
|
-
export default class AuthorizeCoinJoin extends AbstractMethod<'authorizeCoinJoin', PROTO.AuthorizeCoinJoin> {
|
|
4
|
-
init(): void;
|
|
5
|
-
run(): Promise<PROTO.Success>;
|
|
6
|
-
}
|
|
7
|
-
//# sourceMappingURL=authorizeCoinJoin.d.ts.map
|