@trezor/connect 9.6.3 → 9.6.4-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 (163) hide show
  1. package/CHANGELOG.md +18 -9
  2. package/README.md +1 -1
  3. package/lib/api/applyFlags.d.ts +1 -1
  4. package/lib/api/applyFlags.js +2 -2
  5. package/lib/api/applySettings.d.ts +1 -1
  6. package/lib/api/authenticateDevice.js +4 -0
  7. package/lib/api/authorizeCoinjoin.d.ts +1 -1
  8. package/lib/api/backupDevice.d.ts +1 -1
  9. package/lib/api/backupDevice.js +2 -2
  10. package/lib/api/bitcoin/TransactionComposer.d.ts +1 -1
  11. package/lib/api/bitcoin/inputs.d.ts +1 -1
  12. package/lib/api/bitcoin/transactionBytes.d.ts +2 -2
  13. package/lib/api/bleUnpair.js +1 -1
  14. package/lib/api/cancelCoinjoinAuthorization.d.ts +1 -1
  15. package/lib/api/cardano/api/cardanoSignTransaction.d.ts +2 -2
  16. package/lib/api/cardano/cardanoInputs.js +2 -2
  17. package/lib/api/changePin.d.ts +1 -1
  18. package/lib/api/changePin.js +2 -2
  19. package/lib/api/changeWipeCode.d.ts +1 -1
  20. package/lib/api/cipherKeyValue.d.ts +1 -1
  21. package/lib/api/eos/api/eosGetPublicKey.d.ts +1 -1
  22. package/lib/api/eos/api/eosSignTransaction.d.ts +1 -1
  23. package/lib/api/eos/eosSignTx.d.ts +20 -20
  24. package/lib/api/ethereum/api/ethereumGetPublicKey.d.ts +5 -5
  25. package/lib/api/ethereum/api/ethereumSignMessage.d.ts +1 -2
  26. package/lib/api/ethereum/api/ethereumVerifyMessage.d.ts +1 -1
  27. package/lib/api/evoluGetNode.d.ts +1 -1
  28. package/lib/api/evoluGetNode.js +2 -2
  29. package/lib/api/firmware/calculateFirmwareHash.d.ts +9 -2
  30. package/lib/api/firmware/calculateFirmwareHash.js +11 -1
  31. package/lib/api/firmware/verifyAuthenticityProof.d.ts +3 -1
  32. package/lib/api/firmware/verifyAuthenticityProof.js +10 -15
  33. package/lib/api/getCoinInfo.d.ts +34 -34
  34. package/lib/api/getFeatures.d.ts +1 -0
  35. package/lib/api/getFirmwareHash.d.ts +1 -1
  36. package/lib/api/getFirmwareHash.js +2 -2
  37. package/lib/api/getNonce.d.ts +1 -1
  38. package/lib/api/getOwnershipId.d.ts +1 -1
  39. package/lib/api/getOwnershipId.js +2 -2
  40. package/lib/api/getOwnershipProof.d.ts +1 -1
  41. package/lib/api/getOwnershipProof.js +2 -2
  42. package/lib/api/getPublicKey.d.ts +5 -5
  43. package/lib/api/loadDevice.d.ts +1 -1
  44. package/lib/api/loadDevice.js +2 -2
  45. package/lib/api/nem/api/nemSignTransaction.d.ts +1 -1
  46. package/lib/api/nem/nemSignTx.d.ts +9 -9
  47. package/lib/api/recoveryDevice.d.ts +1 -1
  48. package/lib/api/requestLogin.d.ts +1 -1
  49. package/lib/api/ripple/api/rippleSignTransaction.d.ts +1 -1
  50. package/lib/api/setBrightness.d.ts +1 -1
  51. package/lib/api/setBrightness.js +2 -2
  52. package/lib/api/setBusy.d.ts +1 -1
  53. package/lib/api/setBusy.js +2 -2
  54. package/lib/api/showDeviceTutorial.d.ts +1 -1
  55. package/lib/api/signMessage.d.ts +1 -1
  56. package/lib/api/solana/api/solanaComposeTransaction.d.ts +6 -0
  57. package/lib/api/solana/api/solanaComposeTransaction.js +9 -0
  58. package/lib/api/solana/api/solanaSignTransaction.js +4 -4
  59. package/lib/api/tezos/api/tezosGetPublicKey.d.ts +1 -1
  60. package/lib/api/tezos/api/tezosSignTransaction.d.ts +1 -1
  61. package/lib/api/tezos/tezosSignTx.d.ts +17 -17
  62. package/lib/api/unlockPath.d.ts +1 -1
  63. package/lib/core/AbstractMethod.d.ts +4 -1
  64. package/lib/core/index.js +8 -1
  65. package/lib/core/onCallFirmwareUpdate.js +42 -51
  66. package/lib/data/coinInfo.d.ts +94 -93
  67. package/lib/data/config.js +9 -1
  68. package/lib/data/defaultFeeLevels.d.ts +1 -1
  69. package/lib/data/defaultFeeLevels.js +1 -1
  70. package/lib/data/deviceAuthenticityBlacklist.d.ts +3 -0
  71. package/lib/data/deviceAuthenticityBlacklist.js +11 -0
  72. package/lib/data/deviceAuthenticityBlacklistConfig.d.ts +11 -0
  73. package/lib/data/deviceAuthenticityBlacklistConfig.js +15 -0
  74. package/lib/data/deviceAuthenticityConfig.js +4 -140
  75. package/lib/data/deviceAuthenticityConfigTypes.d.ts +0 -9
  76. package/lib/data/deviceAuthenticityConfigTypes.js +3 -5
  77. package/lib/data/firmwareInfo.d.ts +12 -7
  78. package/lib/data/firmwareInfo.js +58 -15
  79. package/lib/data/transportInfo.d.ts +11 -1
  80. package/lib/data/udevInfo.d.ts +9 -1
  81. package/lib/data/version.d.ts +1 -1
  82. package/lib/data/version.js +1 -1
  83. package/lib/device/Device.d.ts +20 -10
  84. package/lib/device/Device.js +95 -23
  85. package/lib/device/DeviceCommands.d.ts +4 -4
  86. package/lib/device/DeviceCurrentSession.d.ts +242 -242
  87. package/lib/device/DeviceCurrentSession.js +1 -1
  88. package/lib/device/DeviceList.d.ts +7 -4
  89. package/lib/device/DeviceList.js +14 -4
  90. package/lib/device/StateStorage.d.ts +1 -1
  91. package/lib/device/checkFirmwareRevision.d.ts +1 -1
  92. package/lib/device/checkFirmwareRevision.js +2 -2
  93. package/lib/device/thp/handshake.d.ts +1 -1
  94. package/lib/device/thp/handshake.js +14 -3
  95. package/lib/device/thp/index.d.ts +1 -1
  96. package/lib/device/thp/index.js +29 -4
  97. package/lib/device/thp/pairing.js +1 -3
  98. package/lib/device/thp/session.js +1 -1
  99. package/lib/device/workflow/checkFirmwareHash.js +6 -1
  100. package/lib/device/workflow/handshake.js +3 -7
  101. package/lib/device/workflow/trezorPushNotification.d.ts +3 -0
  102. package/lib/device/workflow/trezorPushNotification.js +76 -0
  103. package/lib/device/workflow/validateState.js +3 -0
  104. package/lib/events/call.d.ts +1 -1
  105. package/lib/events/device.d.ts +11 -3
  106. package/lib/events/device.js +5 -1
  107. package/lib/events/popup.d.ts +1 -1
  108. package/lib/events/transport.d.ts +3 -21
  109. package/lib/events/ui-request.d.ts +15 -8
  110. package/lib/tsconfig.lib.tsbuildinfo +1 -1
  111. package/lib/types/api/applyFlags.d.ts +1 -1
  112. package/lib/types/api/applySettings.d.ts +1 -0
  113. package/lib/types/api/authenticateDevice.d.ts +9 -10
  114. package/lib/types/api/authenticateDevice.js +2 -0
  115. package/lib/types/api/backupDevice.d.ts +1 -1
  116. package/lib/types/api/bitcoin/index.d.ts +1 -1
  117. package/lib/types/api/bleUnpair.d.ts +1 -1
  118. package/lib/types/api/cancelCoinjoinAuthorization.d.ts +1 -1
  119. package/lib/types/api/cardanoComposeTransaction.d.ts +2 -2
  120. package/lib/types/api/cardanoComposeTransaction.js +2 -2
  121. package/lib/types/api/changePin.d.ts +1 -1
  122. package/lib/types/api/changeWipeCode.d.ts +1 -1
  123. package/lib/types/api/composeTransaction.d.ts +1 -1
  124. package/lib/types/api/discoverAccounts.d.ts +1 -1
  125. package/lib/types/api/discoverAccounts.js +1 -1
  126. package/lib/types/api/eosSignTransaction.d.ts +1 -1
  127. package/lib/types/api/ethereum/index.d.ts +8 -8
  128. package/lib/types/api/ethereumSignMessage.d.ts +1 -1
  129. package/lib/types/api/ethereumSignTypedData.d.ts +1 -1
  130. package/lib/types/api/ethereumVerifyMessage.d.ts +1 -1
  131. package/lib/types/api/getAccountInfo.d.ts +1 -1
  132. package/lib/types/api/getAddress.d.ts +6 -6
  133. package/lib/types/api/getFirmwareHash.d.ts +1 -1
  134. package/lib/types/api/nemGetAddress.d.ts +1 -1
  135. package/lib/types/api/nemSignTransaction.d.ts +1 -1
  136. package/lib/types/api/recoveryDevice.d.ts +2 -2
  137. package/lib/types/api/setBusy.d.ts +1 -1
  138. package/lib/types/api/setProxy.d.ts +1 -1
  139. package/lib/types/api/showDeviceTutorial.d.ts +1 -1
  140. package/lib/types/api/signMessage.d.ts +1 -1
  141. package/lib/types/api/solana/index.d.ts +26 -3
  142. package/lib/types/api/solana/index.js +19 -3
  143. package/lib/types/api/tezosSignTransaction.d.ts +1 -1
  144. package/lib/types/api/thpRemoveCredentials.d.ts +1 -1
  145. package/lib/types/api/unlockPath.d.ts +1 -1
  146. package/lib/types/api/verifyMessage.d.ts +1 -1
  147. package/lib/types/api/wipeDevice.d.ts +1 -1
  148. package/lib/types/device.d.ts +9 -4
  149. package/lib/types/device.js +5 -3
  150. package/lib/types/firmware.d.ts +1 -0
  151. package/lib/types/settings.d.ts +2 -2
  152. package/lib/types/workflow.d.ts +4 -0
  153. package/lib/utils/assetUtils.d.ts +6 -4
  154. package/lib/utils/assetUtils.js +13 -2
  155. package/lib/utils/assets-browser.d.ts +0 -4
  156. package/lib/utils/assets-browser.js +3 -11
  157. package/lib/utils/assets.native.js +1 -1
  158. package/lib/utils/deviceFeaturesUtils.d.ts +1 -1
  159. package/lib/utils/firmwareUtils.d.ts +7 -4
  160. package/lib/utils/firmwareUtils.js +21 -14
  161. package/lib/utils/pathUtils.d.ts +3 -2
  162. package/lib/utils/uiPromiseManager.d.ts +9 -9
  163. package/package.json +13 -12
