@trezor/connect 9.4.2-beta.2 → 9.4.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 (39) hide show
  1. package/CHANGELOG.md +55 -23
  2. package/README.md +1 -1
  3. package/lib/api/checkFirmwareAuthenticity.js +9 -2
  4. package/lib/api/firmware/getBinary.d.ts +4 -5
  5. package/lib/api/firmware/getBinary.js +12 -13
  6. package/lib/api/firmware/getBinaryForFirmwareUpgrade.d.ts +3 -3
  7. package/lib/api/firmware/getBinaryForFirmwareUpgrade.js +2 -2
  8. package/lib/api/firmware/index.d.ts +1 -1
  9. package/lib/api/firmware/index.js +2 -1
  10. package/lib/api/resetDevice.js +0 -1
  11. package/lib/backend/Blockchain.js +3 -6
  12. package/lib/constants/errors.d.ts +46 -38
  13. package/lib/constants/errors.js +7 -0
  14. package/lib/constants/firmware.d.ts +2 -0
  15. package/lib/constants/firmware.js +5 -0
  16. package/lib/constants/index.d.ts +1 -0
  17. package/lib/constants/index.js +2 -1
  18. package/lib/core/onCallFirmwareUpdate.js +1 -1
  19. package/lib/data/analyticsInfo.js +2 -1
  20. package/lib/data/connectSettings.js +5 -0
  21. package/lib/data/deviceAuthenticityConfig.js +3 -0
  22. package/lib/data/version.d.ts +2 -1
  23. package/lib/data/version.js +3 -2
  24. package/lib/device/Device.d.ts +2 -1
  25. package/lib/device/Device.js +57 -7
  26. package/lib/device/checkFirmwareRevision.js +4 -4
  27. package/lib/events/core.d.ts +4 -3
  28. package/lib/impl/dynamic.d.ts +39 -0
  29. package/lib/impl/dynamic.js +84 -0
  30. package/lib/types/device.d.ts +21 -14
  31. package/lib/types/params.d.ts +2 -1
  32. package/lib/types/settings.d.ts +2 -1
  33. package/lib/utils/assetUtils.d.ts +1 -1
  34. package/lib/utils/assetUtils.js +3 -3
  35. package/lib/utils/assets.js +1 -1
  36. package/lib/utils/assets.native.js +1 -1
  37. package/lib/utils/proxy-event-emitter.d.ts +21 -0
  38. package/lib/utils/proxy-event-emitter.js +65 -0
  39. package/package.json +7 -7
package/CHANGELOG.md CHANGED
@@ -1,16 +1,61 @@
1
1
  | Package | Stable | Canary |
2
2
  | :------------------------------: | :----: | :----------: |
3
- | npm @trezor/connect | 9.4.1 | 9.4.2-beta.2 |
4
- | npm @trezor/connect-web | 9.4.1 | 9.4.2-beta.2 |
5
- | npm @trezor/connect-webextension | 9.4.1 | 9.4.2-beta.2 |
3
+ | npm @trezor/connect | 9.4.2 | 9.4.3-beta.1 |
4
+ | npm @trezor/connect-web | 9.4.2 | 9.4.3-beta.1 |
5
+ | npm @trezor/connect-webextension | 9.4.2 | 9.4.3-beta.1 |
6
6
 
7
7
  | Deployment | Stable | Canary |
8
8
  | :----------------: | :----: | :----------: |
9
- | connect.trezor.io/ | 9.4.1 | 9.4.2-beta.2 |
9
+ | connect.trezor.io/ | 9.4.2 | 9.4.3-beta.1 |
10
10
 
