@trezor/connect 9.6.3-beta.1 → 9.6.3-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,16 +1,21 @@
1
1
  | Package | Stable | Canary |
2
2
  | :------------------------------: | :----: | :----------: |
3
- | npm @trezor/connect | 9.6.2 | 9.6.3-beta.1 |
4
- | npm @trezor/connect-web | 9.6.2 | 9.6.3-beta.1 |
5
- | npm @trezor/connect-webextension | 9.6.2 | 9.6.3-beta.1 |
6
- | npm @trezor/connect-mobile | 9.6.2 | 9.6.3-beta.1 |
3
+ | npm @trezor/connect | 9.6.2 | 9.6.3-beta.2 |
4
+ | npm @trezor/connect-web | 9.6.2 | 9.6.3-beta.2 |
5
+ | npm @trezor/connect-webextension | 9.6.2 | 9.6.3-beta.2 |
6
+ | npm @trezor/connect-mobile | 9.6.2 | 9.6.3-beta.2 |
7
7
 
8
8
  | Deployment | Stable | Canary |
9
9
  | :----------------: | :----: | :----------: |
10
- | connect.trezor.io/ | 9.6.2 | 9.6.3-beta.1 |
10
+ | connect.trezor.io/ | 9.6.2 | 9.6.3-beta.2 |
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.3-beta.2
15
+
16
+ - feat(connect): trezor bridge pinging now runs in a worker to prevent spamming developer console
17
+ - chore(connect): stellar code is now wrapped in a worker in the same way other coins are wrapped
18
+
14
19
  # 9.6.3-beta.1
15
20
 
16
21
  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-beta.1
3
+ API version 9.6.3-beta.2
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)
@@ -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>;
21
20
  destination: {
22
21
  hash: Uint8Array<ArrayBufferLike>;
23
22
  tag: number;
24
23
  };
24
+ source: Uint8Array<ArrayBufferLike>;
25
25
  counter: number;
26
26
  gas_limit: number;
27
27
  storage_limit: number;
@@ -1,4 +1,4 @@
1
- export declare const VERSION = "9.6.3-beta.1";
1
+ export declare const VERSION = "9.6.3-beta.2";
2
2
  export declare const DEFAULT_DOMAIN_MAJOR_VER: string;
3
3
  export declare const DEFAULT_DOMAIN: string;
4
4
  export declare const CONTENT_SCRIPT_VERSION = 1;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DEEPLINK_VERSION = exports.CONTENT_SCRIPT_VERSION = exports.DEFAULT_DOMAIN = exports.DEFAULT_DOMAIN_MAJOR_VER = exports.VERSION = void 0;
4
- exports.VERSION = '9.6.3-beta.1';
4
+ exports.VERSION = '9.6.3-beta.2';
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_MAJOR_VER = `https://connect.trezor.io/${versionN[0]}/`;
@@ -259,7 +259,7 @@ class Device extends utils_1.TypedEmitter {
259
259
  return this.runPromise;
260
260
  }