package/CHANGELOG.md CHANGED
@@ -1,16 +1,25 @@
1
- | Package | Stable | Canary |
2
- | :------------------------------: | :----: | :----: |
3
- | npm @trezor/connect | 9.6.3 | - |
4
- | npm @trezor/connect-web | 9.6.3 | - |
5
- | npm @trezor/connect-webextension | 9.6.3 | - |
6
- | npm @trezor/connect-mobile | 9.6.3 | - |
1
+ | Package | Stable | Canary |
2
+ | :------------------------------: | :----: | :----------: |
3
+ | npm @trezor/connect | 9.6.3 | 9.6.4-beta.1 |
4
+ | npm @trezor/connect-web | 9.6.3 | 9.6.4-beta.1 |
5
+ | npm @trezor/connect-webextension | 9.6.3 | 9.6.4-beta.1 |
6
+ | npm @trezor/connect-mobile | 9.6.3 | 9.6.4-beta.1 |
7
7
 
8
- | Deployment | Stable | Canary |
9
- | :----------------: | :----: | :----: |
10
- | connect.trezor.io/ | 9.6.3 | - |
8
+ | Deployment | Stable | Canary |
9
+ | :----------------: | :----: | :----------: |
10
+ | connect.trezor.io/ | 9.6.3 | 9.6.4-beta.1 |
11
11
 
