@trezor/connect 9.0.4 → 9.0.5
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 +67 -0
- package/README.md +1 -1
- package/lib/api/binanceGetAddress.d.ts +1 -1
- package/lib/api/binanceSignTransaction.d.ts +1 -1
- package/lib/api/bitcoin/Fees.d.ts +1 -1
- package/lib/api/bitcoin/TransactionComposer.d.ts +1 -1
- package/lib/api/bitcoin/signtxVerify.d.ts +1 -1
- package/lib/api/blockchainDisconnect.d.ts +1 -1
- package/lib/api/blockchainEstimateFee.d.ts +1 -1
- package/lib/api/blockchainGetAccountBalanceHistory.d.ts +1 -1
- package/lib/api/blockchainGetCurrentFiatRates.d.ts +1 -1
- package/lib/api/blockchainGetFiatRatesForTimestamps.d.ts +1 -1
- package/lib/api/blockchainGetTransactions.d.ts +1 -1
- package/lib/api/blockchainSetCustomBackend.d.ts +1 -1
- package/lib/api/blockchainSubscribe.d.ts +1 -1
- package/lib/api/blockchainSubscribeFiatRates.d.ts +1 -1
- package/lib/api/blockchainUnsubscribe.d.ts +1 -1
- package/lib/api/blockchainUnsubscribeFiatRates.d.ts +1 -1
- package/lib/api/cardano/cardanoCertificate.d.ts +2 -2
- package/lib/api/cardano/cardanoInputs.d.ts +3 -3
- package/lib/api/cardano/cardanoOutputs.d.ts +1 -1
- package/lib/api/cardano/cardanoTokenBundle.d.ts +1 -1
- package/lib/api/cardanoGetAddress.d.ts +1 -1
- package/lib/api/cardanoSignTransaction.d.ts +1 -1
- package/lib/api/common/Discovery.d.ts +2 -2
- package/lib/api/common/paramsValidator.d.ts +2 -2
- package/lib/api/composeTransaction.d.ts +1 -1
- package/lib/api/eos/eosSignTx.js +1 -1
- package/lib/api/eosSignTransaction.d.ts +1 -1
- package/lib/api/ethereumGetAddress.d.ts +1 -1
- package/lib/api/ethereumGetPublicKey.d.ts +1 -1
- package/lib/api/ethereumSignTransaction.d.ts +1 -1
- package/lib/api/ethereumSignTypedData.d.ts +1 -1
- package/lib/api/firmware/uploadFirmware.d.ts +2 -2
- package/lib/api/firmwareUpdate.d.ts +1 -1
- package/lib/api/firmwareUpdate.js +1 -1
- package/lib/api/getAccountInfo.d.ts +1 -1
- package/lib/api/getAddress.d.ts +1 -1
- package/lib/api/getCoinInfo.d.ts +2 -2
- package/lib/api/getPublicKey.d.ts +1 -1
- package/lib/api/nemGetAddress.d.ts +1 -1
- package/lib/api/pushTransaction.d.ts +1 -1
- package/lib/api/rippleGetAddress.d.ts +1 -1
- package/lib/api/setBusy.js +5 -1
- package/lib/api/setProxy.js +3 -4
- package/lib/api/signTransaction.d.ts +1 -1
- package/lib/api/stellarGetAddress.d.ts +1 -1
- package/lib/api/stellarSignTransaction.d.ts +1 -1
- package/lib/api/tezosGetAddress.d.ts +1 -1
- package/lib/backend/BackendManager.d.ts +1 -1
- package/lib/backend/BackendManager.js +0 -4
- package/lib/backend/Blockchain.d.ts +3 -9
- package/lib/backend/Blockchain.js +2 -17
- package/lib/constants/network.d.ts +1 -1
- package/lib/core/AbstractMethod.d.ts +4 -4
- package/lib/core/AbstractMethod.js +7 -5
- package/lib/core/index.js +2 -0
- package/lib/data/DataManager.d.ts +1 -1
- package/lib/data/analyticsInfo.d.ts +6 -0
- package/lib/data/analyticsInfo.js +37 -0
- package/lib/data/version.d.ts +1 -1
- package/lib/data/version.js +1 -1
- package/lib/device/AbortController.d.ts +1 -1
- package/lib/device/DescriptorStream.d.ts +1 -1
- package/lib/device/Device.d.ts +1 -1
- package/lib/device/Device.js +3 -0
- package/lib/device/DeviceCommands.d.ts +7 -7
- package/lib/device/DeviceCommands.js +3 -1
- package/lib/device/DeviceList.d.ts +1 -1
- package/lib/events/blockchain.d.ts +4 -5
- package/lib/events/call.d.ts +10 -10
- package/lib/events/core.d.ts +3 -2
- package/lib/events/device.d.ts +3 -3
- package/lib/events/iframe.d.ts +2 -2
- package/lib/events/popup.d.ts +2 -2
- package/lib/events/transport.d.ts +3 -3
- package/lib/events/ui-promise.d.ts +2 -2
- package/lib/events/ui-request.d.ts +8 -6
- package/lib/events/ui-response.d.ts +2 -2
- package/lib/types/account.d.ts +2 -2
- package/lib/types/api/binance/index.d.ts +1 -1
- package/lib/types/api/bitcoin/index.d.ts +2 -2
- package/lib/types/api/blockchainGetTransactions.d.ts +1 -1
- package/lib/types/api/blockchainSetCustomBackend.d.ts +1 -1
- package/lib/types/api/blockchainSubscribe.d.ts +1 -1
- package/lib/types/api/blockchainSubscribeFiatRates.d.ts +1 -1
- package/lib/types/api/cardano/index.d.ts +2 -2
- package/lib/types/api/composeTransaction.d.ts +3 -3
- package/lib/types/api/eos/index.d.ts +1 -1
- package/lib/types/api/getAddress.d.ts +1 -1
- package/lib/types/api/nem/index.d.ts +9 -9
- package/lib/types/api/off.d.ts +2 -2
- package/lib/types/api/on.d.ts +2 -2
- package/lib/types/api/pushTransaction.d.ts +1 -1
- package/lib/types/api/setProxy.d.ts +1 -2
- package/lib/types/api/stellar/index.d.ts +2 -2
- package/lib/types/coinInfo.d.ts +3 -3
- package/lib/types/device.d.ts +13 -13
- package/lib/types/firmware.d.ts +3 -3
- package/lib/types/params.d.ts +3 -3
- package/lib/types/settings.d.ts +1 -2
- package/lib/types/utils.d.ts +2 -2
- package/lib/utils/accountUtils.d.ts +1 -1
- package/lib/utils/browserUtils.d.ts +2 -2
- package/lib/utils/debug.d.ts +1 -1
- package/lib/utils/deferred.d.ts +2 -2
- package/lib/utils/interactionTimeout.d.ts +1 -1
- package/lib/workers/RNUsbPlugin.d.ts +1 -1
- package/lib/workers/workers.d.ts +1 -1
- package/package.json +83 -80
|
@@ -5,7 +5,6 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const blockchain_link_1 = tslib_1.__importDefault(require("@trezor/blockchain-link"));
|
|
6
6
|
const events_1 = require("../events");
|
|
7
7
|
const constants_1 = require("../constants");
|
|
8
|
-
const urlUtils_1 = require("../utils/urlUtils");
|
|
9
8
|
const workers_1 = require("../workers/workers");
|
|
10
9
|
const getWorker = (type) => {
|
|
11
10
|
switch (type) {
|
|
@@ -37,19 +36,7 @@ class Blockchain {
|
|
|
37
36
|
if (!worker) {
|
|
38
37
|
throw constants_1.ERRORS.TypedError('Backend_WorkerMissing', `BlockchainLink worker not found ${blockchainLink.type}`);
|
|
39
38
|
}
|
|
40
|
-
const
|
|
41
|
-
this.onionDomains = onionDomains
|
|
42
|
-
? blockchainLink.url.reduce((a, url) => {
|
|
43
|
-
const onion = (0, urlUtils_1.getOnionDomain)(url, onionDomains);
|
|
44
|
-
if (onion !== url) {
|
|
45
|
-
a[onion] = url;
|
|
46
|
-
}
|
|
47
|
-
return a;
|
|
48
|
-
}, {})
|
|
49
|
-
: {};
|
|
50
|
-
const server = Object.keys(this.onionDomains).length
|
|
51
|
-
? Object.keys(this.onionDomains)
|
|
52
|
-
: blockchainLink.url;
|
|
39
|
+
const server = blockchainLink.url;
|
|
53
40
|
this.link = new blockchain_link_1.default({
|
|
54
41
|
name: this.coinInfo.shortcut,
|
|
55
42
|
worker,
|
|
@@ -78,12 +65,10 @@ class Blockchain {
|
|
|
78
65
|
this.onError(constants_1.ERRORS.TypedError('Backend_Invalid'));
|
|
79
66
|
return;
|
|
80
67
|
}
|
|
81
|
-
|
|
82
|
-
(_a = this.onConnected) === null || _a === void 0 ? void 0 : _a.call(this, cleanUrl || info.url);
|
|
68
|
+
(_a = this.onConnected) === null || _a === void 0 ? void 0 : _a.call(this, info.url);
|
|
83
69
|
this.postMessage((0, events_1.createBlockchainMessage)(events_1.BLOCKCHAIN.CONNECT, {
|
|
84
70
|
coin: this.coinInfo,
|
|
85
71
|
...info,
|
|
86
|
-
cleanUrl,
|
|
87
72
|
}));
|
|
88
73
|
});
|
|
89
74
|
this.link.on('disconnected', () => {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { NETWORK } from '../constants';
|
|
2
|
-
import { CallMethodPayload, CallMethodResponse,
|
|
2
|
+
import { CallMethodPayload, CallMethodResponse, UiRequestButtonData, UiPromise, UiPromiseResponse, PostMessage } from '../events';
|
|
3
3
|
import { Deferred } from '../utils/deferred';
|
|
4
4
|
import type { Device } from '../device/Device';
|
|
5
5
|
import type { FirmwareRange } from '../types';
|
|
6
|
-
export
|
|
6
|
+
export type Payload<M> = Extract<CallMethodPayload, {
|
|
7
7
|
method: M;
|
|
8
8
|
}> & {
|
|
9
9
|
override?: boolean;
|
|
10
10
|
};
|
|
11
|
-
export
|
|
11
|
+
export type MethodReturnType<M extends CallMethodPayload['method']> = CallMethodResponse<M>;
|
|
12
12
|
export declare abstract class AbstractMethod<Name extends CallMethodPayload['method'], Params = undefined> {
|
|
13
13
|
responseID: number;
|
|
14
14
|
device: Device;
|
|
@@ -39,7 +39,7 @@ export declare abstract class AbstractMethod<Name extends CallMethodPayload['met
|
|
|
39
39
|
confirmation?(): Promise<boolean | undefined>;
|
|
40
40
|
noBackupConfirmation?(): Promise<boolean>;
|
|
41
41
|
getButtonRequestData?(code: string): UiRequestButtonData | undefined;
|
|
42
|
-
postMessage:
|
|
42
|
+
postMessage: PostMessage;
|
|
43
43
|
getPopupPromise: () => Deferred<void>;
|
|
44
44
|
createUiPromise: <T extends UiPromiseResponse['type']>(promiseId: T, device?: Device) => UiPromise<T>;
|
|
45
45
|
removeUiPromise: (promise: Deferred<any>) => void;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AbstractMethod = void 0;
|
|
4
|
-
const
|
|
5
|
-
const storage = tslib_1.__importStar(require("@trezor/connect-common/lib/storage"));
|
|
4
|
+
const connect_common_1 = require("@trezor/connect-common");
|
|
6
5
|
const DataManager_1 = require("../data/DataManager");
|
|
7
6
|
const constants_1 = require("../constants");
|
|
8
7
|
const events_1 = require("../events");
|
|
@@ -77,7 +76,7 @@ class AbstractMethod {
|
|
|
77
76
|
return false;
|
|
78
77
|
}
|
|
79
78
|
checkPermissions() {
|
|
80
|
-
const savedPermissions = storage.load(
|
|
79
|
+
const savedPermissions = connect_common_1.storage.load().permissions;
|
|
81
80
|
let notPermitted = [...this.requiredPermissions];
|
|
82
81
|
if (savedPermissions) {
|
|
83
82
|
const originPermissions = savedPermissions.filter(p => p.origin === DataManager_1.DataManager.getSettings('origin'));
|
|
@@ -91,7 +90,7 @@ class AbstractMethod {
|
|
|
91
90
|
this.requiredPermissions = notPermitted;
|
|
92
91
|
}
|
|
93
92
|
savePermissions(temporary = false) {
|
|
94
|
-
const savedPermissions = storage.load(
|
|
93
|
+
const savedPermissions = connect_common_1.storage.load(temporary).permissions || [];
|
|
95
94
|
let permissionsToSave = this.requiredPermissions.map(p => ({
|
|
96
95
|
origin: DataManager_1.DataManager.getSettings('origin'),
|
|
97
96
|
type: p,
|
|
@@ -113,7 +112,10 @@ class AbstractMethod {
|
|
|
113
112
|
return !granted;
|
|
114
113
|
});
|
|
115
114
|
}
|
|
116
|
-
storage.save(
|
|
115
|
+
connect_common_1.storage.save(state => ({
|
|
116
|
+
...state,
|
|
117
|
+
permissions: savedPermissions.concat(permissionsToSave),
|
|
118
|
+
}), temporary);
|
|
117
119
|
if (emitEvent) {
|
|
118
120
|
this.postMessage((0, events_1.createDeviceMessage)(events_1.DEVICE.CONNECT, this.device.toMessageObject()));
|
|
119
121
|
}
|
package/lib/core/index.js
CHANGED
|
@@ -5,6 +5,7 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const events_1 = tslib_1.__importDefault(require("events"));
|
|
6
6
|
const DataManager_1 = require("../data/DataManager");
|
|
7
7
|
const DeviceList_1 = require("../device/DeviceList");
|
|
8
|
+
const analyticsInfo_1 = require("../data/analyticsInfo");
|
|
8
9
|
const constants_1 = require("../constants");
|
|
9
10
|
const events_2 = require("../events");
|
|
10
11
|
const method_1 = require("./method");
|
|
@@ -216,6 +217,7 @@ const onCall = async (message) => {
|
|
|
216
217
|
postMessage((0, events_2.createResponseMessage)(responseID, false, { error }));
|
|
217
218
|
throw error;
|
|
218
219
|
}
|
|
220
|
+
method.postMessage = (message) => (0, analyticsInfo_1.enhancePostMessageWithAnalytics)(postMessage, message, { device: device.toMessageObject() });
|
|
219
221
|
method.setDevice(device);
|
|
220
222
|
const previousCall = _callMethods.filter(call => call && call !== method && call.devicePath === method.devicePath);
|
|
221
223
|
if (previousCall.length > 0 && method.overridePreviousCall) {
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { CoreMessage, PostMessage } from '../events';
|
|
2
|
+
import type { Device } from '../types';
|
|
3
|
+
export declare const enhancePostMessageWithAnalytics: (callback: PostMessage, message: CoreMessage, data: {
|
|
4
|
+
device?: Device;
|
|
5
|
+
}) => void;
|
|
6
|
+
//# sourceMappingURL=analyticsInfo.d.ts.map
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.enhancePostMessageWithAnalytics = void 0;
|
|
4
|
+
const events_1 = require("../events");
|
|
5
|
+
const enhancePostMessageWithAnalytics = (callback, message, data) => {
|
|
6
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
7
|
+
switch (message.type) {
|
|
8
|
+
case events_1.UI_REQUEST.REQUEST_CONFIRMATION:
|
|
9
|
+
const { device } = data;
|
|
10
|
+
callback({
|
|
11
|
+
...message,
|
|
12
|
+
payload: {
|
|
13
|
+
...message.payload,
|
|
14
|
+
analytics: {
|
|
15
|
+
type: 'device/selected',
|
|
16
|
+
payload: {
|
|
17
|
+
mode: (device === null || device === void 0 ? void 0 : device.mode) || '',
|
|
18
|
+
pinProtection: ((_a = device === null || device === void 0 ? void 0 : device.features) === null || _a === void 0 ? void 0 : _a.pin_protection) || '',
|
|
19
|
+
passphraseProtection: ((_b = device === null || device === void 0 ? void 0 : device.features) === null || _b === void 0 ? void 0 : _b.passphrase_protection) || '',
|
|
20
|
+
backupType: ((_c = device === null || device === void 0 ? void 0 : device.features) === null || _c === void 0 ? void 0 : _c.backup_type) || 'Bip39',
|
|
21
|
+
language: ((_d = device === null || device === void 0 ? void 0 : device.features) === null || _d === void 0 ? void 0 : _d.language) || '',
|
|
22
|
+
model: ((_e = device === null || device === void 0 ? void 0 : device.features) === null || _e === void 0 ? void 0 : _e.model) || '',
|
|
23
|
+
vendor: ((_f = device === null || device === void 0 ? void 0 : device.features) === null || _f === void 0 ? void 0 : _f.vendor) || '',
|
|
24
|
+
firmwareRevision: ((_g = device === null || device === void 0 ? void 0 : device.features) === null || _g === void 0 ? void 0 : _g.revision) || '',
|
|
25
|
+
firmwareType: (device === null || device === void 0 ? void 0 : device.firmwareType) || '',
|
|
26
|
+
bootloaderHash: ((_h = device === null || device === void 0 ? void 0 : device.features) === null || _h === void 0 ? void 0 : _h.bootloader_hash) || '',
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
break;
|
|
32
|
+
default:
|
|
33
|
+
callback(message);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
exports.enhancePostMessageWithAnalytics = enhancePostMessageWithAnalytics;
|
|
37
|
+
//# sourceMappingURL=analyticsInfo.js.map
|
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.5';
|
|
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
|
|
@@ -15,7 +15,7 @@ declare class AbortControllerFallback {
|
|
|
15
15
|
abort(): void;
|
|
16
16
|
toString(): string;
|
|
17
17
|
}
|
|
18
|
-
export
|
|
18
|
+
export type Controller = AbortController | AbortControllerFallback;
|
|
19
19
|
export declare const getAbortController: () => AbortControllerFallback | AbortController;
|
|
20
20
|
export {};
|
|
21
21
|
//# sourceMappingURL=AbortController.d.ts.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import EventEmitter from 'events';
|
|
3
3
|
import type { Transport, TrezorDeviceInfoWithSession as DeviceDescriptor } from '@trezor/transport';
|
|
4
|
-
export
|
|
4
|
+
export type DeviceDescriptorDiff = {
|
|
5
5
|
didUpdate: boolean;
|
|
6
6
|
connected: DeviceDescriptor[];
|
|
7
7
|
disconnected: DeviceDescriptor[];
|
package/lib/device/Device.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { DEVICE, DeviceButtonRequestPayload } from '../events';
|
|
|
6
6
|
import { Deferred } from '../utils/deferred';
|
|
7
7
|
import type { Transport, TrezorDeviceInfoWithSession as DeviceDescriptor } from '@trezor/transport';
|
|
8
8
|
import type { Device as DeviceTyped, DeviceFirmwareStatus, Features, ReleaseInfo, UnavailableCapabilities } from '../types';
|
|
9
|
-
export
|
|
9
|
+
export type RunOptions = {
|
|
10
10
|
skipFinalReload?: boolean;
|
|
11
11
|
waiting?: boolean;
|
|
12
12
|
onlyOneActivity?: boolean;
|
package/lib/device/Device.js
CHANGED
|
@@ -310,6 +310,9 @@ class Device extends events_1.default {
|
|
|
310
310
|
feat.unlocked = (_a = feat.unlocked) !== null && _a !== void 0 ? _a : true;
|
|
311
311
|
const revision = (0, deviceFeaturesUtils_1.parseRevision)(feat);
|
|
312
312
|
feat.revision = revision;
|
|
313
|
+
if (!feat.model && feat.major_version === 1) {
|
|
314
|
+
feat.model = '1';
|
|
315
|
+
}
|
|
313
316
|
this.features = feat;
|
|
314
317
|
this.featuresNeedsReload = false;
|
|
315
318
|
this.firmwareType =
|
|
@@ -2,17 +2,17 @@ import { Transport, Messages } from '@trezor/transport';
|
|
|
2
2
|
import type { Device } from './Device';
|
|
3
3
|
import type { CoinInfo, BitcoinNetworkInfo } from '../types';
|
|
4
4
|
import type { HDNodeResponse } from '../types/api/getPublicKey';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export
|
|
5
|
+
type MessageType = Messages.MessageType;
|
|
6
|
+
type MessageKey = keyof MessageType;
|
|
7
|
+
export type TypedResponseMessage<T extends MessageKey> = {
|
|
8
8
|
type: T;
|
|
9
9
|
message: MessageType[T];
|
|
10
10
|
};
|
|
11
|
-
|
|
11
|
+
type TypedCallResponseMap = {
|
|
12
12
|
[K in keyof MessageType]: TypedResponseMessage<K>;
|
|
13
13
|
};
|
|
14
|
-
export
|
|
15
|
-
export
|
|
14
|
+
export type DefaultMessageResponse = TypedCallResponseMap[keyof MessageType];
|
|
15
|
+
export type PassphrasePromptResponse = {
|
|
16
16
|
passphrase?: string;
|
|
17
17
|
passphraseOnDevice?: boolean;
|
|
18
18
|
cache?: boolean;
|
|
@@ -64,6 +64,6 @@ export declare class DeviceCommands {
|
|
|
64
64
|
}>;
|
|
65
65
|
cancel(): Promise<void>;
|
|
66
66
|
}
|
|
67
|
-
export
|
|
67
|
+
export type TypedCall = DeviceCommands['typedCall'];
|
|
68
68
|
export {};
|
|
69
69
|
//# sourceMappingURL=DeviceCommands.d.ts.map
|
|
@@ -113,7 +113,9 @@ class DeviceCommands {
|
|
|
113
113
|
response.xpub = hdnodeUtils.convertXpub(publicKey.xpub, network, coinInfo.network);
|
|
114
114
|
}
|
|
115
115
|
if ((0, pathUtils_1.isTaprootPath)(path)) {
|
|
116
|
-
const fingerprint = Number(publicKey.root_fingerprint || 0)
|
|
116
|
+
const fingerprint = Number(publicKey.root_fingerprint || 0)
|
|
117
|
+
.toString(16)
|
|
118
|
+
.padStart(8, '0');
|
|
117
119
|
const descriptorPath = `${fingerprint}${response.serializedPath.substring(1)}`;
|
|
118
120
|
response.xpubSegwit = `tr([${descriptorPath}]${response.xpub}/<0;1>/*)`;
|
|
119
121
|
}
|
|
@@ -6,7 +6,7 @@ import { DescriptorStream } from './DescriptorStream';
|
|
|
6
6
|
import { Device } from './Device';
|
|
7
7
|
import type { Device as DeviceTyped } from '../types';
|
|
8
8
|
import type { Controller } from './AbortController';
|
|
9
|
-
|
|
9
|
+
type LowLevelPlugin = {
|
|
10
10
|
name: 'WebUsbPlugin' | 'ReactNativePlugin';
|
|
11
11
|
unreadableHidDeviceChange: {
|
|
12
12
|
on: (event: string, fn: any) => void;
|
|
@@ -11,7 +11,6 @@ export declare const BLOCKCHAIN: {
|
|
|
11
11
|
};
|
|
12
12
|
export interface BlockchainInfo extends ServerInfo {
|
|
13
13
|
coin: CoinInfo;
|
|
14
|
-
cleanUrl?: string;
|
|
15
14
|
misc?: {
|
|
16
15
|
reserve?: string;
|
|
17
16
|
};
|
|
@@ -21,7 +20,7 @@ export interface BlockchainError {
|
|
|
21
20
|
error: string;
|
|
22
21
|
code?: string;
|
|
23
22
|
}
|
|
24
|
-
export
|
|
23
|
+
export type BlockchainBlock = BlockEvent['payload'] & {
|
|
25
24
|
coin: CoinInfo;
|
|
26
25
|
};
|
|
27
26
|
export interface BlockchainNotification {
|
|
@@ -32,7 +31,7 @@ export interface BlockchainFiatRatesUpdate {
|
|
|
32
31
|
coin: CoinInfo;
|
|
33
32
|
rates: FiatRates;
|
|
34
33
|
}
|
|
35
|
-
export
|
|
34
|
+
export type BlockchainEvent = {
|
|
36
35
|
type: typeof BLOCKCHAIN.CONNECT;
|
|
37
36
|
payload: BlockchainInfo;
|
|
38
37
|
} | {
|
|
@@ -48,9 +47,9 @@ export declare type BlockchainEvent = {
|
|
|
48
47
|
type: typeof BLOCKCHAIN.FIAT_RATES_UPDATE;
|
|
49
48
|
payload: BlockchainFiatRatesUpdate;
|
|
50
49
|
};
|
|
51
|
-
export
|
|
50
|
+
export type BlockchainEventMessage = BlockchainEvent & {
|
|
52
51
|
event: typeof BLOCKCHAIN_EVENT;
|
|
53
52
|
};
|
|
54
|
-
export
|
|
53
|
+
export type BlockchainEventListenerFn = (type: typeof BLOCKCHAIN_EVENT, cb: (event: BlockchainEventMessage) => void) => void;
|
|
55
54
|
export declare const createBlockchainMessage: MessageFactoryFn<typeof BLOCKCHAIN_EVENT, BlockchainEvent>;
|
|
56
55
|
//# sourceMappingURL=blockchain.d.ts.map
|
package/lib/events/call.d.ts
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
import type { IFRAME } from './iframe';
|
|
2
2
|
import type { TrezorConnect } from '../types/api';
|
|
3
3
|
import type { CommonParams } from '../types/params';
|
|
4
|
-
|
|
4
|
+
type UnwrappedResponse<T> = T extends Promise<infer R> ? R extends {
|
|
5
5
|
success: true;
|
|
6
6
|
payload: infer P;
|
|
7
7
|
} ? P : never : void;
|
|
8
|
-
|
|
8
|
+
type OverloadedMethod<T, E extends Record<string, string>> = T extends {
|
|
9
9
|
(params: infer P1): infer R1;
|
|
10
10
|
(params: infer P2): infer R2;
|
|
11
11
|
} ? ((params: P1 & E) => R1) | ((params: P2 & E) => R2) : T extends (...args: infer P) => infer R ? (params: E & P[0]) => R : never;
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
type UnwrappedMethod<T, M extends Record<string, string>> = T extends () => infer R ? (params: M & CommonParams) => R : OverloadedMethod<T, M>;
|
|
13
|
+
type IsMethodCallable<T> = T extends (...args: any[]) => infer R ? R extends Promise<{
|
|
14
14
|
success: boolean;
|
|
15
15
|
}> ? R : never : never;
|
|
16
|
-
|
|
16
|
+
type CallApi = {
|
|
17
17
|
[K in keyof TrezorConnect]: IsMethodCallable<TrezorConnect[K]> extends never ? never : UnwrappedMethod<TrezorConnect[K], {
|
|
18
18
|
method: K;
|
|
19
19
|
}>;
|
|
20
20
|
};
|
|
21
|
-
export
|
|
22
|
-
export
|
|
23
|
-
export
|
|
24
|
-
export
|
|
25
|
-
export
|
|
21
|
+
export type CallMethodUnion = CallApi[keyof CallApi];
|
|
22
|
+
export type CallMethodPayload = Parameters<CallMethodUnion>[0];
|
|
23
|
+
export type CallMethodResponse<M extends keyof CallApi> = UnwrappedResponse<ReturnType<CallApi[M]>>;
|
|
24
|
+
export type CallMethodAnyResponse = ReturnType<CallMethodUnion>;
|
|
25
|
+
export type CallMethod = (params: CallMethodPayload) => Promise<any>;
|
|
26
26
|
export interface IFrameCallMessage {
|
|
27
27
|
event: typeof IFRAME.CALL;
|
|
28
28
|
type: typeof IFRAME.CALL;
|
package/lib/events/core.d.ts
CHANGED
|
@@ -8,11 +8,12 @@ import type { UiEventMessage } from './ui-request';
|
|
|
8
8
|
import type { UiResponseMessage } from './ui-response';
|
|
9
9
|
import type { Unsuccessful } from '../types/params';
|
|
10
10
|
export declare const CORE_EVENT = "CORE_EVENT";
|
|
11
|
-
export
|
|
11
|
+
export type CoreMessage = {
|
|
12
12
|
id?: number;
|
|
13
13
|
success?: boolean;
|
|
14
14
|
} & (BlockchainEventMessage | DeviceEventMessage | TransportEventMessage | UiEventMessage | UiResponseMessage | IFrameCallMessage | MethodResponseMessage | IFrameEventMessage | PopupEventMessage);
|
|
15
|
-
export
|
|
15
|
+
export type PostMessageEvent = MessageEvent<CoreMessage>;
|
|
16
|
+
export type PostMessage = (message: CoreMessage) => void;
|
|
16
17
|
export declare const parseMessage: (messageData: any) => CoreMessage;
|
|
17
18
|
export declare const createErrorMessage: (error: Error & {
|
|
18
19
|
code?: string;
|
package/lib/events/device.d.ts
CHANGED
|
@@ -28,13 +28,13 @@ export interface DeviceButtonRequest {
|
|
|
28
28
|
device: Device;
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
|
-
export
|
|
31
|
+
export type DeviceEvent = {
|
|
32
32
|
type: typeof DEVICE.CONNECT | typeof DEVICE.CONNECT_UNACQUIRED | typeof DEVICE.CHANGED | typeof DEVICE.DISCONNECT;
|
|
33
33
|
payload: Device;
|
|
34
34
|
} | DeviceButtonRequest;
|
|
35
|
-
export
|
|
35
|
+
export type DeviceEventMessage = DeviceEvent & {
|
|
36
36
|
event: typeof DEVICE_EVENT;
|
|
37
37
|
};
|
|
38
|
-
export
|
|
38
|
+
export type DeviceEventListenerFn = (type: typeof DEVICE_EVENT, cb: (event: DeviceEventMessage) => void) => void;
|
|
39
39
|
export declare const createDeviceMessage: MessageFactoryFn<typeof DEVICE_EVENT, DeviceEvent>;
|
|
40
40
|
//# sourceMappingURL=device.d.ts.map
|
package/lib/events/iframe.d.ts
CHANGED
|
@@ -28,11 +28,11 @@ export interface IFrameInit {
|
|
|
28
28
|
extension?: string;
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
|
-
export
|
|
31
|
+
export type IFrameEvent = {
|
|
32
32
|
type: typeof IFRAME.BOOTSTRAP;
|
|
33
33
|
payload?: typeof undefined;
|
|
34
34
|
} | IFrameLoaded | IFrameInit | IFrameError;
|
|
35
|
-
export
|
|
35
|
+
export type IFrameEventMessage = IFrameEvent & {
|
|
36
36
|
event: typeof UI_EVENT;
|
|
37
37
|
};
|
|
38
38
|
export declare const createIFrameMessage: MessageFactoryFn<typeof UI_EVENT, IFrameEvent>;
|
package/lib/events/popup.d.ts
CHANGED
|
@@ -40,11 +40,11 @@ export interface PopupClosedMessage {
|
|
|
40
40
|
error: any;
|
|
41
41
|
} | null;
|
|
42
42
|
}
|
|
43
|
-
export
|
|
43
|
+
export type PopupEvent = {
|
|
44
44
|
type: typeof POPUP.LOADED | typeof POPUP.CANCEL_POPUP_REQUEST;
|
|
45
45
|
payload?: typeof undefined;
|
|
46
46
|
} | PopupInit | PopupHandshake | PopupError | PopupClosedMessage;
|
|
47
|
-
export
|
|
47
|
+
export type PopupEventMessage = PopupEvent & {
|
|
48
48
|
event: typeof UI_EVENT;
|
|
49
49
|
};
|
|
50
50
|
export declare const createPopupMessage: MessageFactoryFn<typeof UI_EVENT, PopupEvent>;
|
|
@@ -38,7 +38,7 @@ export interface TransportInfo {
|
|
|
38
38
|
bridge?: BridgeInfo;
|
|
39
39
|
udev?: UdevInfo;
|
|
40
40
|
}
|
|
41
|
-
export
|
|
41
|
+
export type TransportEvent = {
|
|
42
42
|
type: typeof TRANSPORT.START;
|
|
43
43
|
payload: TransportInfo;
|
|
44
44
|
} | {
|
|
@@ -54,9 +54,9 @@ export interface TransportDisableWebUSB {
|
|
|
54
54
|
type: typeof TRANSPORT.DISABLE_WEBUSB;
|
|
55
55
|
payload?: undefined;
|
|
56
56
|
}
|
|
57
|
-
export
|
|
57
|
+
export type TransportEventMessage = TransportEvent & {
|
|
58
58
|
event: typeof TRANSPORT_EVENT;
|
|
59
59
|
};
|
|
60
|
-
export
|
|
60
|
+
export type TransportEventListenerFn = (type: typeof TRANSPORT_EVENT, cb: (event: TransportEventMessage) => void) => void;
|
|
61
61
|
export declare const createTransportMessage: MessageFactoryFn<typeof TRANSPORT_EVENT, TransportEvent>;
|
|
62
62
|
//# sourceMappingURL=transport.d.ts.map
|
|
@@ -2,11 +2,11 @@ import type { DEVICE } from './device';
|
|
|
2
2
|
import type { Device } from '../device/Device';
|
|
3
3
|
import type { UiResponseEvent } from './ui-response';
|
|
4
4
|
import type { Deferred } from '../utils/deferred';
|
|
5
|
-
export
|
|
5
|
+
export type UiPromiseResponse = UiResponseEvent | {
|
|
6
6
|
type: typeof DEVICE.DISCONNECT;
|
|
7
7
|
payload?: undefined;
|
|
8
8
|
};
|
|
9
|
-
export
|
|
9
|
+
export type UiPromise<T extends UiPromiseResponse['type']> = Deferred<Extract<UiPromiseResponse, {
|
|
10
10
|
type: T;
|
|
11
11
|
}>, T, Device>;
|
|
12
12
|
//# sourceMappingURL=ui-promise.d.ts.map
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { EventTypeDeviceSelected } from '@trezor/connect-analytics';
|
|
1
2
|
import type { PROTO } from '../constants';
|
|
2
3
|
import type { TransportDisableWebUSB } from './transport';
|
|
3
4
|
import type { Device, CoinInfo, BitcoinNetworkInfo } from '../types';
|
|
@@ -43,7 +44,7 @@ export declare const UI_REQUEST: {
|
|
|
43
44
|
readonly ADDRESS_VALIDATION: "ui-address_validation";
|
|
44
45
|
readonly IFRAME_FAILURE: "ui-iframe_failure";
|
|
45
46
|
};
|
|
46
|
-
export
|
|
47
|
+
export type UiRequestWithoutPayload = {
|
|
47
48
|
type: typeof UI_REQUEST.LOADING;
|
|
48
49
|
payload?: typeof undefined;
|
|
49
50
|
} | {
|
|
@@ -65,7 +66,7 @@ export declare type UiRequestWithoutPayload = {
|
|
|
65
66
|
type: typeof UI_REQUEST.LOGIN_CHALLENGE_REQUEST;
|
|
66
67
|
payload?: typeof undefined;
|
|
67
68
|
};
|
|
68
|
-
export
|
|
69
|
+
export type UiRequestDeviceAction = {
|
|
69
70
|
type: typeof UI_REQUEST.REQUEST_PIN;
|
|
70
71
|
payload: {
|
|
71
72
|
device: Device;
|
|
@@ -141,6 +142,7 @@ export interface UiRequestConfirmation {
|
|
|
141
142
|
className: string;
|
|
142
143
|
label: string;
|
|
143
144
|
};
|
|
145
|
+
analytics?: EventTypeDeviceSelected;
|
|
144
146
|
};
|
|
145
147
|
}
|
|
146
148
|
export interface UiRequestSelectDevice {
|
|
@@ -198,11 +200,11 @@ export interface FirmwareProgress {
|
|
|
198
200
|
progress: number;
|
|
199
201
|
};
|
|
200
202
|
}
|
|
201
|
-
export
|
|
202
|
-
export
|
|
203
|
+
export type UiEvent = UiRequestWithoutPayload | UiRequestDeviceAction | UiRequestButton | UiRequestPermission | UiRequestConfirmation | UiRequestSelectDevice | UiRequestUnexpectedDeviceMode | UiRequestSelectAccount | UiRequestSelectFee | UpdateCustomFee | BundleProgress<any> | FirmwareProgress | FirmwareException | UiRequestAddressValidation | UiRequestSetOperation | TransportDisableWebUSB;
|
|
204
|
+
export type UiEventMessage = UiEvent & {
|
|
203
205
|
event: typeof UI_EVENT;
|
|
204
206
|
};
|
|
205
|
-
export
|
|
206
|
-
export
|
|
207
|
+
export type ProgressEventListenerFn = <R>(type: typeof UI_REQUEST.BUNDLE_PROGRESS, cb: (event: BundleProgress<R>['payload']) => void) => void;
|
|
208
|
+
export type UiEventListenerFn = (type: typeof UI_EVENT, cb: (event: UiEventMessage) => void) => void;
|
|
207
209
|
export declare const createUiMessage: MessageFactoryFn<typeof UI_EVENT, UiEvent>;
|
|
208
210
|
//# sourceMappingURL=ui-request.d.ts.map
|
|
@@ -80,8 +80,8 @@ export interface UiResponseLoginChallenge {
|
|
|
80
80
|
challengeVisual: string;
|
|
81
81
|
};
|
|
82
82
|
}
|
|
83
|
-
export
|
|
84
|
-
export
|
|
83
|
+
export type UiResponseEvent = UiResponsePopupHandshake | UiResponsePermission | UiResponseConfirmation | UiResponseDevice | UiResponsePin | UiResponseWord | UiResponsePassphrase | UiResponsePassphraseAction | UiResponseAccount | UiResponseFee | UiResponseLoginChallenge;
|
|
84
|
+
export type UiResponseMessage = UiResponseEvent & {
|
|
85
85
|
event: typeof UI_EVENT;
|
|
86
86
|
};
|
|
87
87
|
export declare const createUiResponse: MessageFactoryFn<typeof UI_EVENT, UiResponseEvent>;
|
package/lib/types/account.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AccountInfo as AccountInfoBase, AccountAddresses, Utxo as AccountUtxo } from '@trezor/blockchain-link';
|
|
2
2
|
export type { AccountAddresses, Utxo as AccountUtxo, Address as AccountAddress, } from '@trezor/blockchain-link';
|
|
3
|
-
export
|
|
3
|
+
export type DiscoveryAccountType = 'p2pkh' | 'p2sh' | 'p2tr' | 'p2wpkh';
|
|
4
4
|
export interface AccountInfo extends AccountInfoBase {
|
|
5
5
|
path?: string;
|
|
6
6
|
legacyXpub?: string;
|
|
@@ -22,7 +22,7 @@ export interface FeeLevel {
|
|
|
22
22
|
feeLimit?: string;
|
|
23
23
|
feePerTx?: string;
|
|
24
24
|
}
|
|
25
|
-
export
|
|
25
|
+
export type SelectFeeLevel = {
|
|
26
26
|
name: string;
|
|
27
27
|
fee: '0';
|
|
28
28
|
feePerByte?: undefined;
|
|
@@ -9,7 +9,7 @@ export interface BinanceSDKTransaction {
|
|
|
9
9
|
placeOrder?: PROTO.BinanceOrderMsg;
|
|
10
10
|
cancelOrder?: PROTO.BinanceCancelMsg;
|
|
11
11
|
}
|
|
12
|
-
export
|
|
12
|
+
export type BinancePreparedMessage = (PROTO.BinanceTransferMsg & {
|
|
13
13
|
type: 'BinanceTransferMsg';
|
|
14
14
|
}) | (PROTO.BinanceOrderMsg & {
|
|
15
15
|
type: 'BinanceOrderMsg';
|
|
@@ -7,7 +7,7 @@ export interface SignMessage {
|
|
|
7
7
|
hex?: boolean;
|
|
8
8
|
no_script_type?: boolean;
|
|
9
9
|
}
|
|
10
|
-
export
|
|
10
|
+
export type RefTransaction = {
|
|
11
11
|
hash: string;
|
|
12
12
|
version: number;
|
|
13
13
|
inputs: PROTO.PrevInput[];
|
|
@@ -71,7 +71,7 @@ export interface SignTransaction {
|
|
|
71
71
|
serialize?: boolean;
|
|
72
72
|
coinjoinRequest?: PROTO.CoinJoinRequest;
|
|
73
73
|
}
|
|
74
|
-
export
|
|
74
|
+
export type SignedTransaction = {
|
|
75
75
|
signatures: string[];
|
|
76
76
|
serializedTx: string;
|
|
77
77
|
witnesses?: (string | undefined)[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { TypedRawTransaction } from '@trezor/blockchain-link';
|
|
2
2
|
import type { CommonParamsWithCoin, Response } from '../params';
|
|
3
|
-
export
|
|
3
|
+
export type BlockchainGetTransactions = CommonParamsWithCoin & {
|
|
4
4
|
txs: string[];
|
|
5
5
|
};
|
|
6
6
|
export declare function blockchainGetTransactions(params: BlockchainGetTransactions): Response<TypedRawTransaction[]>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { CommonParamsWithCoin, Response } from '../params';
|
|
2
2
|
import type { BlockchainLink } from '../coinInfo';
|
|
3
|
-
export
|
|
3
|
+
export type BlockchainSetCustomBackend = CommonParamsWithCoin & {
|
|
4
4
|
blockchainLink?: BlockchainLink;
|
|
5
5
|
};
|
|
6
6
|
export declare function blockchainSetCustomBackend(params: BlockchainSetCustomBackend): Response<boolean>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { SubscriptionAccountInfo, BlockchainLinkResponse } from '@trezor/blockchain-link';
|
|
2
2
|
import type { CommonParamsWithCoin, Response } from '../params';
|
|
3
|
-
export
|
|
3
|
+
export type BlockchainSubscribe = CommonParamsWithCoin & {
|
|
4
4
|
accounts?: SubscriptionAccountInfo[];
|
|
5
5
|
};
|
|
6
6
|
export declare function blockchainSubscribe(params: BlockchainSubscribe): Response<BlockchainLinkResponse<'subscribe'>>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { BlockchainLinkResponse } from '@trezor/blockchain-link';
|
|
2
2
|
import type { CommonParamsWithCoin, Response } from '../params';
|
|
3
|
-
export
|
|
3
|
+
export type BlockchainSubscribeFiatRates = CommonParamsWithCoin & {
|
|
4
4
|
currency?: string;
|
|
5
5
|
};
|
|
6
6
|
export declare function blockchainSubscribeFiatRates(params: BlockchainSubscribeFiatRates): Response<BlockchainLinkResponse<'subscribe'>>;
|