@trezor/connect 9.6.2-beta.3 → 9.6.3-beta.1

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.
Files changed (139) hide show
  1. package/CHANGELOG.md +15 -6
  2. package/README.md +1 -1
  3. package/lib/api/applySettings.js +16 -1
  4. package/lib/api/bitcoin/signtx.d.ts +2 -2
  5. package/lib/api/bitcoin/signtx.js +1 -1
  6. package/lib/api/bleUnpair.js +0 -1
  7. package/lib/api/cardano/api/cardanoGetAddress.d.ts +1 -0
  8. package/lib/api/cardano/api/cardanoSignMessage.d.ts +25 -0
  9. package/lib/api/cardano/api/cardanoSignMessage.js +97 -0
  10. package/lib/api/cardano/api/index.d.ts +1 -0
  11. package/lib/api/cardano/api/index.js +3 -1
  12. package/lib/api/cardano/cardanoUtils.d.ts +1 -1
  13. package/lib/api/cardano/cardanoUtils.js +2 -2
  14. package/lib/api/discoverAccounts.js +61 -33
  15. package/lib/api/ethereum/api/ethereumGetAddress.js +1 -0
  16. package/lib/api/ethereum/api/ethereumSignTransaction.js +22 -4
  17. package/lib/api/ethereum/ethereumSignTx.d.ts +3 -2
  18. package/lib/api/ethereum/ethereumSignTx.js +4 -2
  19. package/lib/api/evoluGetNode.d.ts +11 -0
  20. package/lib/api/evoluGetNode.js +26 -0
  21. package/lib/api/firmware/calculateFirmwareHash.d.ts +2 -1
  22. package/lib/api/firmware/calculateFirmwareHash.js +17 -4
  23. package/lib/api/firmware/getBinary.d.ts +7 -6
  24. package/lib/api/firmware/getBinary.js +18 -6
  25. package/lib/api/firmware/index.d.ts +0 -2
  26. package/lib/api/firmware/index.js +1 -5
  27. package/lib/api/firmware/uploadFirmware.d.ts +10 -1
  28. package/lib/api/firmware/uploadFirmware.js +8 -7
  29. package/lib/api/getFeatures.d.ts +2 -1
  30. package/lib/api/index.d.ts +3 -0
  31. package/lib/api/index.js +8 -2
  32. package/lib/api/nem/nemSignTx.d.ts +1 -1
  33. package/lib/api/pushTransaction.d.ts +2 -1
  34. package/lib/api/pushTransaction.js +2 -1
  35. package/lib/api/resetDevice.js +2 -1
  36. package/lib/api/ripple/api/rippleGetAddress.d.ts +1 -0
  37. package/lib/api/signMessage.js +1 -1
  38. package/lib/api/signTransaction.d.ts +1 -1
  39. package/lib/api/solana/api/solanaGetAddress.d.ts +1 -0
  40. package/lib/api/solana/api/solanaGetPublicKey.d.ts +2 -0
  41. package/lib/api/solana/api/solanaGetPublicKey.js +3 -0
  42. package/lib/api/stellar/api/stellarGetAddress.d.ts +1 -0
  43. package/lib/api/tezos/api/tezosGetAddress.d.ts +1 -0
  44. package/lib/api/tezos/tezosSignTx.d.ts +1 -1
  45. package/lib/api/thpGetCredentials.d.ts +10 -0
  46. package/lib/api/thpGetCredentials.js +31 -0
  47. package/lib/api/thpRemoveCredentials.d.ts +8 -0
  48. package/lib/api/thpRemoveCredentials.js +32 -0
  49. package/lib/api/wipeDevice.js +6 -2
  50. package/lib/backend/Blockchain.d.ts +4 -4
  51. package/lib/backend/Blockchain.js +12 -11
  52. package/lib/constants/cardano.d.ts +3 -0
  53. package/lib/constants/cardano.js +5 -1
  54. package/lib/constants/errors.d.ts +12 -9
  55. package/lib/constants/errors.js +18 -24
  56. package/lib/core/AbstractMethod.d.ts +5 -24
  57. package/lib/core/AbstractMethod.js +2 -2
  58. package/lib/core/index.js +5 -1
  59. package/lib/core/onCallFirmwareUpdate.d.ts +13 -1
  60. package/lib/core/onCallFirmwareUpdate.js +158 -94
  61. package/lib/data/DataManager.d.ts +13 -1
  62. package/lib/data/DataManager.js +44 -14
  63. package/lib/data/coinInfo.d.ts +8 -84
  64. package/lib/data/coinInfo.js +6 -9
  65. package/lib/data/config.d.ts +26 -192
  66. package/lib/data/config.js +37 -1
  67. package/lib/data/connectSettings.js +7 -0
  68. package/lib/data/defaultFeeLevels.js +2 -1
  69. package/lib/data/deviceAuthenticityConfig.js +10 -1
  70. package/lib/data/firmwareInfo.d.ts +44 -11
  71. package/lib/data/firmwareInfo.js +360 -122
  72. package/lib/data/thpSettings.js +5 -2
  73. package/lib/data/version.d.ts +2 -1
  74. package/lib/data/version.js +4 -3
  75. package/lib/device/Device.d.ts +17 -7
  76. package/lib/device/Device.js +72 -115
  77. package/lib/device/DeviceCommands.d.ts +1 -0
  78. package/lib/device/DeviceCurrentSession.d.ts +41 -20
  79. package/lib/device/DeviceCurrentSession.js +18 -22
  80. package/lib/device/TransportList.js +10 -5
  81. package/lib/device/checkFirmwareRevision.d.ts +3 -2
  82. package/lib/device/checkFirmwareRevision.js +6 -11
  83. package/lib/device/thp/handshake.d.ts +4 -0
  84. package/lib/device/thp/handshake.js +88 -0
  85. package/lib/device/thp/index.d.ts +4 -1
  86. package/lib/device/thp/index.js +24 -6
  87. package/lib/device/thp/pairing.d.ts +16 -0
  88. package/lib/device/thp/pairing.js +230 -0
  89. package/lib/device/thp/session.d.ts +3 -0
  90. package/lib/device/thp/session.js +27 -0
  91. package/lib/device/thp/thpCall.d.ts +41 -0
  92. package/lib/device/thp/thpCall.js +57 -0
  93. package/lib/device/workflow/checkFirmwareHash.d.ts +10 -0
  94. package/lib/device/workflow/checkFirmwareHash.js +79 -0
  95. package/lib/device/workflow/checkFirmwareHashWithRetries.d.ts +9 -0
  96. package/lib/device/workflow/checkFirmwareHashWithRetries.js +41 -0
  97. package/lib/device/workflow/handshake.js +7 -6
  98. package/lib/device/workflow/validateState.js +53 -10
  99. package/lib/events/ui-request.d.ts +1 -1
  100. package/lib/factory.js +4 -0
  101. package/lib/tsconfig.lib.tsbuildinfo +1 -1
  102. package/lib/types/api/bitcoin/index.d.ts +1 -1
  103. package/lib/types/api/cardano/index.d.ts +62 -1
  104. package/lib/types/api/cardano/index.js +30 -1
  105. package/lib/types/api/cardanoSignMessage.d.ts +4 -0
  106. package/lib/types/api/cardanoSignMessage.js +3 -0
  107. package/lib/types/api/discoverAccounts.d.ts +17 -12
  108. package/lib/types/api/ethereum/index.d.ts +108 -0
  109. package/lib/types/api/ethereum/index.js +3 -0
  110. package/lib/types/api/evoluGetNode.d.ts +4 -0
  111. package/lib/types/api/evoluGetNode.js +3 -0
  112. package/lib/types/api/index.d.ts +8 -0
  113. package/lib/types/api/pushTransaction.d.ts +4 -1
  114. package/lib/types/api/pushTransaction.js +7 -1
  115. package/lib/types/api/solana/index.d.ts +3 -0
  116. package/lib/types/api/solana/index.js +2 -0
  117. package/lib/types/api/thpGetCredentials.d.ts +4 -0
  118. package/lib/types/api/thpGetCredentials.js +3 -0
  119. package/lib/types/api/thpRemoveCredentials.d.ts +7 -0
  120. package/lib/types/api/thpRemoveCredentials.js +3 -0
  121. package/lib/types/device.d.ts +9 -9
  122. package/lib/types/firmware.d.ts +15 -12
  123. package/lib/types/firmware.js +0 -3
  124. package/lib/types/params.d.ts +1 -0
  125. package/lib/types/settings.d.ts +7 -0
  126. package/lib/utils/assetUtils.d.ts +5 -2
  127. package/lib/utils/assetUtils.js +14 -18
  128. package/lib/utils/assets.native.js +0 -2
  129. package/lib/utils/firmwareReleaseConfigUtils.d.ts +8 -5
  130. package/lib/utils/firmwareReleaseConfigUtils.js +74 -59
  131. package/lib/utils/firmwareUtils.d.ts +8 -4
  132. package/lib/utils/firmwareUtils.js +62 -20
  133. package/lib/utils/formatUtils.d.ts +1 -0
  134. package/lib/utils/formatUtils.js +3 -2
  135. package/package.json +19 -18
  136. package/lib/api/firmware/getBinaryForFirmwareUpgrade.d.ts +0 -12
  137. package/lib/api/firmware/getBinaryForFirmwareUpgrade.js +0 -32
  138. package/lib/data/getLanguage.d.ts +0 -6
  139. package/lib/data/getLanguage.js +0 -10