12
12
  Use the persistent link [connect.trezor.io/9](https://connect.trezor.io/9/) to access the latest stable version of Connect Explorer.
13
13
 
14
+ # 9.6.4-beta.1
15
+
16
+ This release primarily introduces support for the new Trezor device and enhancements to the transport API, including a new API type:
17
+
18
+ - feat(connect): Expose API type and ID on descriptor (ed650e3)
19
+ - feat(connect): Add additional variants of DeviceStatus = 'busy' (34d888e)
20
+
21
+ In addition, this release includes various bug fixes, refactorings, and chores.
22
+
14
23
  # 9.6.3
15
24
 
16
25
  We’ve added support for Cardano message signing based on the CIP-8 standard, available through the new cardanoSignMessage method.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @trezor/connect
2
2
 
3
- API version 9.6.3
3
+ API version 9.6.4-beta.1
4
4
 
5
5
  [![Build Status](https://github.com/trezor/trezor-suite/actions/workflows/test-connect.yml/badge.svg)](https://github.com/trezor/trezor-suite/actions/workflows/test-connect.yml)
6
6
  [![NPM](https://img.shields.io/npm/v/@trezor/connect.svg)](https://www.npmjs.org/package/@trezor/connect)
@@ -1,4 +1,4 @@
1
- import { PROTO } from '../constants';
1
+ import { MessagesSchema as PROTO } from '@trezor/protobuf';
2
2
  import { AbstractMethod } from '../core/AbstractMethod';
3
3
  export default class ApplyFlags extends AbstractMethod<'applyFlags', PROTO.ApplyFlags> {
4
4
  init(): void;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ const protobuf_1 = require("@trezor/protobuf");
3
4
  const schema_utils_1 = require("@trezor/schema-utils");
4
- const constants_1 = require("../constants");
5
5
  const AbstractMethod_1 = require("../core/AbstractMethod");
6
6
  class ApplyFlags extends AbstractMethod_1.AbstractMethod {
7
7
  init() {
@@ -9,7 +9,7 @@ class ApplyFlags extends AbstractMethod_1.AbstractMethod {
9
9
  this.useDeviceState = false;
10
10
  this.skipFinalReload = false;
11
11
  const { payload } = this;
12
- (0, schema_utils_1.Assert)(constants_1.PROTO.ApplyFlags, payload);
12
+ (0, schema_utils_1.Assert)(protobuf_1.MessagesSchema.ApplyFlags, payload);
13
13
  this.params = {
14
14
  flags: payload.flags,
15
15
  };
@@ -1,4 +1,4 @@
1
- import { PROTO } from '../constants';
1
+ import { MessagesSchema as PROTO } from '@trezor/protobuf';
2
2
  import { AbstractMethod } from '../core/AbstractMethod';
3
3
  export default class ApplySettings extends AbstractMethod<'applySettings', PROTO.ApplySettings> {
4
4
  init(): void;
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const schema_utils_1 = require("@trezor/schema-utils");
4
4
  const AbstractMethod_1 = require("../core/AbstractMethod");
5
+ const deviceAuthenticityBlacklist_1 = require("../data/deviceAuthenticityBlacklist");
5
6
  const events_1 = require("../events");
6
7
  const paramsValidator_1 = require("./common/paramsValidator");
7
8
  const deviceAuthenticityConfig_1 = require("../data/deviceAuthenticityConfig");
@@ -19,6 +20,7 @@ class AuthenticateDevice extends AbstractMethod_1.AbstractMethod {
19
20
  (0, schema_utils_1.Assert)(authenticateDevice_1.AuthenticateDeviceParams, payload);
20
21
  this.params = {
21
22
  config: payload.config,
23
+ blacklistConfig: payload.blacklistConfig,
22
24
  allowDebugKeys: payload.allowDebugKeys,
23
25
  };
24
26
  }
@@ -30,10 +32,12 @@ class AuthenticateDevice extends AbstractMethod_1.AbstractMethod {
30
32
  challenge: challenge.toString('hex'),
31
33
  });
32
34
  const config = this.params.config || deviceAuthenticityConfig_1.deviceAuthenticityConfig;
35
+ const blacklistConfig = this.params.blacklistConfig || deviceAuthenticityBlacklist_1.deviceAuthenticityBlacklist;
33
36
  const valid = await (0, verifyAuthenticityProof_1.verifyAuthenticityProof)({
34
37
  ...message,
35
38
  challenge,
36
39
  config,
40
+ blacklistConfig,
37
41
  allowDebugKeys: this.params.allowDebugKeys,
38
42
  deviceModel: this.device.features.internal_model,
39
43
  });
@@ -1,4 +1,4 @@
1
- import { PROTO } from '../constants';
1
+ import { MessagesSchema as PROTO } from '@trezor/protobuf';
2
2
  import { AbstractMethod } from '../core/AbstractMethod';
3
3
  export default class AuthorizeCoinjoin extends AbstractMethod<'authorizeCoinjoin', PROTO.AuthorizeCoinJoin> {
4
4
  init(): void;
@@ -1,4 +1,4 @@
1
- import { PROTO } from '../constants';
1
+ import { MessagesSchema as PROTO } from '@trezor/protobuf';
2
2
  import { AbstractMethod } from '../core/AbstractMethod';
3
3
  export default class BackupDevice extends AbstractMethod<'backupDevice', PROTO.BackupDevice> {
4
4
  init(): void;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ const protobuf_1 = require("@trezor/protobuf");
3
4
  const schema_utils_1 = require("@trezor/schema-utils");
4
- const constants_1 = require("../constants");
5
5
  const AbstractMethod_1 = require("../core/AbstractMethod");
6
6
  class BackupDevice extends AbstractMethod_1.AbstractMethod {
7
7
  init() {
@@ -9,7 +9,7 @@ class BackupDevice extends AbstractMethod_1.AbstractMethod {
9
9
  this.skipFinalReload = false;
10
10
  this.useDeviceState = false;
11
11
  const { payload } = this;
12
- (0, schema_utils_1.Assert)(constants_1.PROTO.BackupDevice, payload);
12
+ (0, schema_utils_1.Assert)(protobuf_1.MessagesSchema.BackupDevice, payload);
13
13
  this.params = {
14
14
  group_threshold: payload.group_threshold,
15
15
  groups: payload.groups,
@@ -34,8 +34,8 @@ export declare class TransactionComposer {
34
34
  fee: "0";
35
35
  disabled: true;
36
36
  } | {
37
- blocks: number;
38
37
  name: string;
38
+ blocks: number;
39
39
  fee: string;
40
40
  feePerByte: string;
41
41
  minutes: number;
@@ -1,5 +1,5 @@
1
+ import { MessagesSchema as PROTO } from '@trezor/protobuf';
1
2
  import { Transaction as BitcoinJsTransaction } from '@trezor/utxo-lib';
2
- import type { PROTO } from '../../constants';
3
3
  import type { BitcoinNetworkInfo, ProtoWithDerivationPath } from '../../types';
4
4
  import type { ComposeUtxo } from '../../types/api/composeTransaction';
5
5
  export declare const validateTrezorInputs: (inputs: ProtoWithDerivationPath<PROTO.TxInputType>[], coinInfo: BitcoinNetworkInfo) => PROTO.TxInputType[];
@@ -1,5 +1,5 @@
1
1
  import { PROTO } from '../../constants';
2
- import { BitcoinNetworkInfo } from '../../exports';
3
- export declare function mapOutputScriptToKey(script_type: string): "p2pkh" | "p2sh" | "p2tr" | "p2wpkh" | undefined;
2
+ import { BitcoinNetworkInfo } from '../../types';
3
+ export declare function mapOutputScriptToKey(script_type: string): "p2tr" | "p2wpkh" | "p2sh" | "p2pkh" | undefined;
4
4
  export declare const getTransactionVbytes: (inputs: PROTO.TxInputType[], outputs: PROTO.TxOutputType[], coinInfo: BitcoinNetworkInfo) => number | undefined;
5
5
  //# sourceMappingURL=transactionBytes.d.ts.map
@@ -24,7 +24,7 @@ class BleUnpair extends AbstractMethod_1.AbstractMethod {
24
24
  return response.message;
25
25
  }
26
26
  catch (error) {
27
- if (this.device.bluetoothProps &&
27
+ if (this.device.descriptor.apiType === 'bluetooth' &&
28
28
  error.message === transport_1.TRANSPORT_ERROR.INTERFACE_DATA_TRANSFER) {
29
29
  throw constants_1.ERRORS.TypedError('Device_Disconnected');
30
30
  }
@@ -1,4 +1,4 @@
1
- import { PROTO } from '../constants';
1
+ import { MessagesSchema as PROTO } from '@trezor/protobuf';
2
2
  import { AbstractMethod } from '../core/AbstractMethod';
3
3
  export default class CancelCoinjoinAuthorization extends AbstractMethod<'cancelCoinjoinAuthorization', PROTO.CancelAuthorization> {
4
4
  init(): void;
@@ -56,8 +56,8 @@ export default class CardanoSignTransaction extends AbstractMethod<'cardanoSignT
56
56
  witnesses: {
57
57
  chainCode?: string | undefined;
58
58
  type: PROTO.CardanoTxWitnessType;
59
- pubKey: string;
60
59
  signature: string;
60
+ pubKey: string;
61
61
  }[];
62
62
  } | {
63
63
  serializedTx: string;
@@ -70,8 +70,8 @@ export default class CardanoSignTransaction extends AbstractMethod<'cardanoSignT
70
70
  witnesses: {
71
71
  chainCode?: string | undefined;
72
72
  type: PROTO.CardanoTxWitnessType;
73
- pubKey: string;
74
73
  signature: string;
74
+ pubKey: string;
75
75
  }[];
76
76
  }>;
77
77
  }
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.transformReferenceInput = exports.transformCollateralInput = exports.transformInput = exports.InputWithPathParam = exports.InputWithPath = exports.Path = void 0;
4
4
  const schema_utils_1 = require("@trezor/schema-utils");
5
5
  const constants_1 = require("../../constants");
6
- const exports_1 = require("../../exports");
6
+ const types_1 = require("../../types");
7
7
  const pathUtils_1 = require("../../utils/pathUtils");
8
8
  exports.Path = schema_utils_1.Type.Array(schema_utils_1.Type.Number());
9
9
  exports.InputWithPath = schema_utils_1.Type.Object({
@@ -13,7 +13,7 @@ exports.InputWithPath = schema_utils_1.Type.Object({
13
13
  exports.InputWithPathParam = schema_utils_1.Type.Composite([
14
14
  constants_1.PROTO.CardanoTxInput,
15
15
  schema_utils_1.Type.Object({
16
- path: schema_utils_1.Type.Optional(exports_1.DerivationPath),
16
+ path: schema_utils_1.Type.Optional(types_1.DerivationPath),
17
17
  }),
18
18
  ]);
19
19
  const transformInput = (input) => {
@@ -1,4 +1,4 @@
1
- import { PROTO } from '../constants';
1
+ import { MessagesSchema as PROTO } from '@trezor/protobuf';
2
2
  import { AbstractMethod } from '../core/AbstractMethod';
3
3
  export default class ChangePin extends AbstractMethod<'changePin', PROTO.ChangePin> {
4
4
  init(): void;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ const protobuf_1 = require("@trezor/protobuf");
3
4
  const schema_utils_1 = require("@trezor/schema-utils");
4
- const constants_1 = require("../constants");
5
5
  const AbstractMethod_1 = require("../core/AbstractMethod");
6
6
  class ChangePin extends AbstractMethod_1.AbstractMethod {
7
7
  init() {
@@ -9,7 +9,7 @@ class ChangePin extends AbstractMethod_1.AbstractMethod {
9
9
  this.useDeviceState = false;
10
10
  this.skipFinalReload = false;
11
11
  const { payload } = this;
12
- (0, schema_utils_1.Assert)(constants_1.PROTO.ChangePin, payload);
12
+ (0, schema_utils_1.Assert)(protobuf_1.MessagesSchema.ChangePin, payload);
13
13
  this.params = {
14
14
  remove: payload.remove,
15
15
  };
@@ -1,4 +1,4 @@
1
- import type { PROTO } from '../constants';
1
+ import { MessagesSchema as PROTO } from '@trezor/protobuf';
2
2
  import { AbstractMethod } from '../core/AbstractMethod';
3
3
  export default class ChangeWipeCode extends AbstractMethod<'changeWipeCode', PROTO.ChangeWipeCode> {
4
4
  init(): void;
@@ -1,4 +1,4 @@
1
- import type { PROTO } from '../constants';
1
+ import { MessagesSchema as PROTO } from '@trezor/protobuf';
2
2
  import { AbstractMethod } from '../core/AbstractMethod';
3
3
  export default class CipherKeyValue extends AbstractMethod<'cipherKeyValue', PROTO.CipherKeyValue[]> {
4
4
  hasBundle?: boolean;
@@ -1,4 +1,4 @@
1
- import type { PROTO } from '../../../constants';
1
+ import { MessagesSchema as PROTO } from '@trezor/protobuf';
2
2
  import { AbstractMethod } from '../../../core/AbstractMethod';
3
3
  export default class EosGetPublicKey extends AbstractMethod<'eosGetPublicKey', PROTO.EosGetPublicKey[]> {
4
4
  hasBundle?: boolean;
@@ -1,4 +1,4 @@
1
- import type { PROTO } from '../../../constants';
1
+ import { MessagesSchema as PROTO } from '@trezor/protobuf';
2
2
  import { AbstractMethod } from '../../../core/AbstractMethod';
3
3
  type Params = {
4
4
  path: number[];
@@ -17,21 +17,17 @@ export declare const validate: (tx: EosSDKTransaction) => {
17
17
  data_chunk: string;
18
18
  } | undefined;
19
19
  transfer?: {
20
+ sender: string;
21
+ receiver: string;
20
22
  quantity: {
21
23
  symbol: string;
22
24
  amount: string | number;
23
25
  };
24
26
  memo: string;
25
- receiver: string;
26
- sender: string;
27
- } | undefined;
28
- refund?: {
29
- owner: string;
30
27
  } | undefined;
31
28
  delegate?: {
32
- transfer: boolean;
33
- receiver: string;
34
29
  sender: string;
30
+ receiver: string;
35
31
  net_quantity: {
36
32
  symbol: string;
37
33
  amount: string | number;
@@ -40,10 +36,11 @@ export declare const validate: (tx: EosSDKTransaction) => {
40
36
  symbol: string;
41
37
  amount: string | number;
42
38
  };
39
+ transfer: boolean;
43
40
  } | undefined;
44
41
  undelegate?: {
45
- receiver: string;
46
42
  sender: string;
43
+ receiver: string;
47
44
  net_quantity: {
48
45
  symbol: string;
49
46
  amount: string | number;
@@ -53,22 +50,25 @@ export declare const validate: (tx: EosSDKTransaction) => {
53
50
  amount: string | number;
54
51
  };
55
52
  } | undefined;
53
+ refund?: {
54
+ owner: string;
55
+ } | undefined;
56
56
  buy_ram?: {
57
+ receiver: string;
57
58
  quantity: {
58
59
  symbol: string;
59
60
  amount: string | number;
60
61
  };
61
- receiver: string;
62
62
  payer: string;
63
63
  } | undefined;
64
64
  buy_ram_bytes?: {
65
- bytes: number;
66
65
  receiver: string;
67
66
  payer: string;
67
+ bytes: number;
68
68
  } | undefined;
69
69
  sell_ram?: {
70
- bytes: number;
71
70
  account: string;
71
+ bytes: number;
72
72
  } | undefined;
73
73
  vote_producer?: {
74
74
  voter: string;
@@ -76,13 +76,13 @@ export declare const validate: (tx: EosSDKTransaction) => {
76
76
  producers: string[];
77
77
  } | undefined;
78
78
  update_auth?: {
79
- account: string;
80
79
  permission: string;
80
+ account: string;
81
81
  parent: string;
82
82
  auth: {
83
83
  keys: {
84
- address_n?: number[] | undefined;
85
84
  type?: number | undefined;
85
+ address_n?: number[] | undefined;
86
86
  weight: number;
87
87
  key: string;
88
88
  }[];
@@ -90,8 +90,8 @@ export declare const validate: (tx: EosSDKTransaction) => {
90
90
  accounts: {
91
91
  weight: number;
92
92
  account: {
93
- permission: string;
94
93
  actor: string;
94
+ permission: string;
95
95
  };
96
96
  }[];
97
97
  waits: {
@@ -101,8 +101,8 @@ export declare const validate: (tx: EosSDKTransaction) => {
101
101
  };
102
102
  } | undefined;
103
103
  delete_auth?: {
104
- account: string;
105
104
  permission: string;
105
+ account: string;
106
106
  } | undefined;
107
107
  link_auth?: {
108
108
  code: string;
@@ -119,8 +119,8 @@ export declare const validate: (tx: EosSDKTransaction) => {
119
119
  name: string;
120
120
  owner: {
121
121
  keys: {
122
- address_n?: number[] | undefined;
123
122
  type?: number | undefined;
123
+ address_n?: number[] | undefined;
124
124
  weight: number;
125
125
  key: string;
126
126
  }[];
@@ -128,8 +128,8 @@ export declare const validate: (tx: EosSDKTransaction) => {
128
128
  accounts: {
129
129
  weight: number;
130
130
  account: {
131
- permission: string;
132
131
  actor: string;
132
+ permission: string;
133
133
  };
134
134
  }[];
135
135
  waits: {
@@ -140,8 +140,8 @@ export declare const validate: (tx: EosSDKTransaction) => {
140
140
  creator: string;
141
141
  active: {
142
142
  keys: {
143
- address_n?: number[] | undefined;
144
143
  type?: number | undefined;
144
+ address_n?: number[] | undefined;
145
145
  weight: number;
146
146
  key: string;
147
147
  }[];
@@ -149,8 +149,8 @@ export declare const validate: (tx: EosSDKTransaction) => {
149
149
  accounts: {
150
150
  weight: number;
151
151
  account: {
152
- permission: string;
153
152
  actor: string;
153
+ permission: string;
154
154
  };
155
155
  }[];
156
156
  waits: {
@@ -163,8 +163,8 @@ export declare const validate: (tx: EosSDKTransaction) => {
163
163
  name: string;
164
164
  account: string;
165
165
  authorization: {
166
- permission: string;
167
166
  actor: string;
167
+ permission: string;
168
168
  }[];
169
169
  };
170
170
  }[];
@@ -1,4 +1,4 @@
1
- import type { PROTO } from '../../../constants';
1
+ import { MessagesSchema as PROTO } from '@trezor/protobuf';
2
2
  import { AbstractMethod } from '../../../core/AbstractMethod';
3
3
  import type { EthereumNetworkInfo } from '../../../types';
4
4
  type Params = PROTO.EthereumGetPublicKey & {
@@ -22,9 +22,9 @@ export default class EthereumGetPublicKey extends AbstractMethod<'ethereumGetPub
22
22
  descriptorChecksum?: string | undefined;
23
23
  depth: number;
24
24
  fingerprint: number;
25
- chainCode: string;
26
- childNum: number;
27
25
  xpub: string;
26
+ childNum: number;
27
+ chainCode: string;
28
28
  }) | ({
29
29
  path: number[];
30
30
  publicKey: string;
@@ -35,9 +35,9 @@ export default class EthereumGetPublicKey extends AbstractMethod<'ethereumGetPub
35
35
  descriptorChecksum?: string | undefined;
36
36
  depth: number;
37
37
  fingerprint: number;
38
- chainCode: string;
39
- childNum: number;
40
38
  xpub: string;
39
+ childNum: number;
40
+ chainCode: string;
41
41
  })[]>;
42
42
  }
43
43
  export {};
@@ -1,5 +1,4 @@
1
- import { MessagesSchema } from '@trezor/protobuf';
2
- import type { PROTO } from '../../../constants';
1
+ import { MessagesSchema, MessagesSchema as PROTO } from '@trezor/protobuf';
3
2
  import { AbstractMethod } from '../../../core/AbstractMethod';
4
3
  import { EthereumNetworkInfo } from '../../../types';
5
4
  type Params = PROTO.EthereumSignMessage & {
@@ -1,4 +1,4 @@
1
- import type { PROTO } from '../../../constants';
1
+ import { MessagesSchema as PROTO } from '@trezor/protobuf';
2
2
  import { AbstractMethod } from '../../../core/AbstractMethod';
3
3
  export default class EthereumVerifyMessage extends AbstractMethod<'ethereumVerifyMessage', PROTO.EthereumVerifyMessage> {
4
4
  init(): void;
@@ -1,4 +1,4 @@
1
- import { PROTO } from '../constants';
1
+ import { MessagesSchema as PROTO } from '@trezor/protobuf';
2
2
  import { AbstractMethod } from '../core/AbstractMethod';
3
3
  export default class EvoluGetNode extends AbstractMethod<'evoluGetNode', PROTO.EvoluGetNode> {
4
4
  hasBundle?: boolean;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ const protobuf_1 = require("@trezor/protobuf");
3
4
  const schema_utils_1 = require("@trezor/schema-utils");
4
- const constants_1 = require("../constants");
5
5
  const AbstractMethod_1 = require("../core/AbstractMethod");
6
6
  const paramsValidator_1 = require("./common/paramsValidator");
7
7
  class EvoluGetNode extends AbstractMethod_1.AbstractMethod {
@@ -10,7 +10,7 @@ class EvoluGetNode extends AbstractMethod_1.AbstractMethod {
10
10
  this.requiredPermissions = ['read'];
11
11
  this.firmwareRange = (0, paramsValidator_1.getFirmwareRange)(this.name, null, this.firmwareRange);
12
12
  const { payload } = this;
13
- (0, schema_utils_1.Assert)(constants_1.PROTO.EvoluGetNode, payload);
13
+ (0, schema_utils_1.Assert)(protobuf_1.MessagesSchema.EvoluGetNode, payload);
14
14
  this.params = {};
15
15
  }
16
16
  get info() {
@@ -1,6 +1,13 @@
1
- import { DeviceModelInternal } from '@trezor/device-utils';
2
- export declare const calculateFirmwareHash: (internal_model: DeviceModelInternal, fw: ArrayBuffer, key?: Buffer) => {
1
+ import { DeviceModelInternal, VersionArray } from '@trezor/device-utils';
2
+ type CalculateFirmwareHashParams = {
3
+ internal_model: DeviceModelInternal;
4
+ fw: ArrayBuffer;
5
+ firmwareVersion: VersionArray;
6
+ key?: Buffer;
7
+ };
8
+ export declare const calculateFirmwareHash: ({ internal_model, firmwareVersion, fw, key, }: CalculateFirmwareHashParams) => {
3
9
  hash: string;
4
10
  challenge: string;
5
11
  };
12
+ export {};
6
13
  //# sourceMappingURL=calculateFirmwareHash.d.ts.map
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.calculateFirmwareHash = void 0;
4
4
  const blakejs_1 = require("blakejs");
5
5
  const device_utils_1 = require("@trezor/device-utils");
6
+ const utils_1 = require("@trezor/utils");
6
7
  const SIZE_T1B1 = (7 * 128 + 64) * 1024;
7
8
  const SIZE_T2T1 = 13 * 128 * 1024;
8
9
  const SIZE_T2B1 = 13 * 128 * 1024;
@@ -17,8 +18,17 @@ const firmwareSizeMap = {
17
18
  [device_utils_1.DeviceModelInternal.T3T1]: SIZE_T3T1,
18
19
  [device_utils_1.DeviceModelInternal.T3W1]: SIZE_T3W1,
19
20
  };
20
- const calculateFirmwareHash = (internal_model, fw, key) => {
21
+ const getSizeForModel = ({ internal_model, firmwareVersion, }) => {
21
22
  const size = firmwareSizeMap[internal_model] ?? SIZE_T1B1;
23
+ if (firmwareVersion !== undefined &&
24
+ internal_model === device_utils_1.DeviceModelInternal.T3W1 &&
25
+ utils_1.versionUtils.isEqual(firmwareVersion, [2, 9, 3])) {
26
+ return size - 16 * 1024;
27
+ }
28
+ return size;
29
+ };
30
+ const calculateFirmwareHash = ({ internal_model, firmwareVersion, fw, key, }) => {
31
+ const size = getSizeForModel({ internal_model, firmwareVersion });
22
32
  const padding = size - fw.byteLength;
23
33
  if (padding < 0) {
24
34
  throw new Error('Firmware too big');
@@ -1,13 +1,15 @@
1
1
  import { PROTO } from '../../constants';
2
+ import { DeviceAuthenticityBlacklistConfig } from '../../data/deviceAuthenticityBlacklistConfig';
2
3
  import { DeviceAuthenticityConfig } from '../../data/deviceAuthenticityConfigTypes';
3
4
  import { AuthenticateDeviceResult } from '../../types/api/authenticateDevice';
4
5
  interface AuthenticityProofData extends PROTO.AuthenticityProof {
5
6
  challenge: Buffer;
6
7
  config: DeviceAuthenticityConfig;
8
+ blacklistConfig: DeviceAuthenticityBlacklistConfig;
7
9
  allowDebugKeys?: boolean;
8
10
  deviceModel: keyof typeof PROTO.DeviceModelInternal;
9
11
  }
10
12
  export declare const getRandomChallenge: () => Buffer<ArrayBufferLike>;
11
- export declare const verifyAuthenticityProof: ({ certificates, signature, challenge, config, allowDebugKeys, deviceModel, }: AuthenticityProofData) => Promise<AuthenticateDeviceResult>;
13
+ export declare const verifyAuthenticityProof: ({ optiga_certificates, optiga_signature, challenge, config, blacklistConfig, allowDebugKeys, deviceModel, }: AuthenticityProofData) => Promise<AuthenticateDeviceResult>;
12
14
  export {};
13
15
  //# sourceMappingURL=verifyAuthenticityProof.d.ts.map
@@ -3,15 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.verifyAuthenticityProof = exports.getRandomChallenge = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const crypto = tslib_1.__importStar(require("crypto"));
6
+ const crypto_utils_1 = require("@trezor/crypto-utils");
6
7
  const utils_1 = require("@trezor/utils");
7
8
  const x509certificate_1 = require("./x509certificate");
8
9
  const verifySignature = async (rawKey, data, signature) => {
9
10
  const signer = crypto.createVerify('sha256');
10
11
  signer.update(Buffer.from(data));
11
- const SubtleCrypto = typeof window !== 'undefined' ? window.crypto.subtle : crypto.subtle;
12
- if (!SubtleCrypto) {
13
- throw new Error('SubtleCrypto not supported');
14
- }
12
+ const SubtleCrypto = (0, crypto_utils_1.getSubtleCrypto)();
15
13
  const ecPubKey = await SubtleCrypto.importKey('raw', rawKey, { name: 'ECDSA', namedCurve: 'P-256' }, true, ['verify']);
16
14
  const spkiPubKey = await SubtleCrypto.exportKey('spki', ecPubKey);
17
15
  const key = `-----BEGIN PUBLIC KEY-----\n${Buffer.from(spkiPubKey).toString('base64')}\n-----END PUBLIC KEY-----`;
@@ -48,13 +46,14 @@ const validateCaCertExtensions = (cert, pathLen) => {
48
46
  throw new Error(`CA missing extensions keyUsage: ${hasKeyUsage}, basicConstraints: ${hasBasicConstraints}`);
49
47
  }
50
48
  };
51
- const verifyAuthenticityProof = async ({ certificates, signature, challenge, config, allowDebugKeys, deviceModel, }) => {
49
+ const verifyAuthenticityProof = async ({ optiga_certificates, optiga_signature, challenge, config, blacklistConfig, allowDebugKeys, deviceModel, }) => {
52
50
  const modelConfig = config[deviceModel];
53
51
  if (!modelConfig) {
54
52
  throw new Error(`Pubkeys for ${deviceModel} not found in config`);
55
53
  }
56
- const { caPubKeys, debug } = modelConfig;
57
- const [deviceCert, caCert] = certificates.map((c, i) => {
54
+ const { debug } = modelConfig;
55
+ const { blacklistedCaPubKeys, debug: debugBlacklist } = blacklistConfig;
56
+ const [deviceCert, caCert] = optiga_certificates.map((c, i) => {
58
57
  const cert = (0, x509certificate_1.parseCertificate)(new Uint8Array(Buffer.from(c, 'hex')));
59
58
  if (i === 0) {
60
59
  return cert;
@@ -75,10 +74,8 @@ const verifyAuthenticityProof = async ({ certificates, signature, challenge, con
75
74
  throw new Error(`CA validity from ${caCertValidityFrom} cant't be in the future!`);
76
75
  }
77
76
  if (!rootPubKey) {
78
- const configExpired = new Date(config.timestamp).getTime() < caCertValidityFrom;
79
77
  return {
80
78
  valid: false,
81
- configExpired,
82
79
  caPubKey,
83
80
  error: 'ROOT_PUBKEY_NOT_FOUND',
84
81
  };
@@ -103,16 +100,14 @@ const verifyAuthenticityProof = async ({ certificates, signature, challenge, con
103
100
  utils_1.bufferUtils.getChunkSize(challenge.length),
104
101
  challenge,
105
102
  ]);
106
- const isSignatureValid = await verifySignature(Buffer.from(deviceCert.tbsCertificate.subjectPublicKeyInfo.bits.bytes), prefixedChallenge, (0, x509certificate_1.fixSignature)(Buffer.from(signature, 'hex')));
103
+ const isSignatureValid = await verifySignature(Buffer.from(deviceCert.tbsCertificate.subjectPublicKeyInfo.bits.bytes), prefixedChallenge, (0, x509certificate_1.fixSignature)(Buffer.from(optiga_signature, 'hex')));
107
104
  if (rootPubKey && isDeviceCertValid && isSignatureValid) {
108
- if ((!isDebugRootPubKey && !caPubKeys.includes(caPubKey)) ||
109
- (isDebugRootPubKey && !debug?.caPubKeys.includes(caPubKey))) {
110
- const configExpired = new Date(config.timestamp).getTime() < caCertValidityFrom;
105
+ if ((!isDebugRootPubKey && blacklistedCaPubKeys.includes(caPubKey)) ||
106
+ (isDebugRootPubKey && debugBlacklist?.blacklistedCaPubKeys.includes(caPubKey))) {
111
107
  return {
112
108
  valid: false,
113
- configExpired,
114
109
  caPubKey,
115
- error: 'CA_PUBKEY_NOT_FOUND',
110
+ error: 'CA_PUBKEY_BLACKLISTED',
116
111
  };
117
112
  }
118
113
  return {