11
11
  Use the persistent link [connect.trezor.io/9](https://connect.trezor.io/9/) to access the latest stable version of Connect Explorer.
12
12
 
13
- # 9.4.2-beta.2
13
+ # 9.4.3-beta.1
14
+
15
+ This release introduces `@trezor/connect-mobile`, which allows mobile apps to integrate with Trezor Suite mobile using deeplinks.
16
+ This package is still beta and work in progress.
17
+
18
+ ### Connect Mobile related changes
19
+
20
+ - chore(connect-mobile): update package.json for publishing (fb157ef318)
21
+ - feat(connect-explorer): hiding beta-only content (21e0d42c6d)
22
+ - feat(connect-explorer): call deeplinks from method tester (f2a5f7460e)
23
+ - docs(connect): mobile connect popup (9f8f1c1bd2)
24
+ - chore(connect-popup): move deeplink fallback page to versioned url (e86e6aa5b3)
25
+ - chore: rename connect-deeplink to connect-mobile (d1c2bd7464)
26
+ - feat(connect): use separate versioning for deeplink protocol (40f3b53a34)
27
+ - feat(module-connect-popup): add version check to app link parser (fe8499ec1c)
28
+ - chore(connect-examples): change from deeplinkUrl to connectSrc (1ff479c545)
29
+ - feat(connect): take deeplinkUrl from connectSrc (1b88b3b72b)
30
+
31
+ ### Other changes
32
+
33
+ - refactor(connect-web): use dynamic from connect package (887889288f)
34
+ - refactor(connect): dynamic connect (96e81fe5bf)
35
+ - fix(connect): make getBinaryOptional async (e583e84c32)
36
+ - test(connect-popup): fix log going to (9dee606f43)
37
+ - feat(connect): fw hash check automatically for T1B1 (0fd023dbe8)
38
+ - docs(connect-web): Support matrix (44ed16a45d)
39
+ - chore: update backends for bsc and op (458f0fe3d9)
40
+ - docs(connect-explorer): mention address can be used in getAccountInfo (722a2b2b7f)
41
+ - chore(connect): cleanup some duplicities in fw download util (53456df94d)
42
+ - chore(connect): a cosmetic change in Device types (b718af4a2b)
43
+ - chore(connect): use import from @trezor/connect-analytics (1ee270b1cd)
44
+ - chore(protobuf): update messages.json (71bbde850b)
45
+ - feat(connect): add Optimism (c2fb244649)
46
+ - chore(connect): pol only to pol backend (fe589cf6bc)
47
+ - chore(connect): rename 'getAssetByUrl' to a more apt fn name 'tryLocalAssetRequire' (f5e8f256ae)
48
+ - docs(connect-explorer): remove trailing commas from json excerpts (dc0147900d)
49
+ - refactor(transport): background sessions improved (7644107353)
50
+ - refactor(connect): connect error codes typing (57815188d1)
51
+ - chore(connect): update device authenticity config (063d68379f)
52
+ - docs: fix header level in connect changelog (ac53d354cc)
53
+ - fix(connect): add other-error to FirmwareRevisionCheckResult errors (4361aba5b7)
54
+
55
+ # 9.4.2
56
+
57
+ This release fixes an issue with TypeScript and certain libraries not being resolved correctly in the previous version.
58
+ If you are still seeing issues with USB types, please add `w3c-web-usb` to your `tsconfig.json` file under `types`.
14
59
 
15
60
  ### Features
16
61
 
@@ -36,26 +81,13 @@ Use the persistent link [connect.trezor.io/9](https://connect.trezor.io/9/) to a
36
81
  - chore(connect-explorer): improve fallback schema illustration (d0619b7)
37
82
  - chore(connect-explorer): improve typography (f730904)
38
83
 
39
- # 9.4.2-beta.1
40
-
41
- ### Features
42
-
43
- - feat(connect): return device info with method response (a378def)
44
- - docs(connect-explorer): flowchart for auto core mode (9501d3d)
45
- - docs(connect-explorer): diagram and explanation for core in popup (3bbb032)
46
-
47
- ### Fixes
48
-
49
- - Fixing an issue with typescript not being able to resolve @sinclair/typebox and USB types correctly ((98d6437))
50
- - Fixing regression that made it impossible to acquire (steal) device session over webusb (5cf83b4)
51
- - Couple of other fixes and improvements of device handling:
52
-
53
- - fix(connect): pending transport event fix (231899f)
54
- - fix(connect): DeviceList create devices sequentially (b4a915b)
84
+ ### Dependencies update
55
85
 
56
- - fix(connect-explorer): icons on index page (fef3791)
86
+ - npm-release: @trezor/connect-common 0.2.2
87
+ - npm-release: @trezor/transport 1.3.2
88
+ - npm-release: @trezor/protobuf 1.2.2
57
89
 
58
- ## 9.4.1
90
+ # 9.4.1
59
91
 
60
92
  Automatic retry for no transport issue: If the transport (bridge) is initially not available, the automatic retry feature allows the user to continue after starting the transport, without having to restart the entire flow.
61
93
 
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @trezor/connect
2
2
 
3
- API version 9.4.2-beta.2
3
+ API version 9.4.3-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,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const crypto_1 = require("crypto");
4
+ const utils_1 = require("@trezor/utils");
4
5
  const AbstractMethod_1 = require("../core/AbstractMethod");
5
6
  const firmware_1 = require("./firmware");
6
7
  const firmwareInfo_1 = require("../data/firmwareInfo");
@@ -24,10 +25,16 @@ class CheckFirmwareAuthenticity extends AbstractMethod_1.AbstractMethod {
24
25
  }
25
26
  const btcOnly = device.firmwareType === types_1.FirmwareType.BitcoinOnly;
26
27
  try {
28
+ const version = device.getVersion();
29
+ const release = (0, firmwareInfo_1.getReleases)((_a = device.features) === null || _a === void 0 ? void 0 : _a.internal_model).find(r => version &&
30
+ utils_1.versionUtils.isVersionArray(version) &&
31
+ utils_1.versionUtils.isEqual(r.version, version));
32
+ if (!release) {
33
+ throw constants_1.ERRORS.TypedError('Runtime', 'no firmware found for this device');
34
+ }
27
35
  const fw = await (0, firmware_1.getBinary)({
28
- releases: (0, firmwareInfo_1.getReleases)((_a = device.features) === null || _a === void 0 ? void 0 : _a.internal_model),
29
36
  baseUrl: (_b = this.params.baseUrl) !== null && _b !== void 0 ? _b : 'https://data.trezor.io',
30
- version: device.getVersion(),
37
+ release,
31
38
  btcOnly,
32
39
  });
33
40
  if (!fw) {
@@ -1,11 +1,10 @@
1
- import { FirmwareRelease, IntermediaryVersion } from '../../types';
1
+ import { FirmwareRelease } from '../../types';
2
2
  interface GetBinaryProps {
3
3
  baseUrl: string;
4
4
  btcOnly?: boolean;
5
- version?: number[];
6
- intermediaryVersion?: IntermediaryVersion;
7
- releases: FirmwareRelease[];
5
+ release: FirmwareRelease;
8
6
  }
9
- export declare const getBinary: ({ releases, baseUrl, version, btcOnly, intermediaryVersion, }: GetBinaryProps) => Promise<ArrayBuffer>;
7
+ export declare const getBinary: ({ baseUrl, btcOnly, release }: GetBinaryProps) => Promise<ArrayBuffer>;
8
+ export declare const getBinaryOptional: (props: GetBinaryProps) => Promise<ArrayBuffer | null>;
10
9
  export {};
11
10
  //# sourceMappingURL=getBinary.d.ts.map
@@ -1,21 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getBinary = void 0;
4
- const utils_1 = require("@trezor/utils");
3
+ exports.getBinaryOptional = exports.getBinary = void 0;
5
4
  const assets_1 = require("../../utils/assets");
6
- const getBinary = ({ releases, baseUrl, version, btcOnly, intermediaryVersion, }) => {
7
- if (intermediaryVersion) {
8
- return (0, assets_1.httpRequest)(`${baseUrl}/firmware/t1b1/trezor-t1b1-inter-v${intermediaryVersion}.bin`, 'binary');
9
- }
10
- const releaseByFirmware = releases.find(r => version &&
11
- utils_1.versionUtils.isVersionArray(version) &&
12
- utils_1.versionUtils.isEqual(r.version, version));
13
- if (releaseByFirmware === undefined) {
14
- throw new Error('no firmware found for this device');
15
- }
16
- const fwUrl = releaseByFirmware[btcOnly ? 'url_bitcoinonly' : 'url'];
5
+ const getBinary = ({ baseUrl, btcOnly, release }) => {
6
+ const fwUrl = release[btcOnly ? 'url_bitcoinonly' : 'url'];
17
7
  const url = `${baseUrl}/${fwUrl}`;
18
8
  return (0, assets_1.httpRequest)(url, 'binary');
19
9
  };
20
10
  exports.getBinary = getBinary;
11
+ const getBinaryOptional = async (props) => {
12
+ try {
13
+ return await (0, exports.getBinary)(props);
14
+ }
15
+ catch (error) {
16
+ return null;
17
+ }
18
+ };
19
+ exports.getBinaryOptional = getBinaryOptional;
21
20
  //# sourceMappingURL=getBinary.js.map
@@ -1,11 +1,11 @@
1
1
  import { GetInfoProps } from '../../data/firmwareInfo';
2
- import { IntermediaryVersion } from '../../types';
2
+ import { IntermediaryVersion, VersionArray } from '../../types';
3
3
  interface GetBinaryForFirmwareUpgradeProps extends GetInfoProps {
4
4
  baseUrl: string;
5
5
  btcOnly?: boolean;
6
- version?: number[];
6
+ version?: VersionArray;
7
7
  intermediaryVersion?: IntermediaryVersion;
8
8
  }
9
- export declare const getBinaryForFirmwareUpgrade: ({ features, releases, baseUrl, version, btcOnly, intermediaryVersion, }: GetBinaryForFirmwareUpgradeProps) => Promise<ArrayBuffer>;
9
+ export declare const getBinaryForFirmwareUpgrade: ({ releases, baseUrl, version, btcOnly, intermediaryVersion, features, }: GetBinaryForFirmwareUpgradeProps) => Promise<ArrayBuffer>;
10
10
  export {};
11
11
  //# sourceMappingURL=getBinaryForFirmwareUpgrade.d.ts.map
@@ -6,7 +6,7 @@ const assets_1 = require("../../utils/assets");
6
6
  const firmwareUtils_1 = require("../../utils/firmwareUtils");
7
7
  const firmwareInfo_1 = require("../../data/firmwareInfo");
8
8
  const getBinary_1 = require("./getBinary");
9
- const getBinaryForFirmwareUpgrade = ({ features, releases, baseUrl, version, btcOnly, intermediaryVersion, }) => {
9
+ const getBinaryForFirmwareUpgrade = ({ releases, baseUrl, version, btcOnly, intermediaryVersion, features, }) => {
10
10
  if (!(0, firmwareUtils_1.isStrictFeatures)(features)) {
11
11
  throw new Error('Features of unexpected shape provided');
12
12
  }
@@ -26,7 +26,7 @@ const getBinaryForFirmwareUpgrade = ({ features, releases, baseUrl, version, btc
26
26
  if (!utils_1.versionUtils.isEqual(releaseByFirmware.version, infoByBootloader.release.version)) {
27
27
  throw new Error(`version provided as param (${releaseByFirmware.version}) does not match firmware version found by features in bootloader (${infoByBootloader.release.version})`);
28
28
  }
29
- return (0, getBinary_1.getBinary)({ releases, baseUrl, version, btcOnly, intermediaryVersion });
29
+ return (0, getBinary_1.getBinary)({ release: releaseByFirmware, baseUrl, btcOnly });
30
30
  };
31
31
  exports.getBinaryForFirmwareUpgrade = getBinaryForFirmwareUpgrade;
32
32
  //# sourceMappingURL=getBinaryForFirmwareUpgrade.js.map
@@ -1,5 +1,5 @@
1
1
  export { getBinaryForFirmwareUpgrade } from './getBinaryForFirmwareUpgrade';
2
- export { getBinary } from './getBinary';
2
+ export { getBinary, getBinaryOptional } from './getBinary';
3
3
  export { getLanguage } from '../../data/getLanguage';
4
4
  export { shouldStripFwHeaders, stripFwHeaders } from './modifyFirmware';
5
5
  export { uploadFirmware } from './uploadFirmware';
@@ -1,10 +1,11 @@
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.getBinary = exports.getBinaryForFirmwareUpgrade = void 0;
3
+ exports.parseFirmwareHeaders = exports.calculateFirmwareHash = exports.uploadFirmware = exports.stripFwHeaders = exports.shouldStripFwHeaders = exports.getLanguage = exports.getBinaryOptional = exports.getBinary = exports.getBinaryForFirmwareUpgrade = void 0;
4
4
  var getBinaryForFirmwareUpgrade_1 = require("./getBinaryForFirmwareUpgrade");
5
5
  Object.defineProperty(exports, "getBinaryForFirmwareUpgrade", { enumerable: true, get: function () { return getBinaryForFirmwareUpgrade_1.getBinaryForFirmwareUpgrade; } });
6
6
  var getBinary_1 = require("./getBinary");
7
7
  Object.defineProperty(exports, "getBinary", { enumerable: true, get: function () { return getBinary_1.getBinary; } });
8
+ Object.defineProperty(exports, "getBinaryOptional", { enumerable: true, get: function () { return getBinary_1.getBinaryOptional; } });
8
9
  var getLanguage_1 = require("../../data/getLanguage");
9
10
  Object.defineProperty(exports, "getLanguage", { enumerable: true, get: function () { return getLanguage_1.getLanguage; } });
10
11
  var modifyFirmware_1 = require("./modifyFirmware");
@@ -14,7 +14,6 @@ class ResetDevice extends AbstractMethod_1.AbstractMethod {
14
14
  const { payload } = this;
15
15
  (0, schema_utils_1.Assert)(constants_1.PROTO.ResetDevice, payload);
16
16
  this.params = {
17
- display_random: payload.display_random,
18
17
  strength: payload.strength || 256,
19
18
  passphrase_protection: payload.passphrase_protection,
20
19
  pin_protection: payload.pin_protection,
@@ -26,11 +26,8 @@ const getNormalizedTrezorShortcut = (shortcut) => {
26
26
  if (shortcut === 'tXRP') {
27
27
  return 'XRP';
28
28
  }
29
- return shortcut;
30
- };
31
- const getNormalizedBackendShortcut = (shortcut) => {
32
- if (shortcut.toLowerCase() === 'matic') {
33
- return 'pol';
29
+ if (shortcut === 'OP') {
30
+ return 'ETH';
34
31
  }
35
32
  return shortcut;
36
33
  };
@@ -85,7 +82,7 @@ class Blockchain {
85
82
  }
86
83
  this.serverInfo = info;
87
84
  const trezorShortcut = getNormalizedTrezorShortcut(this.coinInfo.shortcut);
88
- const backendShortcut = getNormalizedBackendShortcut(this.serverInfo.shortcut);
85
+ const backendShortcut = this.serverInfo.shortcut;
89
86
  if (trezorShortcut.toLowerCase() !== backendShortcut.toLowerCase()) {
90
87
  throw constants_1.ERRORS.TypedError('Backend_Invalid');
91
88
  }
@@ -1,46 +1,54 @@
1
1
  export declare const ERROR_CODES: {
2
- Init_NotInitialized: string;
3
- Init_AlreadyInitialized: string;
4
- Init_IframeBlocked: string;
5
- Init_IframeTimeout: string;
6
- Init_ManifestMissing: string;
7
- Popup_ConnectionMissing: string;
8
- Transport_Missing: string;
9
- Transport_InvalidProtobuf: string;
10
- Method_InvalidPackage: string;
11
- Method_InvalidParameter: string;
12
- Method_NotAllowed: string;
13
- Method_PermissionsNotGranted: string;
14
- Method_Cancel: string;
15
- Method_Interrupted: string;
16
- Method_UnknownCoin: string;
17
- Method_AddressNotMatch: string;
18
- Method_FirmwareUpdate_DownloadFailed: string;
19
- Method_Discovery_BundleException: string;
20
- Method_Override: string;
21
- Method_NoResponse: string;
22
- Backend_NotSupported: string;
23
- Backend_WorkerMissing: string;
24
- Backend_Disconnected: string;
25
- Backend_Invalid: string;
26
- Backend_Error: string;
27
- Runtime: string;
28
- Device_NotFound: string;
29
- Device_InitializeFailed: string;
30
- Device_FwException: string;
31
- Device_ModeException: string;
32
- Device_Disconnected: string;
33
- Device_UsedElsewhere: string;
34
- Device_InvalidState: string;
35
- Device_CallInProgress: string;
36
- Device_MultipleNotSupported: string;
2
+ readonly Init_NotInitialized: "TrezorConnect not initialized";
3
+ readonly Init_AlreadyInitialized: "TrezorConnect has been already initialized";
4
+ readonly Init_IframeBlocked: "Iframe blocked";
5
+ readonly Init_IframeTimeout: "Iframe timeout";
6
+ readonly Init_ManifestMissing: "Manifest not set. Read more at https://github.com/trezor/trezor-suite/blob/develop/docs/packages/connect/index.md";
7
+ readonly Popup_ConnectionMissing: "Unable to establish connection with iframe";
8
+ readonly Transport_Missing: "Transport is missing";
9
+ readonly Transport_InvalidProtobuf: "";
10
+ readonly Method_InvalidPackage: "This package is not suitable to work with browser. Use @trezor/connect-web package instead";
11
+ readonly Method_InvalidParameter: "";
12
+ readonly Method_NotAllowed: "Method not allowed for this configuration";
13
+ readonly Method_PermissionsNotGranted: "Permissions not granted";
14
+ readonly Method_Cancel: "Cancelled";
15
+ readonly Method_Interrupted: "Popup closed";
16
+ readonly Method_UnknownCoin: "Coin not found";
17
+ readonly Method_AddressNotMatch: "Addresses do not match";
18
+ readonly Method_FirmwareUpdate_DownloadFailed: "Failed to download firmware binary";
19
+ readonly Method_Discovery_BundleException: "";
20
+ readonly Method_Override: "override";
21
+ readonly Method_NoResponse: "Call resolved without response";
22
+ readonly Backend_NotSupported: "BlockchainLink settings not found in coins.json";
23
+ readonly Backend_WorkerMissing: "";
24
+ readonly Backend_Disconnected: "Backend disconnected";
25
+ readonly Backend_Invalid: "Invalid backend";
26
+ readonly Backend_Error: "";
27
+ readonly Runtime: "";
28
+ readonly Device_NotFound: "Device not found";
29
+ readonly Device_InitializeFailed: "";
30
+ readonly Device_FwException: "";
31
+ readonly Device_ModeException: "";
32
+ readonly Device_Disconnected: "Device disconnected";
33
+ readonly Device_UsedElsewhere: "Device is used in another window";
34
+ readonly Device_InvalidState: "Passphrase is incorrect";
35
+ readonly Device_CallInProgress: "Device call in progress";
36
+ readonly Device_MultipleNotSupported: "Multiple devices are not supported";
37
+ readonly Failure_ActionCancelled: "Action cancelled by user";
38
+ readonly Failure_FirmwareError: "Firmware installation failed";
39
+ readonly Failure_UnknownCode: "Unknown error";
40
+ readonly Failure_PinCancelled: "PIN cancelled";
41
+ readonly Failure_PinMismatch: "PIN mismatch";
42
+ readonly Failure_WipeCodeMismatch: "Wipe code mismatch";
43
+ readonly Deeplink_VersionMismatch: "Not compatible with current version of the app";
37
44
  };
45
+ export type ErrorCode = keyof typeof ERROR_CODES;
38
46
  export declare class TrezorError extends Error {
39
- code: string;
47
+ code: ErrorCode;
40
48
  message: string;
41
- constructor(code: string, message: string);
49
+ constructor(code: ErrorCode, message: string);
42
50
  }
43
- export declare const TypedError: (id: keyof typeof ERROR_CODES, message?: string) => TrezorError;
51
+ export declare const TypedError: (id: ErrorCode, message?: string) => TrezorError;
44
52
  export declare const serializeError: (payload: any) => any;
45
53
  export declare const LIBUSB_ERROR_MESSAGE = "LIBUSB_ERROR";
46
54
  //# sourceMappingURL=errors.d.ts.map
@@ -37,6 +37,13 @@ exports.ERROR_CODES = {
37
37
  Device_InvalidState: 'Passphrase is incorrect',
38
38
  Device_CallInProgress: 'Device call in progress',
39
39
  Device_MultipleNotSupported: 'Multiple devices are not supported',
40
+ Failure_ActionCancelled: 'Action cancelled by user',
41
+ Failure_FirmwareError: 'Firmware installation failed',
42
+ Failure_UnknownCode: 'Unknown error',
43
+ Failure_PinCancelled: 'PIN cancelled',
44
+ Failure_PinMismatch: 'PIN mismatch',
45
+ Failure_WipeCodeMismatch: 'Wipe code mismatch',
46
+ Deeplink_VersionMismatch: 'Not compatible with current version of the app',
40
47
  };
41
48
  class TrezorError extends Error {
42
49
  constructor(code, message) {
@@ -0,0 +1,2 @@
1
+ export declare const FW_HASH_SUPPORTED_VERSIONS: string[];
2
+ //# sourceMappingURL=firmware.d.ts.map
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FW_HASH_SUPPORTED_VERSIONS = void 0;
4
+ exports.FW_HASH_SUPPORTED_VERSIONS = ['1.11.1', '2.5.1'];
5
+ //# sourceMappingURL=firmware.js.map
@@ -2,5 +2,6 @@ export * as ERRORS from './errors';
2
2
  export * as NETWORK from './network';
3
3
  export * as CARDANO from './cardano';
4
4
  export * as NEM from './nem';
5
+ export * as FIRMWARE from './firmware';
5
6
  export { MessagesSchema as PROTO } from '@trezor/protobuf';
6
7
  //# sourceMappingURL=index.d.ts.map
@@ -1,11 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PROTO = exports.NEM = exports.CARDANO = exports.NETWORK = exports.ERRORS = void 0;
3
+ exports.PROTO = exports.FIRMWARE = exports.NEM = exports.CARDANO = exports.NETWORK = exports.ERRORS = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  exports.ERRORS = tslib_1.__importStar(require("./errors"));
6
6
  exports.NETWORK = tslib_1.__importStar(require("./network"));
7
7
  exports.CARDANO = tslib_1.__importStar(require("./cardano"));
8
8
  exports.NEM = tslib_1.__importStar(require("./nem"));
9
+ exports.FIRMWARE = tslib_1.__importStar(require("./firmware"));
9
10
  var protobuf_1 = require("@trezor/protobuf");
10
11
  Object.defineProperty(exports, "PROTO", { enumerable: true, get: function () { return protobuf_1.MessagesSchema; } });
11
12
  //# sourceMappingURL=index.js.map
@@ -255,7 +255,7 @@ const onCallFirmwareUpdate = async ({ params, context: { deviceList, postMessage
255
255
  log.error('onCallFirmwareUpdate', 'changeLanguage failed silently: ', err);
256
256
  }
257
257
  }
258
- const checkSupported = reconnectedDevice.atLeast(['1.11.1', '2.5.1']) && !params.binary;
258
+ const checkSupported = reconnectedDevice.atLeast(constants_1.FIRMWARE.FW_HASH_SUPPORTED_VERSIONS) && !params.binary;
259
259
  if (checkSupported) {
260
260
  try {
261
261
  log.debug('onCallFirmwareUpdate', 'getFirmwareHash supported, proceed with check', stripped);
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.enhanceMessageWithAnalytics = void 0;
4
+ const connect_analytics_1 = require("@trezor/connect-analytics");
4
5
  const events_1 = require("../events");
5
6
  const enhanceMessageWithAnalytics = (message, data) => {
6
7
  var _a, _b, _c, _d, _e, _f, _g, _h;
@@ -12,7 +13,7 @@ const enhanceMessageWithAnalytics = (message, data) => {
12
13
  payload: {
13
14
  ...message.payload,
14
15
  analytics: {
15
- type: 'device/selected',
16
+ type: connect_analytics_1.EventType.DeviceSelected,
16
17
  payload: {
17
18
  mode: (device === null || device === void 0 ? void 0 : device.mode) || '',
18
19
  pinProtection: ((_a = device === null || device === void 0 ? void 0 : device.features) === null || _a === void 0 ? void 0 : _a.pin_protection) || '',
@@ -21,6 +21,7 @@ const initialSettings = {
21
21
  timestamp: new Date().getTime(),
22
22
  interactionTimeout: 600,
23
23
  sharedLogger: true,
24
+ deeplinkUrl: `${version_1.DEFAULT_DOMAIN}deeplink/${version_1.DEEPLINK_VERSION}/`,
24
25
  };
25
26
  const parseManifest = (manifest) => {
26
27
  if (!manifest)
@@ -71,6 +72,7 @@ const parseConnectSettings = (input = {}) => {
71
72
  settings.iframeSrc = `${src}iframe.html`;
72
73
  settings.popupSrc = `${src}popup.html`;
73
74
  settings.webusbSrc = `${src}webusb.html`;
75
+ settings.deeplinkUrl = `${src}deeplink/${version_1.DEEPLINK_VERSION}/`;
74
76
  if (typeof input.transportReconnect === 'boolean') {
75
77
  settings.transportReconnect = input.transportReconnect;
76
78
  }
@@ -117,6 +119,9 @@ const parseConnectSettings = (input = {}) => {
117
119
  if (typeof input._sessionsBackgroundUrl === 'string') {
118
120
  settings._sessionsBackgroundUrl = input._sessionsBackgroundUrl;
119
121
  }
122
+ if (typeof input.binFilesBaseUrl === 'string') {
123
+ settings.binFilesBaseUrl = input.binFilesBaseUrl;
124
+ }
120
125
  return settings;
121
126
  };
122
127
  exports.parseConnectSettings = parseConnectSettings;
@@ -92,6 +92,9 @@ exports.deviceAuthenticityConfig = {
92
92
  '04903be00e4c5561413513eec337f0a6bec4968711de83242856e6b2bf1f06b26732b7bb1322a817448c03fc2f312318af67be580add0768179ce1af1f5e777bd0',
93
93
  '0464f0ef96854bc7f081396ce7a2c75df4208f551c19d27f5a81238d47b842df800383a736a1b5b1c9e1e458d05ea1584e12278ab5e1252a098820251b37917c22',
94
94
  '0401f3f804333b4d0caa18d27dfc0698dbc11c33b703019018e5819734ef2551615ba6915e6119bd7d36c035553ea660f1ccf7c34e2375e8e1ddf0a471b76707fd',
95
+ '04b427eb0e1484b7127f82820edddbbb538c11d3c330b5f68acef96c8cf4601b30390311f2d48090f3f5c5e4bf56ca0396984797cd92ab0d12164600c9f43d2ba3',
96
+ '0438e670e9eb3cd19f8579b3202caf9aa766c8d5735ab97bd3682155437499e062587bded86c732789345538581c83e9e42af0a15a4ad81bc42e1f28a7859ebce0',
97
+ '04ac2a7e88ffc08186b3cb461966a96cacdb2c07b383018d708a6f0ce0b74f59dca97a6f31fc8d243a781c7fe5006dc6b8ef05347972082b32fb29c636c595ffbc',
95
98
  ],
96
99
  debug: {
97
100
  rootPubKeys: [
@@ -1,4 +1,5 @@
1
- export declare const VERSION = "9.4.2-beta.2";
1
+ export declare const VERSION = "9.4.3-beta.1";
2
2
  export declare const DEFAULT_DOMAIN: string;
3
3
  export declare const CONTENT_SCRIPT_VERSION = 1;
4
+ export declare const DEEPLINK_VERSION = 1;
4
5
  //# sourceMappingURL=version.d.ts.map
@@ -1,11 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CONTENT_SCRIPT_VERSION = exports.DEFAULT_DOMAIN = exports.VERSION = void 0;
4
- exports.VERSION = '9.4.2-beta.2';
3
+ exports.DEEPLINK_VERSION = exports.CONTENT_SCRIPT_VERSION = exports.DEFAULT_DOMAIN = exports.VERSION = void 0;
4
+ exports.VERSION = '9.4.3-beta.1';
5
5
  const versionN = exports.VERSION.split('.').map(s => parseInt(s, 10));
6
6
  const isBeta = exports.VERSION.includes('beta');
7
7
  exports.DEFAULT_DOMAIN = isBeta
8
8
  ? `https://connect.trezor.io/${exports.VERSION}/`
9
9
  : `https://connect.trezor.io/${versionN[0]}/`;
10
10
  exports.CONTENT_SCRIPT_VERSION = 1;
11
+ exports.DEEPLINK_VERSION = 1;
11
12
  //# sourceMappingURL=version.js.map
@@ -5,7 +5,7 @@ import { DeviceCommands } from './DeviceCommands';
5
5
  import { PROTO, NETWORK } from '../constants';
6
6
  import { DEVICE, DeviceButtonRequestPayload, UiResponsePin, UiResponsePassphrase, UiResponseWord } from '../events';
7
7
  import { type Transport, type Descriptor } from '@trezor/transport';
8
- import { Device as DeviceTyped, DeviceFirmwareStatus, DeviceState, Features, ReleaseInfo, UnavailableCapabilities, FirmwareType, VersionArray, KnownDevice } from '../types';
8
+ import { Device as DeviceTyped, DeviceFirmwareStatus, DeviceState, Features, ReleaseInfo, UnavailableCapabilities, FirmwareType, VersionArray, KnownDevice, FirmwareHashCheckResult } from '../types';
9
9
  import { IStateStorage } from './StateStorage';
10
10
  import type { PromptCallback } from './prompts';
11
11
  export type RunOptions = {
@@ -78,6 +78,7 @@ export declare class Device extends TypedEmitter<DeviceEvents> {
78
78
  initialize(useCardanoDerivation: boolean): Promise<void>;
79
79
  initStorage(storage: IStateStorage): void;
80
80
  getFeatures(): Promise<void>;
81
+ checkFirmwareHash(): Promise<FirmwareHashCheckResult | null>;
81
82
  checkFirmwareRevision(): Promise<void>;
82
83
  changeLanguage({ language, binary, }: {
83
84
  language?: undefined;
@@ -16,6 +16,8 @@ const types_1 = require("../types");
16
16
  const models_1 = require("../data/models");
17
17
  const getLanguage_1 = require("../data/getLanguage");
18
18
  const checkFirmwareRevision_1 = require("./checkFirmwareRevision");
19
+ const firmware_1 = require("../api/firmware");
20
+ const crypto_1 = require("crypto");
19
21
  const _log = (0, debug_1.initLog)('Device');
20
22
  exports.GET_FEATURES_TIMEOUT = 3000;
21
23
  exports.GET_FEATURES_TIMEOUT_REACT_NATIVE = 20000;
@@ -40,6 +42,7 @@ class Device extends utils_1.TypedEmitter {
40
42
  this.availableTranslations = [];
41
43
  this.authenticityChecks = {
42
44
  firmwareRevision: null,
45
+ firmwareHash: null,
43
46
  };
44
47
  this.useCardanoDerivation = false;
45
48
  this.protocol = protocol_1.v1;
@@ -321,9 +324,12 @@ class Device extends utils_1.TypedEmitter {
321
324
  async getFeatures() {
322
325
  const { message } = await this.getCommands().typedCall('GetFeatures', 'Features', {});
323
326
  this._updateFeatures(message);
327
+ if (this.authenticityChecks.firmwareHash === null) {
328
+ this.authenticityChecks.firmwareHash = await this.checkFirmwareHash();
329
+ }
324
330
  if (this.authenticityChecks.firmwareRevision === null ||
325
331
  (this.authenticityChecks.firmwareRevision.success === false &&
326
- this.authenticityChecks.firmwareRevision.error === 'cannot-perform-check-offline')) {
332
+ ['cannot-perform-check-offline', 'other-error'].includes(this.authenticityChecks.firmwareRevision.error))) {
327
333
  await this.checkFirmwareRevision();
328
334
  }
329
335
  if (!this.features.language_version_matches &&
@@ -338,6 +344,47 @@ class Device extends utils_1.TypedEmitter {
338
344
  }
339
345
  }
340
346
  }
347
+ async checkFirmwareHash() {
348
+ var _a;
349
+ const createFailResult = (error) => ({ success: false, error });
350
+ const firmwareVersion = this.getVersion();
351
+ if (firmwareVersion === undefined || !this.features || this.features.bootloader_mode) {
352
+ return null;
353
+ }
354
+ const baseUrl = DataManager_1.DataManager.getSettings('binFilesBaseUrl');
355
+ const isModelOne = this.features.internal_model === types_1.DeviceModelInternal.T1B1;
356
+ if (baseUrl === undefined || !isModelOne)
357
+ return createFailResult('check-skipped');
358
+ const checkSupported = this.atLeast(constants_1.FIRMWARE.FW_HASH_SUPPORTED_VERSIONS);
359
+ if (!checkSupported)
360
+ return createFailResult('check-unsupported');
361
+ const release = (0, firmwareInfo_1.getReleases)(this.features.internal_model).find(r => utils_1.versionUtils.isEqual(r.version, firmwareVersion));
362
+ if (release === undefined)
363
+ return createFailResult('unknown-release');
364
+ const btcOnly = this.firmwareType === types_1.FirmwareType.BitcoinOnly;
365
+ const binary = await (0, firmware_1.getBinaryOptional)({ baseUrl, btcOnly, release });
366
+ if (binary === null) {
367
+ return createFailResult('check-unsupported');
368
+ }
369
+ const strippedBinary = (0, firmware_1.stripFwHeaders)(binary);
370
+ const { hash: expectedHash, challenge } = (0, firmware_1.calculateFirmwareHash)(this.features.major_version, strippedBinary, (0, crypto_1.randomBytes)(32));
371
+ const getFirmwareHashOptional = async () => {
372
+ try {
373
+ return await this.getCommands().typedCall('GetFirmwareHash', 'FirmwareHash', {
374
+ challenge,
375
+ });
376
+ }
377
+ catch (e) {
378
+ return null;
379
+ }
380
+ };
381
+ const deviceResponse = await getFirmwareHashOptional();
382
+ if (!((_a = deviceResponse === null || deviceResponse === void 0 ? void 0 : deviceResponse.message) === null || _a === void 0 ? void 0 : _a.hash))
383
+ return createFailResult('other-error');
384
+ if (deviceResponse.message.hash !== expectedHash)
385
+ return createFailResult('hash-mismatch');
386
+ return { success: true };
387
+ }
341
388
  async checkFirmwareRevision() {
342
389
  const firmwareVersion = this.getVersion();
343
390
  if (!firmwareVersion || !this.features) {
@@ -567,21 +614,25 @@ class Device extends utils_1.TypedEmitter {
567
614
  }
568
615
  toMessageObject() {
569
616
  var _a;
617
+ const { path } = this.originalDescriptor;
618
+ const { name } = this;
619
+ const base = {
620
+ path,
621
+ name,
622
+ };
570
623
  if (this.unreadableError) {
571
624
  return {
625
+ ...base,
572
626
  type: 'unreadable',
573
- path: this.originalDescriptor.path,
574
627
  error: this.unreadableError,
575
628
  label: 'Unreadable device',
576
- name: this.name,
577
629
  };
578
630
  }
579
631
  if (this.isUnacquired()) {
580
632
  return {
633
+ ...base,
581
634
  type: 'unacquired',
582
- path: this.originalDescriptor.path,
583
635
  label: 'Unacquired device',
584
- name: this.name,
585
636
  };
586
637
  }
587
638
  const defaultLabel = 'My Trezor';
@@ -590,15 +641,14 @@ class Device extends utils_1.TypedEmitter {
590
641
  if (this.featuresNeedsReload)
591
642
  status = 'used';
592
643
  return {
644
+ ...base,
593
645
  type: 'acquired',
594
646
  id: this.features.device_id,
595
- path: this.originalDescriptor.path,
596
647
  label,
597
648
  _state: this.getState(),
598
649
  state: (_a = this.getState()) === null || _a === void 0 ? void 0 : _a.staticSessionId,
599
650
  status,
600
651
  mode: this.getMode(),
601
- name: this.name,
602
652
  color: this.color,
603
653
  firmware: this.firmwareStatus,
604
654
  firmwareRelease: this.firmwareRelease,
@@ -42,10 +42,10 @@ const checkFirmwareRevision = async ({ firmwareVersion, internalModel, deviceRev
42
42
  return { success: true };
43
43
  }
44
44
  catch (e) {
45
- return {
46
- success: false,
47
- error: 'cannot-perform-check-offline',
48
- };
45
+ if (e.name === 'FetchError' && e.code === 'ENOTFOUND') {
46
+ return failFirmwareRevisionCheck('cannot-perform-check-offline');
47
+ }
48
+ return failFirmwareRevisionCheck('other-error');
49
49
  }
50
50
  }
51
51
  if (!doRevisionsMatch({
@@ -7,6 +7,7 @@ import type { TransportEventMessage, TransportDisableWebUSB, TransportRequestWeb
7
7
  import type { UiEventMessage } from './ui-request';
8
8
  import type { UiResponseEvent } from './ui-response';
9
9
  import type { Unsuccessful } from '../types/params';
10
+ import { ErrorCode, TrezorError } from '../constants/errors';
10
11
  export declare const CORE_EVENT = "CORE_EVENT";
11
12
  export type CoreRequestMessage = PopupClosedMessage | PopupAnalyticsResponse | TransportDisableWebUSB | TransportRequestWebUSBDevice | TransportGetInfo | UiResponseEvent | IFrameInit | IFrameCallMessage | IFrameLogRequest;
12
13
  export type CoreEventMessage = {
@@ -17,7 +18,7 @@ export type CoreEventMessage = {
17
18
  };
18
19
  } & (BlockchainEventMessage | DeviceEventMessage | TransportEventMessage | UiEventMessage | MethodResponseMessage | IFrameEventMessage | PopupEventMessage);
19
20
  export declare const parseMessage: <T extends CoreRequestMessage | CoreEventMessage = never>(messageData: any) => T;
20
- export declare const createErrorMessage: (error: Error & {
21
- code?: string;
22
- }) => Unsuccessful;
21
+ export declare const createErrorMessage: (error: (Error & {
22
+ code?: ErrorCode;
23
+ }) | TrezorError) => Unsuccessful;
23
24
  //# sourceMappingURL=core.d.ts.map
@@ -0,0 +1,39 @@
1
+ import EventEmitter from 'events';
2
+ import { ConnectFactoryDependencies } from '../factory';
3
+ import type { ConnectSettingsPublic, Manifest } from '../types';
4
+ import { CallMethodPayload } from '../events';
5
+ type TrezorConnectDynamicParams<TrezorConnectImplType> = {
6
+ implementations: {
7
+ type: TrezorConnectImplType;
8
+ impl: ConnectFactoryDependencies;
9
+ }[];
10
+ getInitTarget: (settings: Partial<ConnectSettingsPublic>) => TrezorConnectImplType;
11
+ handleErrorFallback: (errorCode: string) => Promise<boolean>;
12
+ };
13
+ export declare class TrezorConnectDynamic<TrezorConnectImplType> implements ConnectFactoryDependencies {
14
+ eventEmitter: EventEmitter;
15
+ private currentTarget;
16
+ private implementations;
17
+ private getInitTarget;
18
+ private handleErrorFallback;
19
+ lastSettings?: {
20
+ manifest: Manifest;
21
+ } & Partial<ConnectSettingsPublic>;
22
+ constructor({ implementations, getInitTarget, handleErrorFallback, }: TrezorConnectDynamicParams<TrezorConnectImplType>);
23
+ private getTarget;
24
+ switchTarget(target: TrezorConnectImplType): Promise<void>;
25
+ manifest(manifest: Manifest): void;
26
+ init(settings: {
27
+ manifest: Manifest;
28
+ } & Partial<ConnectSettingsPublic>): Promise<void>;
29
+ call(params: CallMethodPayload): Promise<any>;
30
+ requestLogin(params: any): import("../types").Response<import("../types/api/requestLogin").Login>;
31
+ uiResponse(params: any): void;
32
+ renderWebUSBButton(): void;
33
+ disableWebUSB(): void;
34
+ requestWebUSBDevice(): void;
35
+ cancel(error?: string): void;
36
+ dispose(): void;
37
+ }
38
+ export {};
39
+ //# sourceMappingURL=dynamic.d.ts.map
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TrezorConnectDynamic = void 0;
4
+ const constants_1 = require("../constants");
5
+ const proxy_event_emitter_1 = require("../utils/proxy-event-emitter");
6
+ class TrezorConnectDynamic {
7
+ constructor({ implementations, getInitTarget, handleErrorFallback, }) {
8
+ this.implementations = implementations;
9
+ this.currentTarget = this.implementations[0].type;
10
+ this.getInitTarget = getInitTarget;
11
+ this.handleErrorFallback = handleErrorFallback;
12
+ this.eventEmitter = new proxy_event_emitter_1.ProxyEventEmitter(this.implementations.map(impl => impl.impl.eventEmitter));
13
+ }
14
+ getTarget() {
15
+ return this.implementations.find(impl => impl.type === this.currentTarget).impl;
16
+ }
17
+ async switchTarget(target) {
18
+ if (this.currentTarget === target) {
19
+ return;
20
+ }
21
+ if (!this.lastSettings) {
22
+ throw constants_1.ERRORS.TypedError('Init_NotInitialized');
23
+ }
24
+ await this.getTarget().dispose();
25
+ this.currentTarget = target;
26
+ await this.getTarget().init(this.lastSettings);
27
+ }
28
+ manifest(manifest) {
29
+ this.lastSettings = {
30
+ ...this.lastSettings,
31
+ manifest,
32
+ };
33
+ this.getTarget().manifest(manifest);
34
+ }
35
+ async init(settings) {
36
+ if (!(settings === null || settings === void 0 ? void 0 : settings.manifest)) {
37
+ throw constants_1.ERRORS.TypedError('Init_ManifestMissing');
38
+ }
39
+ this.lastSettings = settings;
40
+ this.currentTarget = this.getInitTarget(settings);
41
+ try {
42
+ return await this.getTarget().init(this.lastSettings);
43
+ }
44
+ catch (error) {
45
+ if (await this.handleErrorFallback(error.code)) {
46
+ return await this.getTarget().init(settings);
47
+ }
48
+ throw error;
49
+ }
50
+ }
51
+ async call(params) {
52
+ const response = await this.getTarget().call(params);
53
+ if (!response.success) {
54
+ if (await this.handleErrorFallback(response.payload.code)) {
55
+ return await this.getTarget().call(params);
56
+ }
57
+ }
58
+ return response;
59
+ }
60
+ requestLogin(params) {
61
+ return this.getTarget().requestLogin(params);
62
+ }
63
+ uiResponse(params) {
64
+ return this.getTarget().uiResponse(params);
65
+ }
66
+ renderWebUSBButton() {
67
+ return this.getTarget().renderWebUSBButton();
68
+ }
69
+ disableWebUSB() {
70
+ return this.getTarget().disableWebUSB();
71
+ }
72
+ requestWebUSBDevice() {
73
+ return this.getTarget().requestWebUSBDevice();
74
+ }
75
+ cancel(error) {
76
+ return this.getTarget().cancel(error);
77
+ }
78
+ dispose() {
79
+ this.eventEmitter.removeAllListeners();
80
+ return this.getTarget().dispose();
81
+ }
82
+ }
83
+ exports.TrezorConnectDynamic = TrezorConnectDynamic;
84
+ //# sourceMappingURL=dynamic.js.map
@@ -16,22 +16,32 @@ export type DeviceState = {
16
16
  export type UnavailableCapabilities = {
17
17
  [key: string]: UnavailableCapability;
18
18
  };
19
+ export type FirmwareRevisionCheckError = 'revision-mismatch' | 'firmware-version-unknown' | 'cannot-perform-check-offline' | 'other-error';
19
20
  export type FirmwareRevisionCheckResult = {
20
21
  success: true;
21
22
  } | {
22
23
  success: false;
23
- error: 'revision-mismatch' | 'firmware-version-unknown' | 'firmware-version-unknown' | 'cannot-perform-check-offline';
24
+ error: FirmwareRevisionCheckError;
24
25
  };
25
- export type KnownDevice = {
26
+ export type FirmwareHashCheckError = 'hash-mismatch' | 'check-skipped' | 'check-unsupported' | 'unknown-release' | 'other-error';
27
+ export type FirmwareHashCheckResult = {
28
+ success: true;
29
+ } | {
30
+ success: false;
31
+ error: FirmwareHashCheckError;
32
+ };
33
+ type BaseDevice = {
34
+ path: string;
35
+ name: string;
36
+ };
37
+ export type KnownDevice = BaseDevice & {
26
38
  type: 'acquired';
27
39
  id: string | null;
28
- path: string;
29
40
  label: string;
30
41
  error?: typeof undefined;
31
42
  firmware: DeviceFirmwareStatus;
32
43
  firmwareRelease?: ReleaseInfo | null;
33
44
  firmwareType?: FirmwareType;
34
- name: string;
35
45
  color?: string;
36
46
  status: DeviceStatus;
37
47
  mode: DeviceMode;
@@ -42,19 +52,18 @@ export type KnownDevice = {
42
52
  availableTranslations: string[];
43
53
  authenticityChecks?: {
44
54
  firmwareRevision: FirmwareRevisionCheckResult | null;
55
+ firmwareHash: FirmwareHashCheckResult | null;
45
56
  };
46
57
  };
47
- export type UnknownDevice = {
58
+ export type UnknownDevice = BaseDevice & {
48
59
  type: 'unacquired';
49
- id?: null;
50
- path: string;
51
- label: string;
60
+ label: 'Unacquired device';
61
+ id?: typeof undefined;
52
62
  error?: typeof undefined;
53
63
  features?: typeof undefined;
54
64
  firmware?: typeof undefined;
55
65
  firmwareRelease?: typeof undefined;
56
66
  firmwareType?: typeof undefined;
57
- name: string;
58
67
  color?: typeof undefined;
59
68
  status?: typeof undefined;
60
69
  mode?: typeof undefined;
@@ -63,17 +72,15 @@ export type UnknownDevice = {
63
72
  unavailableCapabilities?: typeof undefined;
64
73
  availableTranslations?: typeof undefined;
65
74
  };
66
- export type UnreadableDevice = {
75
+ export type UnreadableDevice = BaseDevice & {
67
76
  type: 'unreadable';
68
- id?: null;
69
- path: string;
70
- label: string;
77
+ label: 'Unreadable device';
71
78
  error: string;
79
+ id?: typeof undefined;
72
80
  features?: typeof undefined;
73
81
  firmware?: typeof undefined;
74
82
  firmwareRelease?: typeof undefined;
75
83
  firmwareType?: typeof undefined;
76
- name: string;
77
84
  color?: typeof undefined;
78
85
  status?: typeof undefined;
79
86
  mode?: typeof undefined;
@@ -1,5 +1,6 @@
1
1
  import { TSchema, Static } from '@trezor/schema-utils';
2
2
  import { DeviceState } from './device';
3
+ import { ErrorCode } from '../constants/errors';
3
4
  export interface DeviceIdentity {
4
5
  path?: string;
5
6
  state?: string | DeviceState;
@@ -34,7 +35,7 @@ export interface Unsuccessful {
34
35
  success: false;
35
36
  payload: {
36
37
  error: string;
37
- code?: string;
38
+ code?: ErrorCode;
38
39
  };
39
40
  }
40
41
  export interface Success<T> {
@@ -25,7 +25,7 @@ export interface ConnectSettingsPublic {
25
25
  _sessionsBackgroundUrl?: string;
26
26
  deeplinkOpen?: (url: string) => void;
27
27
  deeplinkCallbackUrl?: string;
28
- deeplinkUrl?: string;
28
+ binFilesBaseUrl?: string;
29
29
  }
30
30
  export interface ConnectSettingsInternal {
31
31
  origin?: string;
@@ -41,6 +41,7 @@ export interface ConnectSettingsInternal {
41
41
  proxy?: Proxy;
42
42
  sharedLogger?: boolean;
43
43
  useCoreInPopup?: boolean;
44
+ deeplinkUrl: string;
44
45
  }
45
46
  export type ConnectSettings = ConnectSettingsPublic & ConnectSettingsInternal;
46
47
  //# sourceMappingURL=settings.d.ts.map
@@ -1,2 +1,2 @@
1
- export declare const getAssetByUrl: (url: string) => any;
1
+ export declare const tryLocalAssetRequire: (url: string) => any;
2
2
  //# sourceMappingURL=assetUtils.d.ts.map
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getAssetByUrl = void 0;
3
+ exports.tryLocalAssetRequire = void 0;
4
4
  const types_1 = require("../types");
5
5
  const isDeviceModel = (model) => {
6
6
  return Object.values(types_1.DeviceModelInternal).includes(model);
@@ -12,7 +12,7 @@ const firmwareAssets = {
12
12
  [types_1.DeviceModelInternal.T3B1]: require('@trezor/connect-common/files/firmware/t3b1/releases.json'),
13
13
  [types_1.DeviceModelInternal.T3T1]: require('@trezor/connect-common/files/firmware/t3t1/releases.json'),
14
14
  };
15
- const getAssetByUrl = (url) => {
15
+ const tryLocalAssetRequire = (url) => {
16
16
  const fileUrl = url.split('?')[0];
17
17
  switch (fileUrl) {
18
18
  case './data/coins.json':
@@ -33,5 +33,5 @@ const getAssetByUrl = (url) => {
33
33
  }
34
34
  return null;
35
35
  };
36
- exports.getAssetByUrl = getAssetByUrl;
36
+ exports.tryLocalAssetRequire = tryLocalAssetRequire;
37
37
  //# sourceMappingURL=assetUtils.js.map
@@ -10,7 +10,7 @@ if (global && typeof global.fetch !== 'function') {
10
10
  global.fetch = cross_fetch_1.default;
11
11
  }
12
12
  function httpRequest(url, type, options, skipLocalForceDownload) {
13
- const asset = skipLocalForceDownload ? null : (0, assetUtils_1.getAssetByUrl)(url);
13
+ const asset = skipLocalForceDownload ? null : (0, assetUtils_1.tryLocalAssetRequire)(url);
14
14
  if (!asset) {
15
15
  return /^https?/.test(url) ? (0, assets_browser_1.httpRequest)(url, type, options) : fs_1.promises.readFile(url);
16
16
  }
@@ -2,6 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.httpRequest = void 0;
4
4
  const assetUtils_1 = require("./assetUtils");
5
- const httpRequest = (url, _type) => (0, assetUtils_1.getAssetByUrl)(url);
5
+ const httpRequest = (url, _type) => (0, assetUtils_1.tryLocalAssetRequire)(url);
6
6
  exports.httpRequest = httpRequest;
7
7
  //# sourceMappingURL=assets.native.js.map
@@ -0,0 +1,21 @@
1
+ import EventEmitter from 'events';
2
+ export declare class ProxyEventEmitter implements EventEmitter {
3
+ private eventEmitters;
4
+ constructor(eventEmitters: EventEmitter[]);
5
+ emit(eventName: string | symbol, ...args: any[]): boolean;
6
+ on(eventName: string | symbol, listener: (...args: any[]) => void): this;
7
+ off(eventName: string | symbol, listener: (...args: any[]) => void): this;
8
+ once(eventName: string | symbol, listener: (...args: any[]) => void): this;
9
+ addListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
10
+ prependListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
11
+ prependOnceListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
12
+ removeAllListeners(event?: string | symbol | undefined): this;
13
+ removeListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
14
+ setMaxListeners(n: number): this;
15
+ eventNames(): (string | symbol)[];
16
+ getMaxListeners(): number;
17
+ listenerCount(eventName: string | symbol, listener?: FunctionConstructor | undefined): number;
18
+ rawListeners(eventName: string | symbol): Function[];
19
+ listeners(eventName: string | symbol): Function[];
20
+ }
21
+ //# sourceMappingURL=proxy-event-emitter.d.ts.map
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ProxyEventEmitter = void 0;
4
+ class ProxyEventEmitter {
5
+ constructor(eventEmitters) {
6
+ this.eventEmitters = eventEmitters;
7
+ }
8
+ emit(eventName, ...args) {
9
+ this.eventEmitters.forEach(emitter => emitter.emit(eventName, ...args));
10
+ return true;
11
+ }
12
+ on(eventName, listener) {
13
+ this.eventEmitters.forEach(emitter => emitter.on(eventName, listener));
14
+ return this;
15
+ }
16
+ off(eventName, listener) {
17
+ this.eventEmitters.forEach(emitter => emitter.off(eventName, listener));
18
+ return this;
19
+ }
20
+ once(eventName, listener) {
21
+ this.eventEmitters.forEach(emitter => emitter.once(eventName, listener));
22
+ return this;
23
+ }
24
+ addListener(eventName, listener) {
25
+ this.eventEmitters.forEach(emitter => emitter.addListener(eventName, listener));
26
+ return this;
27
+ }
28
+ prependListener(eventName, listener) {
29
+ this.eventEmitters.forEach(emitter => emitter.prependListener(eventName, listener));
30
+ return this;
31
+ }
32
+ prependOnceListener(eventName, listener) {
33
+ this.eventEmitters.forEach(emitter => emitter.prependOnceListener(eventName, listener));
34
+ return this;
35
+ }
36
+ removeAllListeners(event) {
37
+ this.eventEmitters.forEach(emitter => emitter.removeAllListeners(event));
38
+ return this;
39
+ }
40
+ removeListener(eventName, listener) {
41
+ this.eventEmitters.forEach(emitter => emitter.removeListener(eventName, listener));
42
+ return this;
43
+ }
44
+ setMaxListeners(n) {
45
+ this.eventEmitters.forEach(emitter => emitter.setMaxListeners(n));
46
+ return this;
47
+ }
48
+ eventNames() {
49
+ return this.eventEmitters[0].eventNames();
50
+ }
51
+ getMaxListeners() {
52
+ return this.eventEmitters[0].getMaxListeners();
53
+ }
54
+ listenerCount(eventName, listener) {
55
+ return this.eventEmitters[0].listenerCount(eventName, listener);
56
+ }
57
+ rawListeners(eventName) {
58
+ return this.eventEmitters[0].rawListeners(eventName);
59
+ }
60
+ listeners(eventName) {
61
+ return this.eventEmitters[0].listeners(eventName);
62
+ }
63
+ }
64
+ exports.ProxyEventEmitter = ProxyEventEmitter;
65
+ //# sourceMappingURL=proxy-event-emitter.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trezor/connect",
3
- "version": "9.4.2-beta.2",
3
+ "version": "9.4.3-beta.1",
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.",
@@ -73,15 +73,15 @@
73
73
  "@ethereumjs/common": "^4.3.0",
74
74
  "@ethereumjs/tx": "^5.3.0",
75
75
  "@fivebinaries/coin-selection": "2.2.1",
76
- "@trezor/blockchain-link": "2.3.1",
77
- "@trezor/blockchain-link-types": "1.2.1",
76
+ "@trezor/blockchain-link": "2.3.2-beta.1",
77
+ "@trezor/blockchain-link-types": "1.2.2-beta.1",
78
78
  "@trezor/connect-analytics": "1.2.1",
79
- "@trezor/connect-common": "0.2.2-beta.1",
80
- "@trezor/protobuf": "1.2.2-beta.1",
79
+ "@trezor/connect-common": "0.2.3-beta.1",
80
+ "@trezor/protobuf": "1.2.3-beta.1",
81
81
  "@trezor/protocol": "1.2.1",
82
82
  "@trezor/schema-utils": "1.2.1",
83
- "@trezor/transport": "1.3.2-beta.1",
84
- "@trezor/utils": "9.2.1",
83
+ "@trezor/transport": "1.3.3-beta.1",
84
+ "@trezor/utils": "9.2.2-beta.1",
85
85
  "@trezor/utxo-lib": "2.2.1",
86
86
  "blakejs": "^1.2.1",
87
87
  "bs58": "^6.0.0",