@@ -2,10 +2,23 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.calculateFirmwareHash = void 0;
4
4
  const blakejs_1 = require("blakejs");
5
- const SIZE_T1 = (7 * 128 + 64) * 1024;
6
- const SIZE_TT = 13 * 128 * 1024;
7
- const calculateFirmwareHash = (major_version, fw, key) => {
8
- const size = major_version === 1 ? SIZE_T1 : SIZE_TT;
5
+ const device_utils_1 = require("@trezor/device-utils");
6
+ const SIZE_T1B1 = (7 * 128 + 64) * 1024;
7
+ const SIZE_T2T1 = 13 * 128 * 1024;
8
+ const SIZE_T2B1 = 13 * 128 * 1024;
9
+ const SIZE_T3B1 = 208 * 8 * 1024;
10
+ const SIZE_T3T1 = 208 * 8 * 1024;
11
+ const SIZE_T3W1 = 417 * 8 * 1024;
12
+ const firmwareSizeMap = {
13
+ [device_utils_1.DeviceModelInternal.T1B1]: SIZE_T1B1,
14
+ [device_utils_1.DeviceModelInternal.T2T1]: SIZE_T2T1,
15
+ [device_utils_1.DeviceModelInternal.T2B1]: SIZE_T2B1,
16
+ [device_utils_1.DeviceModelInternal.T3B1]: SIZE_T3B1,
17
+ [device_utils_1.DeviceModelInternal.T3T1]: SIZE_T3T1,
18
+ [device_utils_1.DeviceModelInternal.T3W1]: SIZE_T3W1,
19
+ };
20
+ const calculateFirmwareHash = (internal_model, fw, key) => {
21
+ const size = firmwareSizeMap[internal_model] ?? SIZE_T1B1;
9
22
  const padding = size - fw.byteLength;
10
23
  if (padding < 0) {
11
24
  throw new Error('Firmware too big');
@@ -1,10 +1,11 @@
1
- import type { FirmwareRelease } from '@trezor/device-utils';
2
- interface GetBinaryProps {
1
+ import { VersionArray } from '@trezor/device-utils';
2
+ import { BinaryInfo } from '../../types';
3
+ interface GetBinaryParams {
3
4
  baseUrl: string;
4
- btcOnly?: boolean;
5
- release: FirmwareRelease;
5
+ path: string;
6
+ version: VersionArray;
6
7
  }
7
- export declare const getBinary: ({ baseUrl, btcOnly, release }: GetBinaryProps) => Promise<ArrayBuffer | Buffer<ArrayBufferLike>>;
8
- export declare const getBinaryOptional: (props: GetBinaryProps) => Promise<ArrayBuffer | null>;
8
+ export declare const getBinary: ({ baseUrl, path, version, }: GetBinaryParams) => Promise<BinaryInfo>;
9
+ export declare const getBinaryOptional: (params: GetBinaryParams) => Promise<BinaryInfo | null>;
9
10
  export {};
10
11
  //# sourceMappingURL=getBinary.d.ts.map
@@ -2,17 +2,29 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getBinaryOptional = exports.getBinary = void 0;
4
4
  const utils_1 = require("@trezor/utils");
5
+ const parseFirmwareHeaders_1 = require("./parseFirmwareHeaders");
6
+ const constants_1 = require("../../constants");
5
7
  const assets_1 = require("../../utils/assets");
6
- const getBinary = ({ baseUrl, btcOnly, release }) => {
7
- const fwUrl = release[btcOnly ? 'url_bitcoinonly' : 'url'];
8
+ const MIN_FIRMWARE_SIZE_BYTES = 200;
9
+ const getBinary = async ({ baseUrl, path, version, }) => {
8
10
  const sanitizedBaseUrl = (0, utils_1.removeTrailingSlashes)(baseUrl);
9
- const url = `${sanitizedBaseUrl}/${fwUrl}`;
10
- return (0, assets_1.httpRequest)(url, 'binary');
11
+ const url = `${sanitizedBaseUrl}/${path}`;
12
+ const binaryArrayBuffer = (await (0, assets_1.httpRequest)(url, 'binary'));
13
+ if (binaryArrayBuffer.byteLength < MIN_FIRMWARE_SIZE_BYTES) {
14
+ throw constants_1.ERRORS.TypedError('Runtime', 'Firmware binary is too small');
15
+ }
16
+ const firmwareBuffer = Buffer.from(binaryArrayBuffer);
17
+ const { version: binaryVersion } = (0, parseFirmwareHeaders_1.parseFirmwareHeaders)(firmwareBuffer);
18
+ return {
19
+ binary: binaryArrayBuffer,
20
+ binaryVersion,
21
+ releaseVersion: version,
22
+ };
11
23
  };
12
24
  exports.getBinary = getBinary;
13
- const getBinaryOptional = async (props) => {
25
+ const getBinaryOptional = async (params) => {
14
26
  try {
15
- return await (0, exports.getBinary)(props);
27
+ return await (0, exports.getBinary)(params);
16
28
  }
17
29
  catch {
18
30
  return null;
@@ -1,6 +1,4 @@
1
- export { getBinaryForFirmwareUpgrade } from './getBinaryForFirmwareUpgrade';
2
1
  export { getBinary, getBinaryOptional } from './getBinary';
3
- export { getLanguage } from '../../data/getLanguage';
4
2
  export { shouldStripFwHeaders, stripFwHeaders } from './modifyFirmware';
5
3
  export { uploadFirmware } from './uploadFirmware';
6
4
  export { calculateFirmwareHash } from './calculateFirmwareHash';
@@ -1,13 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseFirmwareHeaders = exports.calculateFirmwareHash = exports.uploadFirmware = exports.stripFwHeaders = exports.shouldStripFwHeaders = exports.getLanguage = exports.getBinaryOptional = exports.getBinary = exports.getBinaryForFirmwareUpgrade = void 0;
4
- var getBinaryForFirmwareUpgrade_1 = require("./getBinaryForFirmwareUpgrade");
5
- Object.defineProperty(exports, "getBinaryForFirmwareUpgrade", { enumerable: true, get: function () { return getBinaryForFirmwareUpgrade_1.getBinaryForFirmwareUpgrade; } });
3
+ exports.parseFirmwareHeaders = exports.calculateFirmwareHash = exports.uploadFirmware = exports.stripFwHeaders = exports.shouldStripFwHeaders = exports.getBinaryOptional = exports.getBinary = void 0;
6
4
  var getBinary_1 = require("./getBinary");
7
5
  Object.defineProperty(exports, "getBinary", { enumerable: true, get: function () { return getBinary_1.getBinary; } });
8
6
  Object.defineProperty(exports, "getBinaryOptional", { enumerable: true, get: function () { return getBinary_1.getBinaryOptional; } });
9
- var getLanguage_1 = require("../../data/getLanguage");
10
- Object.defineProperty(exports, "getLanguage", { enumerable: true, get: function () { return getLanguage_1.getLanguage; } });
11
7
  var modifyFirmware_1 = require("./modifyFirmware");
12
8
  Object.defineProperty(exports, "shouldStripFwHeaders", { enumerable: true, get: function () { return modifyFirmware_1.shouldStripFwHeaders; } });
13
9
  Object.defineProperty(exports, "stripFwHeaders", { enumerable: true, get: function () { return modifyFirmware_1.stripFwHeaders; } });
@@ -2,7 +2,15 @@ import { PROTO } from '../../constants';
2
2
  import type { Device } from '../../device/Device';
3
3
  import type { TypedCall } from '../../device/DeviceCommands';
4
4
  import { CoreEventMessage } from '../../events';
5
- export declare const uploadFirmware: (typedCall: TypedCall, postMessage: (message: CoreEventMessage) => void, device: Device, { payload }: PROTO.FirmwareUpload) => Promise<{
5
+ import { FirmwareUpdateFlowType } from '../../types';
6
+ type UploadFirmwareProps = {
7
+ typedCall: TypedCall;
8
+ postMessage: (message: CoreEventMessage) => void;
9
+ device: Device;
10
+ firmwareUploadRequest: PROTO.FirmwareUpload;
11
+ updateFlowType: FirmwareUpdateFlowType;
12
+ };
13
+ export declare const uploadFirmware: ({ typedCall, postMessage, device, firmwareUploadRequest: { payload }, updateFlowType, }: UploadFirmwareProps) => Promise<{
6
14
  message: string;
7
15
  } | {
8
16
  type: "Success";
@@ -10,4 +18,5 @@ export declare const uploadFirmware: (typedCall: TypedCall, postMessage: (messag
10
18
  message: string;
11
19
  };
12
20
  }>;
21
+ export {};
13
22
  //# sourceMappingURL=uploadFirmware.d.ts.map
@@ -4,10 +4,11 @@ exports.uploadFirmware = void 0;
4
4
  const transport_1 = require("@trezor/transport");
5
5
  const constants_1 = require("../../constants");
6
6
  const events_1 = require("../../events");
7
- const postConfirmationMessage = (device) => {
8
- if (device.features.firmware_present) {
9
- device.emit(events_1.DEVICE.BUTTON, { device, payload: { code: 'ButtonRequest_FirmwareUpdate' } });
10
- }
7
+ const postConfirmationMessage = (device, updateFlowType) => {
8
+ const freshInstall = device.features.firmware_present === false;
9
+ if (freshInstall || updateFlowType === 'reboot_and_upgrade')
10
+ return;
11
+ device.emit(events_1.DEVICE.BUTTON, { device, payload: { code: 'ButtonRequest_FirmwareUpdate' } });
11
12
  };
12
13
  const postProgressMessage = (device, progress, postMessage) => {
13
14
  postMessage((0, events_1.createUiMessage)(events_1.UI.FIRMWARE_PROGRESS, {
@@ -17,9 +18,9 @@ const postProgressMessage = (device, progress, postMessage) => {
17
18
  }));
18
19
  };
19
20
  const FIRMWARE_ERASE_TIMEOUT_MILLISECONDS = 15_000;
20
- const uploadFirmware = async (typedCall, postMessage, device, { payload }) => {
21
+ const uploadFirmware = async ({ typedCall, postMessage, device, firmwareUploadRequest: { payload }, updateFlowType, }) => {
21
22
  if (device.features.major_version === 1) {
22
- postConfirmationMessage(device);
23
+ postConfirmationMessage(device, updateFlowType);
23
24
  const timeoutId = setTimeout(() => {
24
25
  postMessage((0, events_1.createUiMessage)(events_1.UI.FIRMWARE_PROGRESS_UNEXPECTED_DELAY, {}));
25
26
  }, FIRMWARE_ERASE_TIMEOUT_MILLISECONDS);
@@ -40,7 +41,7 @@ const uploadFirmware = async (typedCall, postMessage, device, { payload }) => {
40
41
  return message;
41
42
  }
42
43
  if (device.features.major_version === 2) {
43
- postConfirmationMessage(device);
44
+ postConfirmationMessage(device, updateFlowType);
44
45
  const length = payload.byteLength;
45
46
  let progress = 0;
46
47
  let response = await typedCall('FirmwareErase', ['FirmwareRequest', 'Success'], { length });
@@ -2,8 +2,8 @@ import { AbstractMethod } from '../core/AbstractMethod';
2
2
  export default class GetFeatures extends AbstractMethod<'getFeatures'> {
3
3
  init(): void;
4
4
  run(): Promise<{
5
- _passphrase_cached?: boolean | undefined;
6
5
  busy?: boolean | undefined;
6
+ _passphrase_cached?: boolean | undefined;
7
7
  homescreen_format?: "Toif" | "Jpeg" | "ToiG" | undefined;
8
8
  hide_passphrase_from_host?: boolean | undefined;
9
9
  unit_color?: number | undefined;
@@ -16,6 +16,7 @@ export default class GetFeatures extends AbstractMethod<'getFeatures'> {
16
16
  haptic_feedback?: boolean | undefined;
17
17
  recovery_type?: "NormalRecovery" | "DryRun" | "UnlockRepeatedBackup" | undefined;
18
18
  optiga_sec?: number | undefined;
19
+ soc?: number | undefined;
19
20
  vendor: string;
20
21
  major_version: number;
21
22
  minor_version: number;
@@ -23,6 +23,7 @@ export { default as changeLanguage } from './changeLanguage';
23
23
  export { default as changePin } from './changePin';
24
24
  export { default as changeWipeCode } from './changeWipeCode';
25
25
  export { default as cipherKeyValue } from './cipherKeyValue';
26
+ export { default as evoluGetNode } from './evoluGetNode';
26
27
  export { default as composeTransaction } from './composeTransaction';
27
28
  export { default as discoverAccounts } from './discoverAccounts';
28
29
  export { default as getAccountDescriptor } from './getAccountDescriptor';
@@ -48,6 +49,8 @@ export { default as setProxy } from './setProxy';
48
49
  export { default as signMessage } from './signMessage';
49
50
  export { default as signTransaction } from './signTransaction';
50
51
  export { default as unlockPath } from './unlockPath';
52
+ export { default as thpGetCredentials } from './thpGetCredentials';
53
+ export { default as thpRemoveCredentials } from './thpRemoveCredentials';
51
54
  export { default as verifyMessage } from './verifyMessage';
52
55
  export { default as wipeDevice } from './wipeDevice';
53
56
  //# sourceMappingURL=index.d.ts.map
package/lib/api/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.unlockPath = exports.signTransaction = exports.signMessage = exports.setProxy = exports.setBusy = exports.setBrightness = exports.loadDevice = exports.resetDevice = exports.requestLogin = exports.recoveryDevice = exports.pushTransaction = exports.getSettings = exports.getPublicKey = exports.getOwnershipProof = exports.getOwnershipId = exports.getNonce = exports.getFirmwareHash = exports.getFeatures = exports.getDeviceState = exports.getCoinInfo = exports.getAddress = exports.getAccountInfo = exports.getAccountDescriptor = exports.discoverAccounts = exports.composeTransaction = exports.cipherKeyValue = exports.changeWipeCode = exports.changePin = exports.changeLanguage = exports.blockchainUnsubscribeFiatRates = exports.blockchainUnsubscribe = exports.blockchainSubscribeFiatRates = exports.blockchainSubscribe = exports.blockchainSetCustomBackend = exports.blockchainGetTransactions = exports.blockchainGetFiatRatesForTimestamps = exports.blockchainEvmRpcCall = exports.blockchainGetInfo = exports.blockchainGetCurrentFiatRates = exports.blockchainGetAccountBalanceHistory = exports.blockchainEstimateFee = exports.blockchainDisconnect = exports.bleUnpair = exports.backupDevice = exports.showDeviceTutorial = exports.cancelCoinjoinAuthorization = exports.authorizeCoinjoin = exports.authenticateDevice = exports.applySettings = exports.applyFlags = void 0;
4
- exports.wipeDevice = exports.verifyMessage = void 0;
3
+ exports.signTransaction = exports.signMessage = exports.setProxy = exports.setBusy = exports.setBrightness = exports.loadDevice = exports.resetDevice = exports.requestLogin = exports.recoveryDevice = exports.pushTransaction = exports.getSettings = exports.getPublicKey = exports.getOwnershipProof = exports.getOwnershipId = exports.getNonce = exports.getFirmwareHash = exports.getFeatures = exports.getDeviceState = exports.getCoinInfo = exports.getAddress = exports.getAccountInfo = exports.getAccountDescriptor = exports.discoverAccounts = exports.composeTransaction = exports.evoluGetNode = exports.cipherKeyValue = exports.changeWipeCode = exports.changePin = exports.changeLanguage = exports.blockchainUnsubscribeFiatRates = exports.blockchainUnsubscribe = exports.blockchainSubscribeFiatRates = exports.blockchainSubscribe = exports.blockchainSetCustomBackend = exports.blockchainGetTransactions = exports.blockchainGetFiatRatesForTimestamps = exports.blockchainEvmRpcCall = exports.blockchainGetInfo = exports.blockchainGetCurrentFiatRates = exports.blockchainGetAccountBalanceHistory = exports.blockchainEstimateFee = exports.blockchainDisconnect = exports.bleUnpair = exports.backupDevice = exports.showDeviceTutorial = exports.cancelCoinjoinAuthorization = exports.authorizeCoinjoin = exports.authenticateDevice = exports.applySettings = exports.applyFlags = void 0;
4
+ exports.wipeDevice = exports.verifyMessage = exports.thpRemoveCredentials = exports.thpGetCredentials = exports.unlockPath = void 0;
5
5
  const tslib_1 = require("tslib");
6
6
  var applyFlags_1 = require("./applyFlags");
7
7
  Object.defineProperty(exports, "applyFlags", { enumerable: true, get: function () { return tslib_1.__importDefault(applyFlags_1).default; } });
@@ -53,6 +53,8 @@ var changeWipeCode_1 = require("./changeWipeCode");
53
53
  Object.defineProperty(exports, "changeWipeCode", { enumerable: true, get: function () { return tslib_1.__importDefault(changeWipeCode_1).default; } });
54
54
  var cipherKeyValue_1 = require("./cipherKeyValue");
55
55
  Object.defineProperty(exports, "cipherKeyValue", { enumerable: true, get: function () { return tslib_1.__importDefault(cipherKeyValue_1).default; } });
56
+ var evoluGetNode_1 = require("./evoluGetNode");
57
+ Object.defineProperty(exports, "evoluGetNode", { enumerable: true, get: function () { return tslib_1.__importDefault(evoluGetNode_1).default; } });
56
58
  var composeTransaction_1 = require("./composeTransaction");
57
59
  Object.defineProperty(exports, "composeTransaction", { enumerable: true, get: function () { return tslib_1.__importDefault(composeTransaction_1).default; } });
58
60
  var discoverAccounts_1 = require("./discoverAccounts");
@@ -103,6 +105,10 @@ var signTransaction_1 = require("./signTransaction");
103
105
  Object.defineProperty(exports, "signTransaction", { enumerable: true, get: function () { return tslib_1.__importDefault(signTransaction_1).default; } });
104
106
  var unlockPath_1 = require("./unlockPath");
105
107
  Object.defineProperty(exports, "unlockPath", { enumerable: true, get: function () { return tslib_1.__importDefault(unlockPath_1).default; } });
108
+ var thpGetCredentials_1 = require("./thpGetCredentials");
109
+ Object.defineProperty(exports, "thpGetCredentials", { enumerable: true, get: function () { return tslib_1.__importDefault(thpGetCredentials_1).default; } });
110
+ var thpRemoveCredentials_1 = require("./thpRemoveCredentials");
111
+ Object.defineProperty(exports, "thpRemoveCredentials", { enumerable: true, get: function () { return tslib_1.__importDefault(thpRemoveCredentials_1).default; } });
106
112
  var verifyMessage_1 = require("./verifyMessage");
107
113
  Object.defineProperty(exports, "verifyMessage", { enumerable: true, get: function () { return tslib_1.__importDefault(verifyMessage_1).default; } });
108
114
  var wipeDevice_1 = require("./wipeDevice");
@@ -34,10 +34,10 @@ export declare const createTx: (tx: $T.NEMTransaction, address_n: number[], chun
34
34
  definition: {
35
35
  name?: string | undefined;
36
36
  fee?: string | number | undefined;
37
+ networks?: number[] | undefined;
37
38
  levy?: PROTO.NEMMosaicLevy | undefined;
38
39
  divisibility?: number | undefined;
39
40
  transferable?: boolean | undefined;
40
- networks?: number[] | undefined;
41
41
  ticker?: string | undefined;
42
42
  levy_address?: string | undefined;
43
43
  levy_namespace?: string | undefined;
@@ -1,7 +1,8 @@
1
1
  import { AbstractMethod } from '../core/AbstractMethod';
2
2
  import type { CoinInfo } from '../types';
3
+ import { PushTransaction as PushTransactionSchema } from '../types/api/pushTransaction';
3
4
  type Params = {
4
- tx: string;
5
+ tx: PushTransactionSchema['tx'];
5
6
  coinInfo: CoinInfo;
6
7
  identity?: string;
7
8
  };
@@ -18,7 +18,8 @@ class PushTransaction extends AbstractMethod_1.AbstractMethod {
18
18
  throw constants_1.ERRORS.TypedError('Method_UnknownCoin');
19
19
  }
20
20
  (0, BlockchainLink_1.isBackendSupported)(coinInfo);
21
- if (coinInfo.type === 'bitcoin' && !/^[0-9A-Fa-f]*$/.test(payload.tx)) {
21
+ if (coinInfo.type === 'bitcoin' &&
22
+ (typeof payload.tx !== 'string' || !/^[0-9A-Fa-f]*$/.test(payload.tx))) {
22
23
  throw constants_1.ERRORS.TypedError('Method_InvalidParameter', 'Transaction must be hexadecimal');
23
24
  }
24
25
  this.params = {
@@ -4,6 +4,7 @@ const schema_utils_1 = require("@trezor/schema-utils");
4
4
  const utils_1 = require("@trezor/utils");
5
5
  const verifyEntropy_1 = require("../api/firmware/verifyEntropy");
6
6
  const constants_1 = require("../constants");
7
+ const errors_1 = require("../constants/errors");
7
8
  const AbstractMethod_1 = require("../core/AbstractMethod");
8
9
  const events_1 = require("../events");
9
10
  const paramsValidator_1 = require("./common/paramsValidator");
@@ -49,7 +50,7 @@ class ResetDevice extends AbstractMethod_1.AbstractMethod {
49
50
  const cmd = this.device.getCommands();
50
51
  const paths = ["m/84'/0'/0'", "m/44'/60'/0'"];
51
52
  const handleErr = (error) => {
52
- throw error.cause === 'transport-error'
53
+ throw error instanceof errors_1.TransportError
53
54
  ? error
54
55
  : constants_1.ERRORS.TypedError('Failure_EntropyCheck', error.message);
55
56
  };
@@ -18,6 +18,7 @@ export default class RippleGetAddress extends AbstractMethod<'rippleGetAddress',
18
18
  label: string;
19
19
  };
20
20
  _call({ address_n, show_display, chunkify }: Params): Promise<{
21
+ mac?: string | undefined;
21
22
  address: string;
22
23
  }>;
23
24
  run(): Promise<import("../../../types").Address | import("../../../types").Address[]>;
@@ -42,7 +42,7 @@ class SignMessage extends AbstractMethod_1.AbstractMethod {
42
42
  if (code === 'ButtonRequest_Other' && name === 'sign_message') {
43
43
  return {
44
44
  type: 'message',
45
- serializedPath: (0, pathUtils_1.getSerializedPath)(this.params.address_n.slice(0, 4)),
45
+ serializedPath: (0, pathUtils_1.getSerializedPath)(this.params.address_n),
46
46
  coin: this.coinInfo?.shortcut ?? 'BTC',
47
47
  message: this.payload.hex ? (0, formatUtils_1.hexToText)(this.payload.message) : this.payload.message,
48
48
  };
@@ -5,7 +5,7 @@ import type { RefTransaction, TransactionOptions } from '../types/api/bitcoin';
5
5
  type Params = {
6
6
  inputs: PROTO.TxInputType[];
7
7
  outputs: PROTO.TxOutputType[];
8
- paymentRequests: PROTO.TxAckPaymentRequest[];
8
+ paymentRequests: PROTO.PaymentRequest[];
9
9
  coinjoinRequest?: PROTO.CoinJoinRequest;
10
10
  refTxs?: RefTransaction[];
11
11
  addresses?: AccountAddresses;
@@ -18,6 +18,7 @@ export default class SolanaGetAddress extends AbstractMethod<'solanaGetAddress',
18
18
  label: string;
19
19
  };
20
20
  _call({ address_n, show_display, chunkify }: Params): Promise<{
21
+ mac?: string | undefined;
21
22
  address: string;
22
23
  }>;
23
24
  run(): Promise<import("../../../types").Address | import("../../../types").Address[]>;
@@ -14,12 +14,14 @@ export default class SolanaGetPublicKey extends AbstractMethod<'solanaGetPublicK
14
14
  serializedPath: string;
15
15
  } & {
16
16
  publicKey: string;
17
+ publicKeyBase58: string;
17
18
  }) | ({
18
19
  path: number[];
19
20
  publicKey: string;
20
21
  serializedPath: string;
21
22
  } & {
22
23
  publicKey: string;
24
+ publicKeyBase58: string;
23
25
  })[]>;
24
26
  }
25
27
  //# sourceMappingURL=solanaGetPublicKey.d.ts.map
@@ -1,5 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const bs58_1 = tslib_1.__importDefault(require("bs58"));
3
5
  const schema_utils_1 = require("@trezor/schema-utils");
4
6
  const AbstractMethod_1 = require("../../../core/AbstractMethod");
5
7
  const coinInfo_1 = require("../../../data/coinInfo");
@@ -48,6 +50,7 @@ class SolanaGetPublicKey extends AbstractMethod_1.AbstractMethod {
48
50
  path: batch.address_n,
49
51
  serializedPath: (0, pathUtils_1.getSerializedPath)(batch.address_n),
50
52
  publicKey: message.public_key,
53
+ publicKeyBase58: bs58_1.default.encode(Buffer.from(message.public_key, 'hex')),
51
54
  });
52
55
  if (this.hasBundle) {
53
56
  this.postMessage((0, events_1.createUiMessage)(events_1.UI.BUNDLE_PROGRESS, {
@@ -18,6 +18,7 @@ export default class StellarGetAddress extends AbstractMethod<'stellarGetAddress
18
18
  label: string;
19
19
  };
20
20
  _call({ address_n, show_display, chunkify }: Params): Promise<{
21
+ mac?: string | undefined;
21
22
  address: string;
22
23
  }>;
23
24
  run(): Promise<import("../../../types").Address | import("../../../types").Address[]>;
@@ -18,6 +18,7 @@ export default class TezosGetAddress extends AbstractMethod<'tezosGetAddress', P
18
18
  label: string;
19
19
  };
20
20
  _call({ address_n, show_display, chunkify }: Params): Promise<{
21
+ mac?: string | undefined;
21
22
  address: string;
22
23
  }>;
23
24
  run(): Promise<import("../../../types").Address | import("../../../types").Address[]>;
@@ -17,11 +17,11 @@ export declare const createTx: (address_n: number[], branch: string, operation:
17
17
  } | undefined;
18
18
  fee: string | number;
19
19
  amount: string | number;
20
+ source: Uint8Array<ArrayBufferLike>;
20
21
  destination: {
21
22
  hash: Uint8Array<ArrayBufferLike>;
22
23
  tag: number;
23
24
  };
24
- source: Uint8Array<ArrayBufferLike>;
25
25
  counter: number;
26
26
  gas_limit: number;
27
27
  storage_limit: number;
@@ -0,0 +1,10 @@
1
+ import { AbstractMethod } from '../core/AbstractMethod';
2
+ export default class ThpGetCredentials extends AbstractMethod<'thpGetCredentials'> {
3
+ init(): void;
4
+ run(): Promise<{
5
+ autoconnect: boolean;
6
+ trezor_static_public_key: string;
7
+ credential: string;
8
+ }>;
9
+ }
10
+ //# sourceMappingURL=thpGetCredentials.d.ts.map
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const constants_1 = require("../constants");
4
+ const AbstractMethod_1 = require("../core/AbstractMethod");
5
+ const DataManager_1 = require("../data/DataManager");
6
+ const thp_1 = require("../device/thp");
7
+ const events_1 = require("../events");
8
+ class ThpGetCredentials extends AbstractMethod_1.AbstractMethod {
9
+ init() {
10
+ this.allowDeviceMode = [events_1.UI.INITIALIZE, events_1.UI.SEEDLESS];
11
+ this.requiredPermissions = ['management'];
12
+ this.useDeviceState = false;
13
+ this.skipFinalReload = true;
14
+ }
15
+ async run() {
16
+ const thpState = this.device.getThpState();
17
+ if (!thpState?.handshakeCredentials) {
18
+ throw constants_1.ERRORS.TypedError('Device_ThpStateMissing');
19
+ }
20
+ const credentials = await (0, thp_1.getThpCredentials)(this.device, true);
21
+ thpState.setPairingCredentials([credentials]);
22
+ DataManager_1.DataManager.getSettings('thp')?.knownCredentials?.push(credentials);
23
+ this.device.emit(events_1.DEVICE.THP_CREDENTIALS_CHANGED, {
24
+ credentials,
25
+ staticKey: thpState.handshakeCredentials.staticKey.toString('hex'),
26
+ });
27
+ return credentials;
28
+ }
29
+ }
30
+ exports.default = ThpGetCredentials;
31
+ //# sourceMappingURL=thpGetCredentials.js.map
@@ -0,0 +1,8 @@
1
+ import { AbstractMethod } from '../core/AbstractMethod';
2
+ export default class ThpRemoveCredentials extends AbstractMethod<'thpRemoveCredentials'> {
3
+ init(): void;
4
+ run(): Promise<{
5
+ message: string;
6
+ }>;
7
+ }
8
+ //# sourceMappingURL=thpRemoveCredentials.d.ts.map
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const constants_1 = require("../constants");
4
+ const AbstractMethod_1 = require("../core/AbstractMethod");
5
+ const DataManager_1 = require("../data/DataManager");
6
+ const events_1 = require("../events");
7
+ class ThpRemoveCredentials extends AbstractMethod_1.AbstractMethod {
8
+ init() {
9
+ this.allowDeviceMode = [events_1.UI.INITIALIZE, events_1.UI.SEEDLESS];
10
+ this.requiredPermissions = ['management'];
11
+ this.useDeviceState = false;
12
+ this.skipFinalReload = true;
13
+ }
14
+ run() {
15
+ const thpState = this.device.getThpState();
16
+ if (!thpState) {
17
+ throw constants_1.ERRORS.TypedError('Device_ThpStateMissing');
18
+ }
19
+ const knownCredentials = DataManager_1.DataManager.getSettings('thp')?.knownCredentials;
20
+ if (knownCredentials) {
21
+ const toRemoveCredentials = (this.payload.credentials || thpState.pairingCredentials).map(c => c.credential);
22
+ const index = knownCredentials.findIndex(({ credential }) => toRemoveCredentials.includes(credential));
23
+ if (index >= 0) {
24
+ knownCredentials.splice(index, 1);
25
+ }
26
+ }
27
+ thpState.resetState();
28
+ return Promise.resolve({ message: 'Success' });
29
+ }
30
+ }
31
+ exports.default = ThpRemoveCredentials;
32
+ //# sourceMappingURL=thpRemoveCredentials.js.map
@@ -8,7 +8,7 @@ class WipeDevice extends AbstractMethod_1.AbstractMethod {
8
8
  this.allowDeviceMode = [events_1.UI.INITIALIZE, events_1.UI.SEEDLESS, events_1.UI.BOOTLOADER];
9
9
  this.useDeviceState = false;
10
10
  this.requiredPermissions = ['management'];
11
- this.skipFinalReload = false;
11
+ this.skipFinalReload = this.payload.skipFinalReload ?? false;
12
12
  this.firmwareRange = (0, paramsValidator_1.getFirmwareRange)(this.name, null, this.firmwareRange);
13
13
  }
14
14
  get confirmation() {
@@ -16,7 +16,7 @@ class WipeDevice extends AbstractMethod_1.AbstractMethod {
16
16
  view: 'device-management',
17
17
  customConfirmButton: {
18
18
  className: 'wipe',
19
- label: `Wipe ${this.device.toMessageObject().label}`,
19
+ label: `Wipe`,
20
20
  },
21
21
  label: 'Are you sure you want to wipe your device?',
22
22
  };
@@ -33,6 +33,10 @@ class WipeDevice extends AbstractMethod_1.AbstractMethod {
33
33
  });
34
34
  }
35
35
  const response = await cmd.typedCall('WipeDevice', 'Success');
36
+ const thpState = this.device.getThpState();
37
+ if (thpState) {
38
+ thpState.resetState();
39
+ }
36
40
  return response.message;
37
41
  }
38
42
  }
@@ -1,7 +1,7 @@
1
1
  import BlockchainLink, { BlockchainLinkParams, ServerInfo, SubscriptionAccountInfo } from '@trezor/blockchain-link';
2
- import { ERRORS } from '../constants';
3
2
  import { CoreEventMessage } from '../events';
4
3
  import type { CoinInfo, Proxy } from '../types';
4
+ import { PushTransaction } from '../types/api/pushTransaction';
5
5
  export type BlockchainOptions = {
6
6
  coinInfo: CoinInfo;
7
7
  postMessage: (message: CoreEventMessage) => void;
@@ -11,7 +11,7 @@ export type BlockchainOptions = {
11
11
  onDisconnected?: (pendingSubscriptions?: boolean) => void;
12
12
  };
13
13
  export declare class Blockchain {
14
- link: BlockchainLink;
14
+ readonly link: BlockchainLink;
15
15
  serverInfo?: ServerInfo;
16
16
  readonly identity?: string;
17
17
  readonly coinInfo: BlockchainOptions['coinInfo'];
@@ -19,7 +19,7 @@ export declare class Blockchain {
19
19
  private onDisconnected;
20
20
  private initPromise?;
21
21
  constructor(options: BlockchainOptions);
22
- onError(error: ERRORS.TrezorError): void;
22
+ private onBackendDisconnected;
23
23
  private initLink;
24
24
  init(): Promise<ServerInfo>;
25
25
  getTransactions(txs: string[]): Promise<import("@trezor/blockchain-link").Transaction[]>;
@@ -76,7 +76,7 @@ export declare class Blockchain {
76
76
  unsubscribeAll(): Promise<{
77
77
  subscribed: boolean;
78
78
  }>;
79
- pushTransaction(tx: string): Promise<string>;
79
+ pushTransaction(tx: PushTransaction['tx']): Promise<string>;
80
80
  disconnect(): void;
81
81
  }
82
82
  //# sourceMappingURL=Blockchain.d.ts.map
@@ -64,16 +64,12 @@ class Blockchain {
64
64
  : {}),
65
65
  });
66
66
  }
67
- onError(error) {
68
- const pendingSubscriptions = this.link.listenerCount('block') ||
69
- this.link.listenerCount('notification') ||
70
- this.link.listenerCount('fiatRates');
71
- this.link.dispose();
67
+ onBackendDisconnected(pendingSubscriptions = false) {
72
68
  this.postMessage((0, events_1.createBlockchainMessage)(events_1.BLOCKCHAIN.ERROR, {
73
69
  coin: this.coinInfo,
74
70
  identity: this.identity,
75
- error: error.message,
76
- code: error.code,
71
+ error: constants_1.ERRORS.ERROR_CODES.Backend_Disconnected,
72
+ code: 'Backend_Disconnected',
77
73
  }));
78
74
  this.onDisconnected?.(!!pendingSubscriptions);
79
75
  }
@@ -93,7 +89,11 @@ class Blockchain {
93
89
  throw constants_1.ERRORS.TypedError('Backend_Invalid');
94
90
  }
95
91
  this.link.on('disconnected', () => {
96
- this.onError(constants_1.ERRORS.TypedError('Backend_Disconnected'));
92
+ const pendingSubscriptions = this.link.listenerCount('block') ||
93
+ this.link.listenerCount('notification') ||
94
+ this.link.listenerCount('fiatRates');
95
+ this.link.dispose();
96
+ this.onBackendDisconnected(!!pendingSubscriptions);
97
97
  });
98
98
  return info;
99
99
  }
@@ -208,12 +208,13 @@ class Blockchain {
208
208
  return this.unsubscribeBlocks();
209
209
  }
210
210
  pushTransaction(tx) {
211
- return this.link.pushTransaction(tx);
211
+ const data = typeof tx === 'string' ? { hex: tx } : tx;
212
+ return this.link.pushTransaction(data);
212
213
  }
213
214
  disconnect() {
214
215
  this.link.removeAllListeners();
215
- this.link.disconnect();
216
- this.onError(constants_1.ERRORS.TypedError('Backend_Disconnected'));
216
+ this.link.disconnect().then(() => this.link.dispose());
217
+ this.onBackendDisconnected();
217
218
  }
218
219
  }
219
220
  exports.Blockchain = Blockchain;
@@ -8,4 +8,7 @@ export declare enum NETWORK_IDS {
8
8
  mainnet = 1,
9
9
  testnet = 0
10
10
  }
11
+ export declare enum ALGORITHM_IDS {
12
+ EdDSA = -8
13
+ }
11
14
  //# sourceMappingURL=cardano.d.ts.map
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NETWORK_IDS = exports.PROTOCOL_MAGICS = void 0;
3
+ exports.ALGORITHM_IDS = exports.NETWORK_IDS = exports.PROTOCOL_MAGICS = void 0;
4
4
  var PROTOCOL_MAGICS;
5
5
  (function (PROTOCOL_MAGICS) {
6
6
  PROTOCOL_MAGICS[PROTOCOL_MAGICS["mainnet"] = 764824073] = "mainnet";
@@ -13,4 +13,8 @@ var NETWORK_IDS;
13
13
  NETWORK_IDS[NETWORK_IDS["mainnet"] = 1] = "mainnet";
14
14
  NETWORK_IDS[NETWORK_IDS["testnet"] = 0] = "testnet";
15
15
  })(NETWORK_IDS || (exports.NETWORK_IDS = NETWORK_IDS = {}));
16
+ var ALGORITHM_IDS;
17
+ (function (ALGORITHM_IDS) {
18
+ ALGORITHM_IDS[ALGORITHM_IDS["EdDSA"] = -8] = "EdDSA";
19
+ })(ALGORITHM_IDS || (exports.ALGORITHM_IDS = ALGORITHM_IDS = {}));
16
20
  //# sourceMappingURL=cardano.js.map