261
261
  async interrupt(reason) {
262
- await (0, thp_1.abortThpWorkflow)(this, () => this.runAbort?.abort(reason));
262
+ await (0, thp_1.abortThpWorkflow)(this);
263
263
  await this.currentSession?.abort(reason);
264
264
  this.runAbort?.abort(reason);
265
265
  await this.currentRun;
@@ -36,6 +36,6 @@ type ThpCallResponse = {
36
36
  };
37
37
  type ThpMessagePayload<T extends MessageKey = MessageKey> = ThpMessage[T];
38
38
  export declare const thpCall: <T extends MessageKey>(device: Device, name: T, data: ThpMessagePayload<T>) => Promise<ThpCallResponse[T]>;
39
- export declare const abortThpWorkflow: (device: Device, abort?: () => any) => Promise<void>;
39
+ export declare const abortThpWorkflow: (device: Device) => Promise<void>;
40
40
  export {};
41
41
  //# sourceMappingURL=thpCall.d.ts.map
@@ -34,7 +34,7 @@ const thpCall = async (device, name, data) => {
34
34
  return result.payload;
35
35
  };
36
36
  exports.thpCall = thpCall;
37
- const abortThpWorkflow = async (device, abort) => {
37
+ const abortThpWorkflow = async (device) => {
38
38
  const thpState = device.getThpState();
39
39
  if (!thpState || !device.currentRun) {
40
40
  return Promise.resolve();
@@ -47,9 +47,6 @@ const abortThpWorkflow = async (device, abort) => {
47
47
  else if (thpState.cancelablePromise) {
48
48
  thpState.sync('send', 'Cancel');
49
49
  await device.getCurrentSession().send('Cancel', {});
50
- if (abort) {
51
- abort();
52
- }
53
50
  await device.currentRun;
54
51
  }
55
52
  };
@@ -134,6 +134,9 @@ class CoreInModule {
134
134
  this._log.enabled = !!this._settings.debug;
135
135
  }
136
136
  setTransports({ transports }) {
137
+ if (!transports?.length) {
138
+ transports = ['BridgeTransport', 'WebUsbTransport'];
139
+ }
137
140
  this._settings = (0, connectSettings_1.parseConnectSettings)({ ...this._settings, transports });
138
141
  this.handleCoreMessage({
139
142
  type: events_2.TRANSPORT.SET_TRANSPORTS,
@@ -109,7 +109,7 @@ export type UnreadableDevice = BaseDevice & {
109
109
  availableTranslations?: typeof undefined;
110
110
  transportSessionOwner?: undefined;
111
111
  hid: boolean;
112
- bluetoothProps?: BluetoothDeviceProps;
112
+ bluetoothProps?: typeof undefined;
113
113
  };
114
114
  export type Device = KnownDevice | UnknownDevice | UnreadableDevice;
115
115
  export type Features = PROTO.Features;
@@ -1,18 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.tryLocalAssetRequire = exports.firmwareReleaseConfigAssets = exports.getReleaseAsset = exports.getReleasesAssetByDeviceModelAndFirmwareType = void 0;
4
- const firmware_1 = require("@trezor/connect-common/files/firmware");
4
+ const connect_common_1 = require("@trezor/connect-common");
5
5
  const device_utils_1 = require("@trezor/device-utils");
6
6
  const getReleasesAssetByDeviceModelAndFirmwareType = (deviceModel, firmwareType) => {
7
7
  const firmwareTypeInFileName = firmwareType === device_utils_1.FirmwareType.BitcoinOnly ? 'bitcoinonly' : 'universal';
8
- return firmware_1.firmwareAssets[deviceModel.toLowerCase()][firmwareTypeInFileName];
8
+ return connect_common_1.firmwareAssets[deviceModel.toLowerCase()][firmwareTypeInFileName];
9
9
  };
10
10
  exports.getReleasesAssetByDeviceModelAndFirmwareType = getReleasesAssetByDeviceModelAndFirmwareType;
11
11
  const getReleaseAsset = (deviceModel, version, firmwareType) => {
12
12
  const firmwareTypeInFileName = firmwareType === device_utils_1.FirmwareType.BitcoinOnly ? 'bitcoinonly' : 'universal';
13
13
  const fileName = `${deviceModel.toLowerCase()}-${version.join('.')}-${firmwareTypeInFileName}`;
14
14
  const deviceModelLower = deviceModel.toLowerCase();
15
- const asset = firmware_1.firmwareAssets?.[deviceModelLower]?.[firmwareTypeInFileName]?.[fileName];
15
+ const asset = connect_common_1.firmwareAssets?.[deviceModelLower]?.[firmwareTypeInFileName]?.[fileName];
16
16
  return asset;
17
17
  };
18
18
  exports.getReleaseAsset = getReleaseAsset;
@@ -11,88 +11,69 @@ const JWS_CONFIG = {
11
11
  REMOTE_FILENAME: 'releases.v1.json',
12
12
  REQUEST_TIMEOUT_MS: 5000,
13
13
  };
14
- const fetchRemoteJWS = async () => {
14
+ const fetchRemoteJws = async () => {
15
15
  const { BASE_URL, MIDDLE_PATH, env } = (0, firmwareInfo_1.getOnlineFirmwareBaseUrl)();
16
- const remoteReleasesUrl = new URL(BASE_URL);
17
- remoteReleasesUrl.pathname = `${MIDDLE_PATH}/${env === 'production' ? 'config/' : ''}${JWS_CONFIG.REMOTE_FILENAME}`;
16
+ const path = `${MIDDLE_PATH}/${env === 'production' ? 'config/' : ''}${JWS_CONFIG.REMOTE_FILENAME}`;
17
+ const remoteReleasesUrl = new URL(path, BASE_URL);
18
18
  try {
19
19
  const controller = new AbortController();
20
- const timeoutId = setTimeout(() => controller.abort(), JWS_CONFIG.REQUEST_TIMEOUT_MS);
20
+ const timeoutId = setTimeout(() => controller.abort('Request timed out'), JWS_CONFIG.REQUEST_TIMEOUT_MS);
21
21
  const response = await fetch(remoteReleasesUrl.toString(), { signal: controller.signal });
22
22
  clearTimeout(timeoutId);
23
23
  if (!response.ok) {
24
- throw new Error(`Fetching error with status: ${response.status}`);
24
+ throw new Error(`HTTP error! Status: ${response.status}`);
25
25
  }
26
26
  const data = await response.json();
27
- return { jws: data.jws, source: 'remote', env };
27
+ if (typeof data.jws !== 'string') {
28
+ throw new Error('Invalid response format: "jws" property missing or not a string.');
29
+ }
30
+ return { jws: data.jws, env };
28
31
  }
29
32
  catch (error) {
30
- console.error(`Fetching remote firmware release failed: ${error}. Falling back to local config.`);
31
- return { jws: assetUtils_1.firmwareReleaseConfigAssets.jws, source: 'local', env };
33
+ throw new Error(`Failed to fetch remote JWS: ${error instanceof Error ? error.message : String(error)}`);
32
34
  }
33
35
  };
34
- const decodeJwsPayload = (jws) => {
36
+ const verifyAndDecodeJws = (jws, publicKey) => {
35
37
  const decoded = (0, jws_1.decode)(jws);
36
- if (!decoded || !decoded.payload) {
37
- throw new Error('Failed to decode JWS or payload is missing.');
38
+ if (!decoded || !decoded.payload || !decoded.header) {
39
+ throw new Error('Invalid JWS structure.');
38
40
  }
39
- return JSON.parse(decoded.payload);
40
- };
41
- const verifyJwsSignature = (jws, publicKey) => {
42
- const decoded = (0, jws_1.decode)(jws);
43
- if (decoded?.header.alg !== JWS_CONFIG.SIGN_ALGORITHM) {
44
- throw new Error(`Invalid JWS algorithm: expected ${JWS_CONFIG.SIGN_ALGORITHM}, got ${decoded?.header.alg}`);
41
+ const parsedPayload = JSON.parse(decoded.payload);
42
+ if (decoded.header.alg !== JWS_CONFIG.SIGN_ALGORITHM) {
43
+ throw new Error('Invalid JWS algorithm');
44
+ }
45
+ if (parsedPayload.version !== JWS_CONFIG.VERSION) {
46
+ throw new Error('Config version mismatch.');
45
47
  }
46
48
  if (!(0, jws_1.verify)(jws, JWS_CONFIG.SIGN_ALGORITHM, publicKey)) {
47
49
  throw new Error('JWS signature is invalid.');
48
50
  }
51
+ return parsedPayload;
49
52
  };
50
53
  const getFirmwareReleaseConfig = async () => {
51
- const { jws: remoteJws, source: initialSource, env } = await fetchRemoteJWS();
52
- let finalJws = remoteJws;
53
- let finalSource = initialSource;
54
- let config;
55
- if (initialSource === 'remote') {
56
- try {
57
- const remotePayload = decodeJwsPayload(remoteJws);
58
- const localPayload = decodeJwsPayload(assetUtils_1.firmwareReleaseConfigAssets.jws);
59
- if (localPayload.version !== JWS_CONFIG.VERSION) {
60
- throw new Error(`Local config has mismatched version: ${localPayload.version}`);
61
- }
62
- if (localPayload.sequence >= remotePayload.sequence) {
63
- finalJws = assetUtils_1.firmwareReleaseConfigAssets.jws;
64
- finalSource = 'local';
65
- config = localPayload;
66
- }
67
- else {
68
- config = remotePayload;
69
- }
70
- }
71
- catch (error) {
72
- console.error(`Error comparing remote/local JWS: ${error}. Using remote as is.`);
54
+ try {
55
+ const { jws, env } = await fetchRemoteJws();
56
+ const useProductionKey = ['test-signed', 'production'].includes(env);
57
+ const publicKey = (0, env_utils_1.getFirmwareReleaseJwsPublicKey)(useProductionKey);
58
+ const remoteConfig = verifyAndDecodeJws(jws, publicKey);
59
+ if (remoteConfig.sequence > assetUtils_1.firmwareReleaseConfigAssets.sequence) {
60
+ return {
61
+ config: remoteConfig,
62
+ isRemote: true,
63
+ };
73
64
  }
74
65
  }
75
- const useProductionKey = ['test-signed', 'production'].includes(env) || finalSource === 'local';
76
- const publicKey = (0, env_utils_1.getFirmwareReleaseJwsPublicKey)(useProductionKey);
77
- verifyJwsSignature(finalJws, publicKey);
78
- if (!config) {
79
- config = decodeJwsPayload(finalJws);
66
+ catch {
80
67
  }
81
68
  return {
82
- config,
83
- isRemote: finalSource === 'remote',
84
- };
85
- };
86
- exports.getFirmwareReleaseConfig = getFirmwareReleaseConfig;
87
- const getOnlyLocalFirmwareReleaseConfig = () => {
88
- const localJws = assetUtils_1.firmwareReleaseConfigAssets.jws;
89
- const publicKey = (0, env_utils_1.getFirmwareReleaseJwsPublicKey)(true);
90
- verifyJwsSignature(localJws, publicKey);
91
- const config = decodeJwsPayload(localJws);
92
- return {
93
- config,
69
+ config: assetUtils_1.firmwareReleaseConfigAssets,
94
70
  isRemote: false,
95
71
  };
96
72
  };
73
+ exports.getFirmwareReleaseConfig = getFirmwareReleaseConfig;
74
+ const getOnlyLocalFirmwareReleaseConfig = () => ({
75
+ config: assetUtils_1.firmwareReleaseConfigAssets,
76
+ isRemote: false,
77
+ });
97
78
  exports.getOnlyLocalFirmwareReleaseConfig = getOnlyLocalFirmwareReleaseConfig;
98
79
  //# sourceMappingURL=firmwareReleaseConfigUtils.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trezor/connect",
3
- "version": "9.6.3-beta.1",
3
+ "version": "9.6.3-beta.2",
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.",
@@ -83,14 +83,14 @@
83
83
  "@trezor/blockchain-link-types": "1.4.3-beta.1",
84
84
  "@trezor/blockchain-link-utils": "1.4.3-beta.1",
85
85
  "@trezor/connect-analytics": "1.3.5",
86
- "@trezor/connect-common": "0.4.3-beta.1",
86
+ "@trezor/connect-common": "0.4.3-beta.2",
87
87
  "@trezor/crypto-utils": "1.1.4",
88
- "@trezor/device-utils": "1.1.3-beta.1",
88
+ "@trezor/device-utils": "1.1.3-beta.2",
89
89
  "@trezor/env-utils": "^1.4.3-beta.1",
90
90
  "@trezor/protobuf": "1.4.3-beta.1",
91
91
  "@trezor/protocol": "1.2.9-beta.1",
92
92
  "@trezor/schema-utils": "1.3.4",
93
- "@trezor/transport": "1.5.3-beta.1",
93
+ "@trezor/transport": "1.5.3-beta.2",
94
94
  "@trezor/type-utils": "1.1.9-beta.1",
95
95
  "@trezor/utils": "9.4.3-beta.1",
96
96
  "@trezor/utxo-lib": "2.4.3-beta.1",