@trezor/connect 9.0.0-beta.7 → 9.0.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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @trezor/connect
2
2
 
3
- API version 9.0.0-beta.7
3
+ API version 9.0.0
4
4
 
5
5
  [![Build Status](https://github.com/trezor/trezor-suite/actions/workflows/connect-test.yml/badge.svg)](https://github.com/trezor/trezor-suite/actions/workflows/connect-test.yml)
6
6
  [![NPM](https://img.shields.io/npm/v/@trezor/connect.svg)](https://www.npmjs.org/package/@trezor/connect)
@@ -23,7 +23,6 @@ export { default as cardanoSignTransaction } from './cardanoSignTransaction';
23
23
  export { default as changePin } from './changePin';
24
24
  export { default as cipherKeyValue } from './cipherKeyValue';
25
25
  export { default as composeTransaction } from './composeTransaction';
26
- export { default as customMessage } from './customMessage';
27
26
  export { default as eosGetPublicKey } from './eosGetPublicKey';
28
27
  export { default as eosSignTransaction } from './eosSignTransaction';
29
28
  export { default as ethereumGetAddress } from './ethereumGetAddress';
package/lib/api/index.js CHANGED
@@ -3,8 +3,8 @@ 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.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.customMessage = 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
- exports.wipeDevice = exports.verifyMessage = exports.tezosSignTransaction = exports.tezosGetPublicKey = exports.tezosGetAddress = exports.stellarSignTransaction = exports.stellarGetAddress = exports.signTransaction = exports.signMessage = exports.setProxy = exports.rippleSignTransaction = exports.rippleGetAddress = exports.resetDevice = exports.requestLogin = void 0;
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
+ exports.wipeDevice = exports.verifyMessage = exports.tezosSignTransaction = exports.tezosGetPublicKey = exports.tezosGetAddress = exports.stellarSignTransaction = exports.stellarGetAddress = exports.signTransaction = exports.signMessage = exports.setProxy = 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");
@@ -55,8 +55,6 @@ var cipherKeyValue_1 = require("./cipherKeyValue");
55
55
  Object.defineProperty(exports, "cipherKeyValue", { enumerable: true, get: function () { return __importDefault(cipherKeyValue_1).default; } });
56
56
  var composeTransaction_1 = require("./composeTransaction");
57
57
  Object.defineProperty(exports, "composeTransaction", { enumerable: true, get: function () { return __importDefault(composeTransaction_1).default; } });
58
- var customMessage_1 = require("./customMessage");
59
- Object.defineProperty(exports, "customMessage", { enumerable: true, get: function () { return __importDefault(customMessage_1).default; } });
60
58
  var eosGetPublicKey_1 = require("./eosGetPublicKey");
61
59
  Object.defineProperty(exports, "eosGetPublicKey", { enumerable: true, get: function () { return __importDefault(eosGetPublicKey_1).default; } });
62
60
  var eosSignTransaction_1 = require("./eosSignTransaction");
@@ -16,7 +16,6 @@ export declare const ERROR_CODES: {
16
16
  Method_UnknownCoin: string;
17
17
  Method_AddressNotMatch: string;
18
18
  Method_FirmwareUpdate_DownloadFailed: string;
19
- Method_CustomMessage_Callback: string;
20
19
  Method_Discovery_BundleException: string;
21
20
  Method_Override: string;
22
21
  Method_NoResponse: string;
@@ -19,7 +19,6 @@ exports.ERROR_CODES = {
19
19
  Method_UnknownCoin: 'Coin not found',
20
20
  Method_AddressNotMatch: 'Addresses do not match',
21
21
  Method_FirmwareUpdate_DownloadFailed: 'Failed to download firmware binary',
22
- Method_CustomMessage_Callback: 'Parameter "callback" is not a function',
23
22
  Method_Discovery_BundleException: '',
24
23
  Method_Override: 'override',
25
24
  Method_NoResponse: 'Call resolved without response',
@@ -53,7 +53,6 @@ export declare abstract class AbstractMethod<Name extends CallMethodPayload['met
53
53
  checkFirmwareRange(isUsingPopup?: boolean): Promise<"ui-device_firmware_old" | "ui-device_firmware_unsupported" | "ui-device_firmware_not_compatible" | "ui-device_firmware_not_installed" | undefined>;
54
54
  abstract init(): void;
55
55
  abstract run(): Promise<MethodReturnType<Name>>;
56
- getCustomMessages(): void;
57
56
  dispose(): void;
58
57
  }
59
58
  //# sourceMappingURL=AbstractMethod.d.ts.map
@@ -152,7 +152,6 @@ class AbstractMethod {
152
152
  }
153
153
  }
154
154
  }
155
- getCustomMessages() { }
156
155
  dispose() { }
157
156
  }
158
157
  exports.AbstractMethod = AbstractMethod;
@@ -7,7 +7,7 @@ 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
9
  dispose(): 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").customMessage | 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").setProxy | import("../api").signMessage | import("../api").signTransaction | import("../api").stellarGetAddress | import("../api").stellarSignTransaction | import("../api").tezosGetAddress | import("../api").tezosGetPublicKey | import("../api").tezosSignTransaction | import("../api").verifyMessage | import("../api").wipeDevice)[];
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").setProxy | import("../api").signMessage | import("../api").signTransaction | import("../api").stellarGetAddress | import("../api").stellarSignTransaction | import("../api").tezosGetAddress | import("../api").tezosGetPublicKey | import("../api").tezosSignTransaction | import("../api").verifyMessage | import("../api").wipeDevice)[];
11
11
  getTransportInfo(): TransportInfo;
12
12
  }
