@trezor/connect 9.4.8-beta.2 → 9.5.0
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 +59 -44
- package/README.md +1 -1
- package/lib/api/authorizeCoinjoin.js +1 -1
- package/lib/api/binance/api/binanceGetAddress.js +2 -4
- package/lib/api/binance/api/binanceGetPublicKey.js +1 -0
- package/lib/api/binance/api/binanceSignTransaction.js +1 -2
- package/lib/api/bitcoin/Fees.js +4 -1
- package/lib/api/bitcoin/TransactionComposer.js +9 -2
- package/lib/api/bitcoin/enhanceSignTx.js +1 -2
- package/lib/api/bitcoin/refTx.js +4 -6
- package/lib/api/blockchainDisconnect.js +1 -1
- package/lib/api/blockchainSubscribe.js +1 -2
- package/lib/api/blockchainUnsubscribe.js +1 -2
- package/lib/api/cardano/api/cardanoComposeTransaction.js +1 -1
- package/lib/api/cardano/api/cardanoGetAddress.js +2 -4
- package/lib/api/cardano/api/cardanoGetPublicKey.js +1 -0
- package/lib/api/cardano/cardanoAuxiliaryData.js +2 -2
- package/lib/api/cardano/cardanoUtils.js +5 -6
- package/lib/api/cipherKeyValue.js +1 -0
- package/lib/api/common/Discovery.js +16 -1
- package/lib/api/common/paramsValidator.js +2 -2
- package/lib/api/composeTransaction.js +6 -6
- package/lib/api/eos/api/eosGetPublicKey.js +1 -0
- package/lib/api/ethereum/api/ethereumGetAddress.js +2 -4
- package/lib/api/ethereum/api/ethereumGetPublicKey.js +1 -0
- package/lib/api/ethereum/api/ethereumSignMessage.js +1 -2
- package/lib/api/ethereum/api/ethereumSignTransaction.js +1 -1
- package/lib/api/ethereum/api/ethereumSignTypedData.js +1 -1
- package/lib/api/ethereum/ethereumDefinitions.js +2 -2
- package/lib/api/ethereum/ethereumSignTx.d.ts +2 -2
- package/lib/api/ethereum/ethereumSignTx.js +3 -2
- package/lib/api/firmware/verifyAuthenticityProof.js +3 -3
- package/lib/api/getAccountDescriptor.js +2 -4
- package/lib/api/getAccountInfo.js +4 -5
- package/lib/api/getAddress.js +5 -8
- package/lib/api/getDeviceState.js +1 -1
- package/lib/api/getOwnershipId.js +1 -0
- package/lib/api/getOwnershipProof.js +1 -0
- package/lib/api/getPublicKey.js +3 -2
- package/lib/api/nem/api/nemGetAddress.js +2 -4
- package/lib/api/nem/api/nemSignTransaction.js +1 -2
- package/lib/api/requestLogin.js +1 -0
- package/lib/api/ripple/api/rippleGetAddress.js +2 -4
- package/lib/api/signMessage.js +1 -2
- package/lib/api/signTransaction.js +6 -8
- package/lib/api/solana/additionalInfo.js +2 -3
- package/lib/api/solana/api/solanaComposeTransaction.js +2 -3
- package/lib/api/solana/api/solanaGetAddress.js +2 -4
- package/lib/api/solana/api/solanaGetPublicKey.js +1 -0
- package/lib/api/solana/solanaUtils.js +6 -5
- package/lib/api/stellar/api/stellarGetAddress.js +2 -4
- package/lib/api/tezos/api/tezosGetAddress.js +2 -4
- package/lib/api/tezos/api/tezosGetPublicKey.js +1 -0
- package/lib/backend/BackendManager.js +11 -16
- package/lib/backend/Blockchain.js +10 -4
- package/lib/backend/BlockchainLink.js +1 -1
- package/lib/constants/errors.js +2 -0
- package/lib/core/AbstractMethod.js +30 -5
- package/lib/core/index.js +24 -34
- package/lib/core/onCallFirmwareUpdate.d.ts +3 -2
- package/lib/core/onCallFirmwareUpdate.js +12 -59
- package/lib/data/DataManager.js +3 -2
- package/lib/data/analyticsInfo.js +10 -11
- package/lib/data/connectSettings.js +3 -2
- package/lib/data/defaultFeeLevels.js +4 -7
- package/lib/data/deviceAuthenticityConfig.js +16 -1
- package/lib/data/firmwareInfo.js +5 -6
- package/lib/data/version.d.ts +1 -1
- package/lib/data/version.js +1 -1
- package/lib/device/Device.d.ts +10 -2
- package/lib/device/Device.js +65 -56
- package/lib/device/DeviceCommands.d.ts +5 -1
- package/lib/device/DeviceCommands.js +7 -2
- package/lib/device/DeviceList.d.ts +2 -0
- package/lib/device/DeviceList.js +44 -24
- package/lib/device/StateStorage.js +5 -6
- package/lib/device/checkFirmwareRevision.js +11 -6
- package/lib/device/prompts.js +4 -7
- package/lib/events/call.d.ts +1 -0
- package/lib/events/call.js +3 -3
- package/lib/impl/core-in-module.js +25 -23
- package/lib/impl/dynamic.js +7 -1
- package/lib/index.js +9 -12
- package/lib/types/api/ethereum/index.d.ts +4 -4
- package/lib/types/api/ethereum/index.js +2 -2
- package/lib/types/api/firmwareUpdate.d.ts +1 -8
- package/lib/utils/assets.js +1 -1
- package/lib/utils/assets.native.js +1 -1
- package/lib/utils/hdnodeUtils.js +1 -2
- package/lib/utils/interactionTimeout.js +2 -2
- package/lib/utils/popupPromiseManager.js +2 -2
- package/lib/utils/proxy-event-emitter.js +1 -0
- package/lib/utils/uiPromiseManager.js +3 -4
- package/lib/utils/urlUtils.js +5 -8
- package/package.json +14 -14
- package/lib/utils/abortablePromise.d.ts +0 -5
- package/lib/utils/abortablePromise.js +0 -17
package/lib/events/call.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ type CallApi = {
|
|
|
21
21
|
};
|
|
22
22
|
export type CallMethodUnion = CallApi[keyof CallApi];
|
|
23
23
|
export type CallMethodPayload = Parameters<CallMethodUnion>[0];
|
|
24
|
+
export type CallMethodParams<M extends keyof CallApi> = Parameters<CallApi[M]>[0];
|
|
24
25
|
export type CallMethodResponse<M extends keyof CallApi> = UnwrappedResponse<ReturnType<CallApi[M]>>;
|
|
25
26
|
export type CallMethodAnyResponse = ReturnType<CallMethodUnion>;
|
|
26
27
|
export type CallMethod = (params: CallMethodPayload) => Promise<any>;
|
package/lib/events/call.js
CHANGED
|
@@ -11,9 +11,9 @@ const createResponseMessage = (id, success, payload, device) => ({
|
|
|
11
11
|
payload: success ? payload : (0, errors_1.serializeError)(payload),
|
|
12
12
|
device: device
|
|
13
13
|
? {
|
|
14
|
-
path: device
|
|
15
|
-
state: device
|
|
16
|
-
instance: device
|
|
14
|
+
path: device?.getUniquePath(),
|
|
15
|
+
state: device?.getState(),
|
|
16
|
+
instance: device?.getInstance(),
|
|
17
17
|
}
|
|
18
18
|
: undefined,
|
|
19
19
|
});
|
|
@@ -10,23 +10,14 @@ const events_2 = require("../events");
|
|
|
10
10
|
const factory_1 = require("../factory");
|
|
11
11
|
const debug_1 = require("../utils/debug");
|
|
12
12
|
class CoreInModule {
|
|
13
|
+
eventEmitter = new events_1.default();
|
|
14
|
+
_settings;
|
|
15
|
+
_coreManager;
|
|
16
|
+
_log;
|
|
17
|
+
_messagePromises;
|
|
18
|
+
boundOnCoreEvent = this.onCoreEvent.bind(this);
|
|
19
|
+
onCoreHook;
|
|
13
20
|
constructor(onCoreHook) {
|
|
14
|
-
this.eventEmitter = new events_1.default();
|
|
15
|
-
this.boundOnCoreEvent = this.onCoreEvent.bind(this);
|
|
16
|
-
this.initSettings = (settings = {}) => {
|
|
17
|
-
var _a;
|
|
18
|
-
this._settings = (0, connectSettings_1.parseConnectSettings)({
|
|
19
|
-
...this._settings,
|
|
20
|
-
...settings,
|
|
21
|
-
popup: false,
|
|
22
|
-
});
|
|
23
|
-
if (!this._settings.manifest) {
|
|
24
|
-
throw ERRORS.TypedError('Init_ManifestMissing');
|
|
25
|
-
}
|
|
26
|
-
if (!((_a = this._settings.transports) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
27
|
-
this._settings.transports = ['BridgeTransport'];
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
21
|
this._settings = (0, connectSettings_1.parseConnectSettings)();
|
|
31
22
|
this._log = (0, debug_1.initLog)('@trezor/connect-web');
|
|
32
23
|
this._messagePromises = (0, utils_1.createDeferredManager)({ initialId: 1 });
|
|
@@ -80,14 +71,13 @@ class CoreInModule {
|
|
|
80
71
|
core.handleMessage(message);
|
|
81
72
|
}
|
|
82
73
|
onCoreEvent(rawMessage) {
|
|
83
|
-
var _a;
|
|
84
74
|
let message = (0, utils_1.cloneObject)(rawMessage);
|
|
85
75
|
if (this.onCoreHook) {
|
|
86
76
|
message = this.onCoreHook(message);
|
|
87
77
|
}
|
|
88
78
|
const { event, type, payload } = message;
|
|
89
79
|
if (type === events_2.UI.REQUEST_UI_WINDOW) {
|
|
90
|
-
|
|
80
|
+
this._coreManager.get()?.handleMessage({ type: events_2.POPUP.HANDSHAKE });
|
|
91
81
|
return;
|
|
92
82
|
}
|
|
93
83
|
if (type === events_2.POPUP.CANCEL_POPUP_REQUEST)
|
|
@@ -126,7 +116,6 @@ class CoreInModule {
|
|
|
126
116
|
}
|
|
127
117
|
}
|
|
128
118
|
async init(settings = {}) {
|
|
129
|
-
var _a;
|
|
130
119
|
if (this._coreManager && (this._coreManager.get() || this._coreManager.getPending())) {
|
|
131
120
|
throw ERRORS.TypedError('Init_AlreadyInitialized');
|
|
132
121
|
}
|
|
@@ -135,7 +124,7 @@ class CoreInModule {
|
|
|
135
124
|
throw ERRORS.TypedError('Init_ManifestMissing');
|
|
136
125
|
}
|
|
137
126
|
this._settings.lazyLoad = true;
|
|
138
|
-
if (!
|
|
127
|
+
if (!this._settings.transports?.length) {
|
|
139
128
|
this._settings.transports = ['BridgeTransport', 'WebUsbTransport'];
|
|
140
129
|
}
|
|
141
130
|
if (!this._coreManager) {
|
|
@@ -151,6 +140,19 @@ class CoreInModule {
|
|
|
151
140
|
payload: { transports },
|
|
152
141
|
});
|
|
153
142
|
}
|
|
143
|
+
initSettings = (settings = {}) => {
|
|
144
|
+
this._settings = (0, connectSettings_1.parseConnectSettings)({
|
|
145
|
+
...this._settings,
|
|
146
|
+
...settings,
|
|
147
|
+
popup: false,
|
|
148
|
+
});
|
|
149
|
+
if (!this._settings.manifest) {
|
|
150
|
+
throw ERRORS.TypedError('Init_ManifestMissing');
|
|
151
|
+
}
|
|
152
|
+
if (!this._settings.transports?.length) {
|
|
153
|
+
this._settings.transports = ['BridgeTransport'];
|
|
154
|
+
}
|
|
155
|
+
};
|
|
154
156
|
initCore() {
|
|
155
157
|
this.initSettings({ lazyLoad: false });
|
|
156
158
|
return this._coreManager.getOrInit(this._settings, this.boundOnCoreEvent);
|
|
@@ -165,7 +167,7 @@ class CoreInModule {
|
|
|
165
167
|
payload,
|
|
166
168
|
});
|
|
167
169
|
const response = (0, utils_1.cloneObject)(await promise);
|
|
168
|
-
return response
|
|
170
|
+
return response ?? (0, events_2.createErrorMessage)(ERRORS.TypedError('Method_NoResponse'));
|
|
169
171
|
}
|
|
170
172
|
catch (error) {
|
|
171
173
|
this._log.error('call', error);
|
|
@@ -201,14 +203,14 @@ class CoreInModule {
|
|
|
201
203
|
}
|
|
202
204
|
}
|
|
203
205
|
};
|
|
204
|
-
core
|
|
206
|
+
core?.on(events_2.CORE_EVENT, loginChallengeListener);
|
|
205
207
|
const response = await this.call({
|
|
206
208
|
method: 'requestLogin',
|
|
207
209
|
...params,
|
|
208
210
|
asyncChallenge: true,
|
|
209
211
|
callback: null,
|
|
210
212
|
});
|
|
211
|
-
core
|
|
213
|
+
core?.removeListener(events_2.CORE_EVENT, loginChallengeListener);
|
|
212
214
|
return response;
|
|
213
215
|
}
|
|
214
216
|
return this.call({ method: 'requestLogin', ...params });
|
package/lib/impl/dynamic.js
CHANGED
|
@@ -4,6 +4,12 @@ exports.TrezorConnectDynamic = void 0;
|
|
|
4
4
|
const constants_1 = require("../constants");
|
|
5
5
|
const proxy_event_emitter_1 = require("../utils/proxy-event-emitter");
|
|
6
6
|
class TrezorConnectDynamic {
|
|
7
|
+
eventEmitter;
|
|
8
|
+
currentTarget;
|
|
9
|
+
implementations;
|
|
10
|
+
getInitTarget;
|
|
11
|
+
handleErrorFallback;
|
|
12
|
+
lastSettings;
|
|
7
13
|
constructor({ implementations, getInitTarget, handleErrorFallback, }) {
|
|
8
14
|
this.implementations = implementations;
|
|
9
15
|
this.currentTarget = this.implementations[0].type;
|
|
@@ -30,7 +36,7 @@ class TrezorConnectDynamic {
|
|
|
30
36
|
this.getTarget().manifest(manifest);
|
|
31
37
|
}
|
|
32
38
|
async init(settings) {
|
|
33
|
-
if (!
|
|
39
|
+
if (!settings?.manifest) {
|
|
34
40
|
throw constants_1.ERRORS.TypedError('Init_ManifestMissing');
|
|
35
41
|
}
|
|
36
42
|
this.lastSettings = settings;
|
package/lib/index.js
CHANGED
|
@@ -27,15 +27,14 @@ const dispose = () => {
|
|
|
27
27
|
coreManager.dispose();
|
|
28
28
|
};
|
|
29
29
|
const onCoreEvent = (message) => {
|
|
30
|
-
var _a;
|
|
31
30
|
const { event, type, payload } = message;
|
|
32
31
|
if (type === events_2.UI.REQUEST_UI_WINDOW) {
|
|
33
|
-
|
|
32
|
+
coreManager.get()?.handleMessage({ type: events_2.POPUP.HANDSHAKE });
|
|
34
33
|
return;
|
|
35
34
|
}
|
|
36
35
|
if (type === events_2.POPUP.CANCEL_POPUP_REQUEST)
|
|
37
36
|
return;
|
|
38
|
-
_log.debug('handleMessage', message);
|
|
37
|
+
_log.debug('handleMessage', message.type);
|
|
39
38
|
switch (event) {
|
|
40
39
|
case events_2.RESPONSE_EVENT: {
|
|
41
40
|
const { id = 0, success, device } = message;
|
|
@@ -65,12 +64,11 @@ const onCoreEvent = (message) => {
|
|
|
65
64
|
}
|
|
66
65
|
};
|
|
67
66
|
const initSettings = (settings = {}) => {
|
|
68
|
-
var _a;
|
|
69
67
|
_settings = (0, connectSettings_1.parseConnectSettings)({ ..._settings, ...settings, popup: false });
|
|
70
68
|
if (!_settings.manifest) {
|
|
71
69
|
throw constants_1.ERRORS.TypedError('Init_ManifestMissing');
|
|
72
70
|
}
|
|
73
|
-
if (!
|
|
71
|
+
if (!_settings.transports?.length) {
|
|
74
72
|
_settings.transports = ['BridgeTransport'];
|
|
75
73
|
}
|
|
76
74
|
};
|
|
@@ -88,10 +86,9 @@ const initCore = () => {
|
|
|
88
86
|
return coreManager.getOrInit(_settings, onCoreEvent);
|
|
89
87
|
};
|
|
90
88
|
const call = async (params) => {
|
|
91
|
-
var _a, _b;
|
|
92
89
|
let core;
|
|
93
90
|
try {
|
|
94
|
-
core =
|
|
91
|
+
core = coreManager.get() ?? (await coreManager.getPending()) ?? (await initCore());
|
|
95
92
|
}
|
|
96
93
|
catch (error) {
|
|
97
94
|
return (0, events_2.createErrorMessage)(error);
|
|
@@ -104,7 +101,7 @@ const call = async (params) => {
|
|
|
104
101
|
id: promiseId,
|
|
105
102
|
});
|
|
106
103
|
const response = await promise;
|
|
107
|
-
return response
|
|
104
|
+
return response ?? (0, events_2.createErrorMessage)(constants_1.ERRORS.TypedError('Method_NoResponse'));
|
|
108
105
|
}
|
|
109
106
|
catch (error) {
|
|
110
107
|
_log.error('call', error);
|
|
@@ -134,27 +131,27 @@ const requestLogin = async (params) => {
|
|
|
134
131
|
if (data && data.type === events_2.UI.LOGIN_CHALLENGE_REQUEST) {
|
|
135
132
|
try {
|
|
136
133
|
const payload = await callback();
|
|
137
|
-
core
|
|
134
|
+
core?.handleMessage({
|
|
138
135
|
type: events_2.UI.LOGIN_CHALLENGE_RESPONSE,
|
|
139
136
|
payload,
|
|
140
137
|
});
|
|
141
138
|
}
|
|
142
139
|
catch (error) {
|
|
143
|
-
core
|
|
140
|
+
core?.handleMessage({
|
|
144
141
|
type: events_2.UI.LOGIN_CHALLENGE_RESPONSE,
|
|
145
142
|
payload: error.message,
|
|
146
143
|
});
|
|
147
144
|
}
|
|
148
145
|
}
|
|
149
146
|
};
|
|
150
|
-
core
|
|
147
|
+
core?.on(events_2.CORE_EVENT, loginChallengeListener);
|
|
151
148
|
const response = await call({
|
|
152
149
|
method: 'requestLogin',
|
|
153
150
|
...params,
|
|
154
151
|
asyncChallenge: true,
|
|
155
152
|
callback: null,
|
|
156
153
|
});
|
|
157
|
-
core
|
|
154
|
+
core?.removeListener(events_2.CORE_EVENT, loginChallengeListener);
|
|
158
155
|
return response;
|
|
159
156
|
}
|
|
160
157
|
return call({ method: 'requestLogin', ...params });
|
|
@@ -8,7 +8,7 @@ export declare const EthereumSignMessage: import("@trezor/schema-utils").TObject
|
|
|
8
8
|
}>;
|
|
9
9
|
export type EthereumTransaction = Static<typeof EthereumTransaction>;
|
|
10
10
|
export declare const EthereumTransaction: import("@trezor/schema-utils").TObject<{
|
|
11
|
-
to: import("@trezor/schema-utils").TString
|
|
11
|
+
to: import("@trezor/schema-utils").TUnion<[import("@trezor/schema-utils").TString, import("@trezor/schema-utils").TNull]>;
|
|
12
12
|
value: import("@trezor/schema-utils").TString;
|
|
13
13
|
gasPrice: import("@trezor/schema-utils").TString;
|
|
14
14
|
gasLimit: import("@trezor/schema-utils").TString;
|
|
@@ -26,7 +26,7 @@ export declare const EthereumAccessList: import("@trezor/schema-utils").TObject<
|
|
|
26
26
|
}>;
|
|
27
27
|
export type EthereumTransactionEIP1559 = Static<typeof EthereumTransactionEIP1559>;
|
|
28
28
|
export declare const EthereumTransactionEIP1559: import("@trezor/schema-utils").TObject<{
|
|
29
|
-
to: import("@trezor/schema-utils").TString
|
|
29
|
+
to: import("@trezor/schema-utils").TUnion<[import("@trezor/schema-utils").TString, import("@trezor/schema-utils").TNull]>;
|
|
30
30
|
value: import("@trezor/schema-utils").TString;
|
|
31
31
|
gasLimit: import("@trezor/schema-utils").TString;
|
|
32
32
|
gasPrice: import("@trezor/schema-utils").TOptional<import("@trezor/schema-utils").TUndefined>;
|
|
@@ -44,7 +44,7 @@ export type EthereumSignTransaction = Static<typeof EthereumSignTransaction>;
|
|
|
44
44
|
export declare const EthereumSignTransaction: import("@trezor/schema-utils").TObject<{
|
|
45
45
|
path: import("@trezor/schema-utils").TUnion<[import("@trezor/schema-utils").TString, import("@trezor/schema-utils").TArray<import("@trezor/schema-utils").TNumber>]>;
|
|
46
46
|
transaction: import("@trezor/schema-utils").TUnion<[import("@trezor/schema-utils").TObject<{
|
|
47
|
-
to: import("@trezor/schema-utils").TString
|
|
47
|
+
to: import("@trezor/schema-utils").TUnion<[import("@trezor/schema-utils").TString, import("@trezor/schema-utils").TNull]>;
|
|
48
48
|
value: import("@trezor/schema-utils").TString;
|
|
49
49
|
gasPrice: import("@trezor/schema-utils").TString;
|
|
50
50
|
gasLimit: import("@trezor/schema-utils").TString;
|
|
@@ -55,7 +55,7 @@ export declare const EthereumSignTransaction: import("@trezor/schema-utils").TOb
|
|
|
55
55
|
chainId: import("@trezor/schema-utils").TNumber;
|
|
56
56
|
txType: import("@trezor/schema-utils").TOptional<import("@trezor/schema-utils").TNumber>;
|
|
57
57
|
}>, import("@trezor/schema-utils").TObject<{
|
|
58
|
-
to: import("@trezor/schema-utils").TString
|
|
58
|
+
to: import("@trezor/schema-utils").TUnion<[import("@trezor/schema-utils").TString, import("@trezor/schema-utils").TNull]>;
|
|
59
59
|
value: import("@trezor/schema-utils").TString;
|
|
60
60
|
gasLimit: import("@trezor/schema-utils").TString;
|
|
61
61
|
gasPrice: import("@trezor/schema-utils").TOptional<import("@trezor/schema-utils").TUndefined>;
|
|
@@ -9,7 +9,7 @@ exports.EthereumSignMessage = schema_utils_1.Type.Object({
|
|
|
9
9
|
hex: schema_utils_1.Type.Optional(schema_utils_1.Type.Boolean()),
|
|
10
10
|
});
|
|
11
11
|
exports.EthereumTransaction = schema_utils_1.Type.Object({
|
|
12
|
-
to: schema_utils_1.Type.String(),
|
|
12
|
+
to: schema_utils_1.Type.Union([schema_utils_1.Type.String(), schema_utils_1.Type.Null()]),
|
|
13
13
|
value: schema_utils_1.Type.String(),
|
|
14
14
|
gasPrice: schema_utils_1.Type.String(),
|
|
15
15
|
gasLimit: schema_utils_1.Type.String(),
|
|
@@ -25,7 +25,7 @@ exports.EthereumAccessList = schema_utils_1.Type.Object({
|
|
|
25
25
|
storageKeys: schema_utils_1.Type.Array(schema_utils_1.Type.String()),
|
|
26
26
|
});
|
|
27
27
|
exports.EthereumTransactionEIP1559 = schema_utils_1.Type.Object({
|
|
28
|
-
to: schema_utils_1.Type.String(),
|
|
28
|
+
to: schema_utils_1.Type.Union([schema_utils_1.Type.String(), schema_utils_1.Type.Null()]),
|
|
29
29
|
value: schema_utils_1.Type.String(),
|
|
30
30
|
gasLimit: schema_utils_1.Type.String(),
|
|
31
31
|
gasPrice: schema_utils_1.Type.Optional(schema_utils_1.Type.Undefined()),
|
|
@@ -10,19 +10,12 @@ export declare const FirmwareUpdate: import("@trezor/schema-utils").TUnion<[impo
|
|
|
10
10
|
}>, import("@trezor/schema-utils").TObject<{
|
|
11
11
|
binary: import("@trezor/schema-utils/lib/custom-types/array-buffer").TArrayBuffer;
|
|
12
12
|
}>]>;
|
|
13
|
-
type
|
|
13
|
+
export type FirmwareUpdateResponse = {
|
|
14
14
|
versionCheck: boolean;
|
|
15
15
|
bootloaderVersion: VersionArray;
|
|
16
16
|
installedVersion: VersionArray;
|
|
17
17
|
binaryVersion: VersionArray;
|
|
18
18
|
releaseVersion?: VersionArray;
|
|
19
19
|
};
|
|
20
|
-
export type FirmwareUpdateResponse = FirmwareUpdateDetails & ({
|
|
21
|
-
check: 'mismatch' | 'valid' | 'omitted';
|
|
22
|
-
} | {
|
|
23
|
-
check: 'other-error';
|
|
24
|
-
checkError: string;
|
|
25
|
-
});
|
|
26
20
|
export declare function firmwareUpdate(params: Params<FirmwareUpdate>): Response<FirmwareUpdateResponse>;
|
|
27
|
-
export {};
|
|
28
21
|
//# sourceMappingURL=firmwareUpdate.d.ts.map
|
package/lib/utils/assets.js
CHANGED
|
@@ -10,7 +10,7 @@ if (global && typeof global.fetch !== 'function') {
|
|
|
10
10
|
global.fetch = cross_fetch_1.default;
|
|
11
11
|
}
|
|
12
12
|
function httpRequest(url, type, options) {
|
|
13
|
-
const asset =
|
|
13
|
+
const asset = options?.skipLocalForceDownload ? null : (0, assetUtils_1.tryLocalAssetRequire)(url);
|
|
14
14
|
if (!asset) {
|
|
15
15
|
return /^https?/.test(url)
|
|
16
16
|
? (0, assets_browser_1.httpRequest)(url, type, options)
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.httpRequest = httpRequest;
|
|
4
4
|
const assetUtils_1 = require("./assetUtils");
|
|
5
5
|
function httpRequest(url, type, options) {
|
|
6
|
-
const asset =
|
|
6
|
+
const asset = options?.skipLocalForceDownload ? null : (0, assetUtils_1.tryLocalAssetRequire)(url);
|
|
7
7
|
if (!asset) {
|
|
8
8
|
return fetch(url, {
|
|
9
9
|
...options,
|
package/lib/utils/hdnodeUtils.js
CHANGED
|
@@ -66,8 +66,7 @@ const xpubToHDNodeType = (xpub, network) => {
|
|
|
66
66
|
};
|
|
67
67
|
exports.xpubToHDNodeType = xpubToHDNodeType;
|
|
68
68
|
const convertMultisigPubKey = (network, utxo) => {
|
|
69
|
-
|
|
70
|
-
if ('multisig' in utxo && ((_a = utxo.multisig) === null || _a === void 0 ? void 0 : _a.pubkeys)) {
|
|
69
|
+
if ('multisig' in utxo && utxo.multisig?.pubkeys) {
|
|
71
70
|
utxo.multisig.pubkeys.forEach(pk => {
|
|
72
71
|
if (typeof pk.node === 'string') {
|
|
73
72
|
pk.node = (0, exports.xpubToHDNodeType)(pk.node, network);
|
|
@@ -4,9 +4,9 @@ exports.InteractionTimeout = void 0;
|
|
|
4
4
|
const debug_1 = require("./debug");
|
|
5
5
|
const _log = (0, debug_1.initLog)('InteractionTimeout');
|
|
6
6
|
class InteractionTimeout {
|
|
7
|
+
timeout = null;
|
|
8
|
+
seconds = 0;
|
|
7
9
|
constructor(seconds) {
|
|
8
|
-
this.timeout = null;
|
|
9
|
-
this.seconds = 0;
|
|
10
10
|
if (seconds) {
|
|
11
11
|
this.seconds = seconds;
|
|
12
12
|
}
|
|
@@ -4,12 +4,12 @@ exports.createPopupPromiseManager = void 0;
|
|
|
4
4
|
const utils_1 = require("@trezor/utils");
|
|
5
5
|
const createPopupPromiseManager = () => {
|
|
6
6
|
let _popupPromise;
|
|
7
|
-
const ensure = () => _popupPromise
|
|
7
|
+
const ensure = () => _popupPromise ?? (_popupPromise = (0, utils_1.createDeferred)());
|
|
8
8
|
const wait = () => ensure().promise;
|
|
9
9
|
const resolve = () => ensure().resolve();
|
|
10
10
|
const isWaiting = () => !!_popupPromise;
|
|
11
11
|
const reject = (error) => {
|
|
12
|
-
_popupPromise
|
|
12
|
+
_popupPromise?.reject(error);
|
|
13
13
|
_popupPromise = undefined;
|
|
14
14
|
};
|
|
15
15
|
const clear = () => {
|
|
@@ -28,15 +28,14 @@ const createUiPromiseManager = (interactionTimeout) => {
|
|
|
28
28
|
_uiPromises = [];
|
|
29
29
|
};
|
|
30
30
|
const disconnected = (devicePath) => {
|
|
31
|
-
const [toResolve, toKeep] = (0, utils_1.arrayPartition)(_uiPromises, (p) =>
|
|
31
|
+
const [toResolve, toKeep] = (0, utils_1.arrayPartition)(_uiPromises, (p) => p.device?.getUniquePath() === devicePath && p.id === events_1.DEVICE.DISCONNECT);
|
|
32
32
|
toResolve.forEach(p => p.resolve({ type: events_1.DEVICE.DISCONNECT }));
|
|
33
33
|
_uiPromises = toKeep;
|
|
34
|
-
return !!toResolve.length || toKeep.some(p =>
|
|
34
|
+
return !!toResolve.length || toKeep.some(p => p.device?.getUniquePath() === devicePath);
|
|
35
35
|
};
|
|
36
36
|
const get = (type) => {
|
|
37
|
-
var _a;
|
|
38
37
|
const uiPromise = _uiPromises.find(p => p.id === type);
|
|
39
|
-
return
|
|
38
|
+
return uiPromise?.promise ?? Promise.reject(new Error(`UiPromise ${type} doesn't exist`));
|
|
40
39
|
};
|
|
41
40
|
const clear = () => {
|
|
42
41
|
_uiPromises = [];
|
package/lib/utils/urlUtils.js
CHANGED
|
@@ -3,20 +3,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getOnionDomain = exports.getHost = exports.getOrigin = void 0;
|
|
4
4
|
const utils_1 = require("@trezor/utils");
|
|
5
5
|
const getOrigin = (url) => {
|
|
6
|
-
var _a;
|
|
7
6
|
if (typeof url !== 'string')
|
|
8
7
|
return 'unknown';
|
|
9
8
|
if (url.indexOf('file://') === 0)
|
|
10
9
|
return 'file://';
|
|
11
|
-
const [origin] =
|
|
12
|
-
return origin
|
|
10
|
+
const [origin] = url.match(/^https?:\/\/[^/]+/) ?? [];
|
|
11
|
+
return origin ?? 'unknown';
|
|
13
12
|
};
|
|
14
13
|
exports.getOrigin = getOrigin;
|
|
15
14
|
const getHost = (url) => {
|
|
16
|
-
var _a;
|
|
17
15
|
if (typeof url !== 'string')
|
|
18
16
|
return;
|
|
19
|
-
const [, , uri] =
|
|
17
|
+
const [, , uri] = url.match(/^(https?):\/\/([^:/]+)?/i) ?? [];
|
|
20
18
|
if (uri) {
|
|
21
19
|
const parts = uri.split('.');
|
|
22
20
|
if (parts[parts.length - 1] === 'localhost')
|
|
@@ -29,11 +27,10 @@ const getHost = (url) => {
|
|
|
29
27
|
};
|
|
30
28
|
exports.getHost = getHost;
|
|
31
29
|
const getOnionDomain = (url, dict) => {
|
|
32
|
-
var _a;
|
|
33
30
|
if (Array.isArray(url))
|
|
34
|
-
return url.map(u =>
|
|
31
|
+
return url.map(u => (0, utils_1.urlToOnion)(u, dict) ?? u);
|
|
35
32
|
if (typeof url === 'string')
|
|
36
|
-
return (
|
|
33
|
+
return (0, utils_1.urlToOnion)(url, dict) ?? url;
|
|
37
34
|
return url;
|
|
38
35
|
};
|
|
39
36
|
exports.getOnionDomain = getOnionDomain;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trezor/connect",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.5.0",
|
|
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.",
|
|
@@ -78,20 +78,20 @@
|
|
|
78
78
|
"@solana-program/compute-budget": "^0.6.1",
|
|
79
79
|
"@solana-program/system": "^0.6.2",
|
|
80
80
|
"@solana-program/token": "^0.4.1",
|
|
81
|
-
"@solana-program/token-2022": "^0.3.
|
|
81
|
+
"@solana-program/token-2022": "^0.3.4",
|
|
82
82
|
"@solana/web3.js": "^2.0.0",
|
|
83
|
-
"@trezor/blockchain-link": "2.
|
|
84
|
-
"@trezor/blockchain-link-types": "1.
|
|
85
|
-
"@trezor/blockchain-link-utils": "1.
|
|
86
|
-
"@trezor/connect-analytics": "1.
|
|
87
|
-
"@trezor/connect-common": "0.
|
|
88
|
-
"@trezor/crypto-utils": "1.
|
|
89
|
-
"@trezor/protobuf": "1.
|
|
83
|
+
"@trezor/blockchain-link": "2.4.0",
|
|
84
|
+
"@trezor/blockchain-link-types": "1.3.0",
|
|
85
|
+
"@trezor/blockchain-link-utils": "1.3.0",
|
|
86
|
+
"@trezor/connect-analytics": "1.3.0",
|
|
87
|
+
"@trezor/connect-common": "0.3.0",
|
|
88
|
+
"@trezor/crypto-utils": "1.1.0",
|
|
89
|
+
"@trezor/protobuf": "1.3.0",
|
|
90
90
|
"@trezor/protocol": "1.2.2",
|
|
91
|
-
"@trezor/schema-utils": "1.
|
|
92
|
-
"@trezor/transport": "1.
|
|
93
|
-
"@trezor/utils": "9.
|
|
94
|
-
"@trezor/utxo-lib": "2.
|
|
91
|
+
"@trezor/schema-utils": "1.3.0",
|
|
92
|
+
"@trezor/transport": "1.4.0",
|
|
93
|
+
"@trezor/utils": "9.3.0",
|
|
94
|
+
"@trezor/utxo-lib": "2.3.0",
|
|
95
95
|
"blakejs": "^1.2.1",
|
|
96
96
|
"bs58": "^6.0.0",
|
|
97
97
|
"bs58check": "^4.0.0",
|
|
@@ -115,7 +115,7 @@
|
|
|
115
115
|
"ts-node": "^10.9.1",
|
|
116
116
|
"tsx": "^4.16.3",
|
|
117
117
|
"web3-utils": "^4.3.2",
|
|
118
|
-
"webpack": "^5.
|
|
118
|
+
"webpack": "^5.97.1",
|
|
119
119
|
"ws": "^8.18.0"
|
|
120
120
|
},
|
|
121
121
|
"peerDependencies": {
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.abortablePromise = void 0;
|
|
4
|
-
const utils_1 = require("@trezor/utils");
|
|
5
|
-
const abortablePromise = (signal) => {
|
|
6
|
-
const { promise, reject, resolve } = (0, utils_1.createDeferred)();
|
|
7
|
-
const onAbort = () => reject(signal.reason);
|
|
8
|
-
signal.addEventListener('abort', onAbort);
|
|
9
|
-
if (signal.aborted)
|
|
10
|
-
onAbort();
|
|
11
|
-
return {
|
|
12
|
-
promise: promise.finally(() => signal.removeEventListener('abort', onAbort)),
|
|
13
|
-
resolve,
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
exports.abortablePromise = abortablePromise;
|
|
17
|
-
//# sourceMappingURL=abortablePromise.js.map
|