13
13
  export declare const initCore: () => Core;
package/lib/core/index.js CHANGED
@@ -57,7 +57,6 @@ const handleMessage = (message, isTrustedOrigin = false) => {
57
57
  const safeMessages = [
58
58
  events_2.IFRAME.CALL,
59
59
  events_2.POPUP.CLOSED,
60
- events_2.UI.CUSTOM_MESSAGE_RESPONSE,
61
60
  events_2.UI.LOGIN_CHALLENGE_RESPONSE,
62
61
  events_2.TRANSPORT.DISABLE_WEBUSB,
63
62
  ];
@@ -82,7 +81,6 @@ const handleMessage = (message, isTrustedOrigin = false) => {
82
81
  case events_2.UI.INVALID_PASSPHRASE_ACTION:
83
82
  case events_2.UI.RECEIVE_ACCOUNT:
84
83
  case events_2.UI.RECEIVE_FEE:
85
- case events_2.UI.CUSTOM_MESSAGE_RESPONSE:
86
84
  case events_2.UI.RECEIVE_WORD:
87
85
  case events_2.UI.LOGIN_CHALLENGE_RESPONSE: {
88
86
  const uiPromise = findUiPromise(message.type);
@@ -255,9 +253,6 @@ const onCall = async (message) => {
255
253
  device.on(events_2.DEVICE.PASSPHRASE_ON_DEVICE, () => {
256
254
  postMessage((0, events_2.createUiMessage)(events_2.UI.REQUEST_PASSPHRASE_ON_DEVICE, { device: device.toMessageObject() }));
257
255
  });
258
- if (_deviceList) {
259
- await _deviceList.reconfigure(device.getVersion());
260
- }
261
256
  try {
262
257
  let PIN_TRIES = 1;
263
258
  const MAX_PIN_TRIES = 3;
@@ -311,9 +306,6 @@ const onCall = async (message) => {
311
306
  return Promise.reject(constants_1.ERRORS.TypedError('Method_Cancel'));
312
307
  }
313
308
  }
314
- if (_deviceList) {
315
- await _deviceList.reconfigure(device.getVersion());
316
- }
317
309
  try {
318
310
  const invalidDeviceState = method.useDeviceState
319
311
  ? await device.validateState(method.network)
@@ -354,10 +346,6 @@ const onCall = async (message) => {
354
346
  postMessage((0, events_2.createPopupMessage)(events_2.POPUP.CANCEL_POPUP_REQUEST));
355
347
  }
356
348
  try {
357
- const customMessages = method.getCustomMessages();
358
- if (_deviceList && customMessages) {
359
- await _deviceList.reconfigure(customMessages, true);
360
- }
361
349
  const response = await method.run();
362
350
  messageResponse = (0, events_2.createResponseMessage)(method.responseID, true, response);
363
351
  }
@@ -400,7 +388,6 @@ const onCall = async (message) => {
400
388
  if (response.success) {
401
389
  _deviceList.removeAuthPenalty(device);
402
390
  }
403
- await _deviceList.restoreMessages();
404
391
  }
405
392
  postMessage(response);
406
393
  }
@@ -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.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.customMessage | 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.setProxy | Methods.signMessage | Methods.signTransaction | Methods.stellarGetAddress | Methods.stellarSignTransaction | Methods.tezosGetAddress | Methods.tezosGetPublicKey | Methods.tezosSignTransaction | Methods.verifyMessage | Methods.wipeDevice;
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.setProxy | Methods.signMessage | Methods.signTransaction | Methods.stellarGetAddress | Methods.stellarSignTransaction | Methods.tezosGetAddress | Methods.tezosGetPublicKey | Methods.tezosSignTransaction | Methods.verifyMessage | Methods.wipeDevice;
6
6
  //# sourceMappingURL=method.d.ts.map
@@ -6,11 +6,9 @@ declare type AssetCollection = {
6
6
  export declare class DataManager {
7
7
  static assets: AssetCollection;
8
8
  static settings: ConnectSettings;
9
- static messages: {
10
- [key: string]: JSON;
11
- };
9
+ private static messages;
12
10
  static load(settings: ConnectSettings, withAssets?: boolean): Promise<void>;
13
- static getProtobufMessages(_version?: number[]): JSON;
11
+ static getProtobufMessages(): JSON;
14
12
  static isWhitelisted(origin: string): {
15
13
  origin: string;
16
14
  priority: number;
@@ -40,18 +40,14 @@ class DataManager {
40
40
  this.assets[asset.name] = json;
41
41
  });
42
42
  await Promise.all(assetPromises);
43
- const protobufPromises = config_1.config.messages.map(async (protobuf) => {
44
- const json = await (0, assets_1.httpRequest)(`${protobuf.json}${ts}`, 'json');
45
- this.messages[protobuf.name] = json;
46
- });
47
- await Promise.all(protobufPromises);
43
+ this.messages = await (0, assets_1.httpRequest)(`${config_1.config.messages}${ts}`, 'json');
48
44
  (0, transportInfo_1.parseBridgeJSON)(this.assets.bridge);
49
45
  (0, coinInfo_1.parseCoinsJson)(this.assets.coins);
50
46
  (0, firmwareInfo_1.parseFirmware)(this.assets['firmware-t1'], 1);
51
47
  (0, firmwareInfo_1.parseFirmware)(this.assets['firmware-t2'], 2);
52
48
  }
53
- static getProtobufMessages(_version) {
54
- return this.messages.default;
49
+ static getProtobufMessages() {
50
+ return this.messages;
55
51
  }
56
52
  static isWhitelisted(origin) {
57
53
  const uri = (0, parse_uri_1.default)(origin);
@@ -94,5 +90,4 @@ class DataManager {
94
90
  }
95
91
  exports.DataManager = DataManager;
96
92
  DataManager.assets = {};
97
- DataManager.messages = {};
98
93
  //# sourceMappingURL=DataManager.js.map
@@ -22,13 +22,7 @@ export declare const config: {
22
22
  name: string;
23
23
  url: string;
24
24
  }[];
25
- messages: {
26
- name: string;
27
- range: {
28
- min: string[];
29
- };
30
- json: string;
31
- }[];
25
+ messages: string;
32
26
  supportedBrowsers: {
33
27
  chrome: {
34
28
  version: number;
@@ -63,15 +63,7 @@ exports.config = {
63
63
  url: './data/firmware/2/releases.json',
64
64
  },
65
65
  ],
66
- messages: [
67
- {
68
- name: 'default',
69
- range: {
70
- min: ['1.0.0', '2.0.0'],
71
- },
72
- json: './data/messages/messages.json',
73
- },
74
- ],
66
+ messages: './data/messages/messages.json',
75
67
  supportedBrowsers: {
76
68
  chrome: {
77
69
  version: 59,
@@ -1,3 +1,3 @@
1
- export declare const VERSION = "9.0.0-beta.7";
1
+ export declare const VERSION = "9.0.0";
2
2
  export declare const DEFAULT_DOMAIN: string;
3
3
  //# sourceMappingURL=version.d.ts.map
@@ -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.0-beta.7';
4
+ exports.VERSION = '9.0.0';
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
@@ -39,9 +39,7 @@ export declare class DeviceList extends EventEmitter {
39
39
  creatingDevicesDescriptors: {
40
40
  [k: string]: DeviceDescriptor;
41
41
  };
42
- defaultMessages: JSON | Record<string, any>;
43
- currentMessages: JSON | Record<string, any>;
44
- hasCustomMessages: boolean;
42
+ messages: JSON | Record<string, any>;
45
43
  transportStartPending: number;
46
44
  penalizedDevices: {
47
45
  [deviceID: string]: number;
@@ -49,8 +47,6 @@ export declare class DeviceList extends EventEmitter {
49
47
  fetchController?: Controller | null;
50
48
  constructor();
51
49
  init(): Promise<void>;
52
- reconfigure(messages: JSON | Record<string, any> | number[], custom?: boolean): Promise<void>;
53
- restoreMessages(): Promise<void>;
54
50
  resolveTransportEvent(): void;
55
51
  waitForTransportFirstEvent(): Promise<void>;
56
52
  _initStream(): void;
@@ -23,7 +23,6 @@ class DeviceList extends events_1.default {
23
23
  super();
24
24
  this.devices = {};
25
25
  this.creatingDevicesDescriptors = {};
26
- this.hasCustomMessages = false;
27
26
  this.transportStartPending = 0;
28
27
  this.penalizedDevices = {};
29
28
  const { env, webusb } = DataManager_1.DataManager.settings;
@@ -46,8 +45,7 @@ class DeviceList extends events_1.default {
46
45
  transports.push((0, workers_1.WebUsbPlugin)());
47
46
  }
48
47
  this.transport = new Fallback(transports);
49
- this.defaultMessages = DataManager_1.DataManager.getProtobufMessages();
50
- this.currentMessages = this.defaultMessages;
48
+ this.messages = DataManager_1.DataManager.getProtobufMessages();
51
49
  }
52
50
  async init() {
53
51
  const { transport } = this;
@@ -55,7 +53,7 @@ class DeviceList extends events_1.default {
55
53
  _log.debug('Initializing transports');
56
54
  await transport.init(_log.enabled);
57
55
  _log.debug('Configuring transports');
58
- await transport.configure(JSON.stringify(this.defaultMessages));
56
+ await transport.configure(JSON.stringify(this.messages));
59
57
  _log.debug('Configuring transports done');
60
58
  const { activeName } = transport;
61
59
  if (activeName === 'LowlevelTransportWithSharedConnections') {
@@ -69,32 +67,6 @@ class DeviceList extends events_1.default {
69
67
  this.emit(events_2.TRANSPORT.ERROR, error);
70
68
  }
71
69
  }
72
- async reconfigure(messages, custom) {
73
- if (Array.isArray(messages)) {
74
- messages = DataManager_1.DataManager.getProtobufMessages(messages);
75
- }
76
- if (this.currentMessages === messages || !messages)
77
- return;
78
- try {
79
- await this.transport.configure(JSON.stringify(messages));
80
- this.currentMessages = messages;
81
- this.hasCustomMessages = typeof custom === 'boolean' ? custom : false;
82
- }
83
- catch (error) {
84
- throw constants_1.ERRORS.TypedError('Transport_InvalidProtobuf', error.message);
85
- }
86
- }
87
- async restoreMessages() {
88
- if (!this.hasCustomMessages)
89
- return;
90
- try {
91
- await this.transport.configure(JSON.stringify(this.defaultMessages));
92
- this.hasCustomMessages = false;
93
- }
94
- catch (error) {
95
- throw constants_1.ERRORS.TypedError('Transport_InvalidProtobuf', error.message);
96
- }
97
- }
98
70
  resolveTransportEvent() {
99
71
  this.transportStartPending--;
100
72
  if (this.transportStartPending === 0) {
@@ -19,7 +19,6 @@ export declare const UI: {
19
19
  readonly RECEIVE_WORD: "ui-receive_word";
20
20
  readonly INVALID_PASSPHRASE_ACTION: "ui-invalid_passphrase_action";
21
21
  readonly CHANGE_SETTINGS: "ui-change_settings";
22
- readonly CUSTOM_MESSAGE_RESPONSE: "ui-custom_response";
23
22
  readonly LOGIN_CHALLENGE_RESPONSE: "ui-login_challenge_response";
24
23
  readonly TRANSPORT: "ui-no_transport";
25
24
  readonly BOOTLOADER: "ui-device_bootloader_mode";
@@ -54,7 +53,6 @@ export declare const UI: {
54
53
  readonly REQUEST_BUTTON: "ui-button";
55
54
  readonly REQUEST_WORD: "ui-request_word";
56
55
  readonly LOGIN_CHALLENGE_REQUEST: "ui-login_challenge_request";
57
- readonly CUSTOM_MESSAGE_REQUEST: "ui-custom_request";
58
56
  readonly BUNDLE_PROGRESS: "ui-bundle_progress";
59
57
  readonly ADDRESS_VALIDATION: "ui-address_validation";
60
58
  readonly IFRAME_FAILURE: "ui-iframe_failure";
@@ -39,7 +39,6 @@ export declare const UI_REQUEST: {
39
39
  readonly REQUEST_BUTTON: "ui-button";
40
40
  readonly REQUEST_WORD: "ui-request_word";
41
41
  readonly LOGIN_CHALLENGE_REQUEST: "ui-login_challenge_request";
42
- readonly CUSTOM_MESSAGE_REQUEST: "ui-custom_request";
43
42
  readonly BUNDLE_PROGRESS: "ui-bundle_progress";
44
43
  readonly ADDRESS_VALIDATION: "ui-address_validation";
45
44
  readonly IFRAME_FAILURE: "ui-iframe_failure";
@@ -163,14 +162,7 @@ export interface FirmwareProgress {
163
162
  progress: number;
164
163
  };
165
164
  }
166
- export interface UiRequestCustomMessage {
167
- type: typeof UI_REQUEST.CUSTOM_MESSAGE_REQUEST;
168
- payload: {
169
- type: string;
170
- message: object;
171
- };
172
- }
173
- export declare type UiEvent = UiRequestWithoutPayload | UiRequestDeviceAction | UiRequestButton | UiRequestPermission | UiRequestConfirmation | UiRequestSelectDevice | UiRequestUnexpectedDeviceMode | UiRequestSelectAccount | UiRequestSelectFee | UpdateCustomFee | BundleProgress<any> | FirmwareProgress | FirmwareException | UiRequestAddressValidation | UiRequestCustomMessage | UiRequestSetOperation | TransportDisableWebUSB;
165
+ export declare type UiEvent = UiRequestWithoutPayload | UiRequestDeviceAction | UiRequestButton | UiRequestPermission | UiRequestConfirmation | UiRequestSelectDevice | UiRequestUnexpectedDeviceMode | UiRequestSelectAccount | UiRequestSelectFee | UpdateCustomFee | BundleProgress<any> | FirmwareProgress | FirmwareException | UiRequestAddressValidation | UiRequestSetOperation | TransportDisableWebUSB;
174
166
  export declare type UiEventMessage = UiEvent & {
175
167
  event: typeof UI_EVENT;
176
168
  };
@@ -36,7 +36,6 @@ exports.UI_REQUEST = {
36
36
  REQUEST_BUTTON: 'ui-button',
37
37
  REQUEST_WORD: 'ui-request_word',
38
38
  LOGIN_CHALLENGE_REQUEST: 'ui-login_challenge_request',
39
- CUSTOM_MESSAGE_REQUEST: 'ui-custom_request',
40
39
  BUNDLE_PROGRESS: 'ui-bundle_progress',
41
40
  ADDRESS_VALIDATION: 'ui-address_validation',
42
41
  IFRAME_FAILURE: 'ui-iframe_failure',
@@ -13,7 +13,6 @@ export declare const UI_RESPONSE: {
13
13
  readonly RECEIVE_WORD: "ui-receive_word";
14
14
  readonly INVALID_PASSPHRASE_ACTION: "ui-invalid_passphrase_action";
15
15
  readonly CHANGE_SETTINGS: "ui-change_settings";
16
- readonly CUSTOM_MESSAGE_RESPONSE: "ui-custom_response";
17
16
  readonly LOGIN_CHALLENGE_RESPONSE: "ui-login_challenge_response";
18
17
  };
19
18
  export interface UiResponsePopupHandshake {
@@ -74,14 +73,6 @@ export interface UiResponseFee {
74
73
  value: string;
75
74
  };
76
75
  }
77
- export interface UiResponseCustomMessage {
78
- type: typeof UI_RESPONSE.CUSTOM_MESSAGE_RESPONSE;
79
- payload: {
80
- type: string;
81
- message: any;
82
- params?: any;
83
- };
84
- }
85
76
  export interface UiResponseLoginChallenge {
86
77
  type: typeof UI_RESPONSE.LOGIN_CHALLENGE_RESPONSE;
87
78
  payload: {
@@ -89,7 +80,7 @@ export interface UiResponseLoginChallenge {
89
80
  challengeVisual: string;
90
81
  };
91
82
  }
92
- export declare type UiResponseEvent = UiResponsePopupHandshake | UiResponsePermission | UiResponseConfirmation | UiResponseDevice | UiResponsePin | UiResponseWord | UiResponsePassphrase | UiResponsePassphraseAction | UiResponseAccount | UiResponseFee | UiResponseLoginChallenge | UiResponseCustomMessage;
83
+ export declare type UiResponseEvent = UiResponsePopupHandshake | UiResponsePermission | UiResponseConfirmation | UiResponseDevice | UiResponsePin | UiResponseWord | UiResponsePassphrase | UiResponsePassphraseAction | UiResponseAccount | UiResponseFee | UiResponseLoginChallenge;
93
84
  export declare type UiResponseMessage = UiResponseEvent & {
94
85
  event: typeof UI_EVENT;
95
86
  };
@@ -13,7 +13,6 @@ exports.UI_RESPONSE = {
13
13
  RECEIVE_WORD: 'ui-receive_word',
14
14
  INVALID_PASSPHRASE_ACTION: 'ui-invalid_passphrase_action',
15
15
  CHANGE_SETTINGS: 'ui-change_settings',
16
- CUSTOM_MESSAGE_RESPONSE: 'ui-custom_response',
17
16
  LOGIN_CHALLENGE_RESPONSE: 'ui-login_challenge_response',
18
17
  };
19
18
  const createUiResponse = (type, payload) => ({
package/lib/factory.d.ts CHANGED
@@ -7,7 +7,6 @@ interface Dependencies {
7
7
  eventEmitter: EventEmitter;
8
8
  manifest: TrezorConnect['manifest'];
9
9
  init: TrezorConnect['init'];
10
- customMessage: TrezorConnect['customMessage'];
11
10
  requestLogin: TrezorConnect['requestLogin'];
12
11
  uiResponse: TrezorConnect['uiResponse'];
13
12
  renderWebUSBButton: TrezorConnect['renderWebUSBButton'];
@@ -15,6 +14,6 @@ interface Dependencies {
15
14
  cancel: TrezorConnect['cancel'];
16
15
  dispose: TrezorConnect['dispose'];
17
16
  }
18
- export declare const factory: ({ eventEmitter, manifest, init, call, customMessage, requestLogin, uiResponse, renderWebUSBButton, disableWebUSB, cancel, dispose, }: Dependencies) => TrezorConnect;
17
+ export declare const factory: ({ eventEmitter, manifest, init, call, requestLogin, uiResponse, renderWebUSBButton, disableWebUSB, cancel, dispose, }: Dependencies) => TrezorConnect;
19
18
  export {};
20
19
  //# 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, customMessage, requestLogin, uiResponse, renderWebUSBButton, disableWebUSB, cancel, dispose, }) => {
5
+ const factory = ({ eventEmitter, manifest, init, call, requestLogin, uiResponse, renderWebUSBButton, disableWebUSB, cancel, dispose, }) => {
6
6
  const api = {
7
7
  manifest,
8
8
  init,
@@ -33,7 +33,6 @@ const factory = ({ eventEmitter, manifest, init, call, customMessage, requestLog
33
33
  blockchainSubscribeFiatRates: params => call({ ...params, method: 'blockchainSubscribeFiatRates' }),
34
34
  blockchainUnsubscribe: params => call({ ...params, method: 'blockchainUnsubscribe' }),
35
35
  blockchainUnsubscribeFiatRates: params => call({ ...params, method: 'blockchainUnsubscribeFiatRates' }),
36
- customMessage: params => customMessage(params),
37
36
  requestLogin: params => requestLogin(params),
38
37
  cardanoGetAddress: params => call({
39
38
  ...params,
@@ -16,7 +16,6 @@ const TrezorConnect = (0, factory_1.factory)({
16
16
  manifest: fallback,
17
17
  init: fallback,
18
18
  call: fallback,
19
- customMessage: fallback,
20
19
  requestLogin: fallback,
21
20
  uiResponse: fallback,
22
21
  renderWebUSBButton: fallback,
package/lib/index.js CHANGED
@@ -132,16 +132,6 @@ const call = async (params) => {
132
132
  return (0, events_2.createErrorMessage)(error);
133
133
  }
134
134
  };
135
- const customMessageResponse = (payload) => {
136
- if (!_core) {
137
- return Promise.resolve((0, events_2.createErrorMessage)(constants_1.ERRORS.TypedError('Init_NotInitialized')));
138
- }
139
- _core.handleMessage({
140
- event: events_2.UI_EVENT,
141
- type: events_2.UI.CUSTOM_MESSAGE_RESPONSE,
142
- payload,
143
- }, true);
144
- };
145
135
  const uiResponse = (response) => {
146
136
  if (!_core) {
147
137
  throw constants_1.ERRORS.TypedError('Init_NotInitialized');
@@ -149,28 +139,6 @@ const uiResponse = (response) => {
149
139
  const { type, payload } = response;
150
140
  _core.handleMessage({ event: events_2.UI_EVENT, type, payload }, true);
151
141
  };
152
- const customMessage = async (params) => {
153
- if (typeof params.callback !== 'function') {
154
- return (0, events_2.createErrorMessage)(constants_1.ERRORS.TypedError('Method_CustomMessage_Callback'));
155
- }
156
- const { callback } = params;
157
- const customMessageListener = async (event) => {
158
- const { data } = event;
159
- if (data && data.type === events_2.UI.CUSTOM_MESSAGE_REQUEST) {
160
- const payload = await callback(data.payload);
161
- if (payload) {
162
- customMessageResponse(payload);
163
- }
164
- else {
165
- customMessageResponse({ message: 'release' });
166
- }
167
- }
168
- };
169
- _core === null || _core === void 0 ? void 0 : _core.on(events_2.CORE_EVENT, customMessageListener);
170
- const response = await call({ method: 'customMessage', ...params, callback: null });
171
- _core === null || _core === void 0 ? void 0 : _core.removeListener(events_2.CORE_EVENT, customMessageListener);
172
- return response;
173
- };
174
142
  const requestLogin = async (params) => {
175
143
  if (typeof params.callback === 'function') {
176
144
  const { callback } = params;
@@ -223,7 +191,6 @@ const TrezorConnect = (0, factory_1.factory)({
223
191
  manifest,
224
192
  init,
225
193
  call,
226
- customMessage,
227
194
  requestLogin,
228
195
  uiResponse,
229
196
  renderWebUSBButton,
@@ -24,7 +24,6 @@ import { cardanoSignTransaction } from './cardanoSignTransaction';
24
24
  import { changePin } from './changePin';
25
25
  import { cipherKeyValue } from './cipherKeyValue';
26
26
  import { composeTransaction } from './composeTransaction';
27
- import { customMessage } from './customMessage';
28
27
  import { disableWebUSB } from './disableWebUSB';
29
28
  import { dispose } from './dispose';
30
29
  import { eosGetPublicKey } from './eosGetPublicKey';
@@ -99,7 +98,6 @@ export interface TrezorConnect {
99
98
  changePin: typeof changePin;
100
99
  cipherKeyValue: typeof cipherKeyValue;
101
100
  composeTransaction: typeof composeTransaction;
102
- customMessage: typeof customMessage;
103
101
  disableWebUSB: typeof disableWebUSB;
104
102
  dispose: typeof dispose;
105
103
  eosGetPublicKey: typeof eosGetPublicKey;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trezor/connect",
3
- "version": "9.0.0-beta.7",
3
+ "version": "9.0.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.",
@@ -21,8 +21,8 @@
21
21
  "main": "lib/index",
22
22
  "browser": {
23
23
  "./lib/index": "./lib/index-browser",
24
- "./lib/workers/workers": "./lib/workers/workers-browser",
25
- "./lib/utils/assets": "./lib/utils/assets-browser"
24
+ "./lib/utils/assets": "./lib/utils/assets-browser",
25
+ "./lib/workers/workers": "./lib/workers/workers-browser"
26
26
  },
27
27
  "react-native": {
28
28
  "./lib/index": "./lib/index",
@@ -37,7 +37,7 @@
37
37
  "lint": "eslint '**/*.{ts,tsx,js}'",
38
38
  "test:unit": "jest",
39
39
  "type-check": "tsc --build",
40
- "build:lib": "rimraf ./lib && tsc --build tsconfig.lib.json",
40
+ "build:lib": "rimraf ./lib && yarn tsc --build tsconfig.lib.json",
41
41
  "version:beta": "tsx scripts/bump-version.ts prerelease",
42
42
  "version:patch": "tsx scripts/bump-version.ts patch",
43
43
  "version:minor": "tsx scripts/bump-version.ts minor",
@@ -61,6 +61,9 @@
61
61
  "devDependencies": {
62
62
  "@types/parse-uri": "^1.0.0",
63
63
  "@types/randombytes": "^2.0.0",
64
- "version-bump-prompt": "^6.1.0"
64
+ "jest": "^26.6.3",
65
+ "rimraf": "^3.0.2",
66
+ "tsx": "^3.8.2",
67
+ "typescript": "4.7.4"
65
68
  }
66
69
  }
@@ -1,13 +0,0 @@
1
- import { AbstractMethod } from '../core/AbstractMethod';
2
- declare type Params = {
3
- customMessages?: JSON | Record<string, any>;
4
- message: string;
5
- params?: any;
6
- };
7
- export default class CustomMessage extends AbstractMethod<'customMessage', Params> {
8
- init(): void;
9
- getCustomMessages(): JSON | Record<string, any> | undefined;
10
- run(): Promise<any>;
11
- }
12
- export {};
13
- //# sourceMappingURL=customMessage.d.ts.map
@@ -1,56 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const AbstractMethod_1 = require("../core/AbstractMethod");
4
- const paramsValidator_1 = require("./common/paramsValidator");
5
- const constants_1 = require("../constants");
6
- const events_1 = require("../events");
7
- class CustomMessage extends AbstractMethod_1.AbstractMethod {
8
- init() {
9
- this.requiredPermissions = ['custom-message', 'read', 'write'];
10
- this.info = 'Custom message';
11
- const { payload } = this;
12
- (0, paramsValidator_1.validateParams)(payload, [
13
- { name: 'message', type: 'string', required: true },
14
- { name: 'params', type: 'object', required: true },
15
- ]);
16
- if (payload.messages) {
17
- try {
18
- JSON.parse(JSON.stringify(payload.messages));
19
- }
20
- catch (error) {
21
- throw constants_1.ERRORS.TypedError('Method_InvalidParameter', 'Parameter "messages" has invalid type. JSON expected.');
22
- }
23
- }
24
- this.params = {
25
- customMessages: payload.messages,
26
- message: payload.message,
27
- params: payload.params,
28
- };
29
- }
30
- getCustomMessages() {
31
- return this.params.customMessages;
32
- }
33
- async run() {
34
- if (this.device.features.vendor === 'trezor.io' ||
35
- this.device.features.vendor === 'bitcointrezor.com') {
36
- throw constants_1.ERRORS.TypedError('Runtime', 'Cannot use custom message on device with official firmware. Change device "vendor" field.');
37
- }
38
- const response = await this.device
39
- .getCommands()
40
- ._commonCall(this.params.message, this.params.params);
41
- const uiPromise = this.createUiPromise(events_1.UI.CUSTOM_MESSAGE_RESPONSE);
42
- this.postMessage((0, events_1.createUiMessage)(events_1.UI.CUSTOM_MESSAGE_REQUEST, response));
43
- const uiResp = await uiPromise.promise;
44
- const { payload } = uiResp;
45
- (0, paramsValidator_1.validateParams)(payload, [{ name: 'message', type: 'string', required: true }]);
46
- if (payload.message.toLowerCase() === 'release') {
47
- return response;
48
- }
49
- (0, paramsValidator_1.validateParams)(payload, [{ name: 'params', type: 'object', required: true }]);
50
- this.params.message = payload.message;
51
- this.params.params = payload.params;
52
- return this.run();
53
- }
54
- }
55
- exports.default = CustomMessage;
56
- //# sourceMappingURL=customMessage.js.map
@@ -1,12 +0,0 @@
1
- import type { Params, Response } from '../params';
2
- export interface CustomMessage {
3
- messages?: JSON | Record<string, any>;
4
- message: string;
5
- params: JSON | Record<string, any>;
6
- callback: (request: any) => Promise<{
7
- message: string;
8
- params?: Record<string, any>;
9
- }>;
10
- }
11
- export declare function customMessage<R extends Record<string, any>>(params: Params<CustomMessage>): Response<R>;
12
- //# sourceMappingURL=customMessage.d.ts.map
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=customMessage.js.map