@trezor/connect 9.0.7 → 9.0.9

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 (82) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +1 -1
  3. package/lib/api/bitcoin/createPendingTx.d.ts +34 -0
  4. package/lib/api/bitcoin/createPendingTx.js +59 -0
  5. package/lib/api/bitcoin/index.d.ts +1 -0
  6. package/lib/api/bitcoin/index.js +1 -0
  7. package/lib/api/blockchainGetAccountBalanceHistory.d.ts +1 -1
  8. package/lib/api/blockchainGetCurrentFiatRates.d.ts +2 -1
  9. package/lib/api/blockchainGetCurrentFiatRates.js +6 -1
  10. package/lib/api/blockchainGetFiatRatesForTimestamps.d.ts +3 -1
  11. package/lib/api/blockchainGetFiatRatesForTimestamps.js +9 -1
  12. package/lib/api/blockchainGetTransactions.d.ts +1 -1
  13. package/lib/api/cardano/cardanoAuxiliaryData.js +43 -23
  14. package/lib/api/cardanoSignTransaction.d.ts +2 -1
  15. package/lib/api/cardanoSignTransaction.js +21 -11
  16. package/lib/api/composeTransaction.js +2 -2
  17. package/lib/api/ethereum/ethereumDefinitions.d.ts +7 -0
  18. package/lib/api/ethereum/ethereumDefinitions.js +43 -0
  19. package/lib/api/ethereum/ethereumSignTx.d.ts +3 -2
  20. package/lib/api/ethereum/ethereumSignTx.js +4 -2
  21. package/lib/api/ethereumGetAddress.d.ts +2 -1
  22. package/lib/api/ethereumGetAddress.js +19 -2
  23. package/lib/api/ethereumSignMessage.js +13 -0
  24. package/lib/api/ethereumSignTransaction.js +10 -3
  25. package/lib/api/ethereumSignTypedData.js +14 -0
  26. package/lib/api/firmware/getBinary.d.ts +3 -12
  27. package/lib/api/firmware/getBinary.js +5 -9
  28. package/lib/api/firmwareUpdate.d.ts +3 -2
  29. package/lib/api/firmwareUpdate.js +4 -5
  30. package/lib/api/getAccountInfo.d.ts +8 -8
  31. package/lib/api/getAccountInfo.js +1 -1
  32. package/lib/api/setBusy.js +1 -4
  33. package/lib/api/setProxy.js +1 -1
  34. package/lib/api/signTransaction.js +10 -2
  35. package/lib/api/unlockPath.js +1 -4
  36. package/lib/backend/Blockchain.d.ts +3 -0
  37. package/lib/core/AbstractMethod.d.ts +1 -0
  38. package/lib/core/AbstractMethod.js +9 -0
  39. package/lib/core/index.js +17 -8
  40. package/lib/data/DataManager.d.ts +92 -15
  41. package/lib/data/DataManager.js +3 -54
  42. package/lib/data/config.js +9 -3
  43. package/lib/data/connectSettings.d.ts +0 -1
  44. package/lib/data/connectSettings.js +10 -57
  45. package/lib/data/firmwareInfo.js +48 -46
  46. package/lib/data/transportInfo.d.ts +1 -0
  47. package/lib/data/transportInfo.js +14 -1
  48. package/lib/data/udevInfo.d.ts +1 -0
  49. package/lib/data/udevInfo.js +14 -1
  50. package/lib/data/version.d.ts +1 -1
  51. package/lib/data/version.js +1 -1
  52. package/lib/device/DescriptorStream.js +1 -1
  53. package/lib/device/DeviceCommands.d.ts +1 -1
  54. package/lib/device/DeviceCommands.js +2 -1
  55. package/lib/device/DeviceList.d.ts +1 -2
  56. package/lib/device/DeviceList.js +20 -10
  57. package/lib/events/iframe.d.ts +2 -1
  58. package/lib/events/popup.d.ts +2 -1
  59. package/lib/index.js +1 -4
  60. package/lib/types/api/bitcoin/index.d.ts +2 -0
  61. package/lib/types/api/cardano/index.d.ts +10 -9
  62. package/lib/types/api/firmwareUpdate.d.ts +2 -1
  63. package/lib/types/firmware.d.ts +2 -3
  64. package/lib/types/index.d.ts +1 -1
  65. package/lib/types/settings.d.ts +1 -1
  66. package/lib/utils/firmwareUtils.d.ts +0 -1
  67. package/lib/utils/firmwareUtils.js +1 -9
  68. package/lib/utils/pathUtils.d.ts +1 -0
  69. package/lib/utils/pathUtils.js +3 -1
  70. package/lib/utils/promiseUtils.d.ts +5 -1
  71. package/lib/utils/promiseUtils.js +7 -3
  72. package/lib/utils/urlUtils.d.ts +2 -1
  73. package/lib/utils/urlUtils.js +18 -3
  74. package/lib/utils/versionUtils.d.ts +3 -1
  75. package/lib/utils/versionUtils.js +5 -2
  76. package/package.json +12 -13
  77. package/lib/device/AbortController.d.ts +0 -21
  78. package/lib/device/AbortController.js +0 -40
  79. package/lib/utils/browserUtils.d.ts +0 -21
  80. package/lib/utils/browserUtils.js +0 -100
  81. package/lib/utils/windowsUtils.d.ts +0 -2
  82. package/lib/utils/windowsUtils.js +0 -6
@@ -1,39 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DataManager = void 0;
4
- const tslib_1 = require("tslib");
5
- const parse_uri_1 = tslib_1.__importDefault(require("parse-uri"));
6
4
  const assets_1 = require("../utils/assets");
7
- const connectSettings_1 = require("./connectSettings");
8
5
  const coinInfo_1 = require("./coinInfo");
9
6
  const firmwareInfo_1 = require("./firmwareInfo");
10
7
  const transportInfo_1 = require("./transportInfo");
11
8
  const config_1 = require("./config");
12
9
  class DataManager {
13
10
  static async load(settings, withAssets = true) {
14
- var _a;
15
11
  const ts = settings.env === 'web' ? `?r=${settings.timestamp}` : '';
16
12
  this.settings = settings;
17
- const isLocalhost = typeof window !== 'undefined' && window.location
18
- ? window.location.hostname === 'localhost'
19
- : true;
20
- const whitelist = DataManager.isWhitelisted(this.settings.origin || '');
21
- this.settings.trustedHost = (isLocalhost || !!whitelist) && !this.settings.popup;
22
- if (!this.settings.trustedHost) {
23
- this.settings.popup = true;
24
- }
25
- if (!this.settings.trustedHost && !whitelist) {
26
- this.settings.debug = false;
27
- }
28
- this.settings.priority = DataManager.getPriority(whitelist);
29
- const knownHost = DataManager.getHostLabel(this.settings.extension || this.settings.origin || '');
30
- if (knownHost) {
31
- this.settings.hostLabel = knownHost.label;
32
- this.settings.hostIcon = knownHost.icon;
33
- }
34
- if (this.settings.popup && this.settings.env !== 'webextension') {
35
- this.settings.transports = (_a = this.settings.transports) === null || _a === void 0 ? void 0 : _a.filter((transport) => transport !== 'WebUsbTransport');
36
- }
37
13
  if (!withAssets)
38
14
  return;
39
15
  const assetPromises = config_1.config.assets.map(async (asset) => {
@@ -50,36 +26,6 @@ class DataManager {
50
26
  static getProtobufMessages() {
51
27
  return this.messages;
52
28
  }
53
- static isWhitelisted(origin) {
54
- const uri = (0, parse_uri_1.default)(origin);
55
- if (uri && typeof uri.host === 'string') {
56
- const parts = uri.host.split('.');
57
- if (parts.length > 2) {
58
- uri.host = parts.slice(parts.length - 2, parts.length).join('.');
59
- }
60
- return config_1.config.whitelist.find(item => item.origin === origin || item.origin === uri.host);
61
- }
62
- }
63
- static isManagementAllowed() {
64
- var _a;
65
- const uri = (0, parse_uri_1.default)((_a = this.settings.origin) !== null && _a !== void 0 ? _a : '');
66
- if (uri && typeof uri.host === 'string') {
67
- const parts = uri.host.split('.');
68
- if (parts.length > 2) {
69
- uri.host = parts.slice(parts.length - 2, parts.length).join('.');
70
- }
71
- return config_1.config.management.find(item => item.origin === this.settings.origin || item.origin === uri.host);
72
- }
73
- }
74
- static getPriority(whitelist) {
75
- if (whitelist) {
76
- return whitelist.priority;
77
- }
78
- return connectSettings_1.DEFAULT_PRIORITY;
79
- }
80
- static getHostLabel(origin) {
81
- return config_1.config.knownHosts.find(host => host.origin === origin);
82
- }
83
29
  static getSettings(key) {
84
30
  if (!this.settings)
85
31
  return null;
@@ -88,6 +34,9 @@ class DataManager {
88
34
  }
89
35
  return this.settings;
90
36
  }
37
+ static getConfig() {
38
+ return config_1.config;
39
+ }
91
40
  }
92
41
  exports.DataManager = DataManager;
93
42
  DataManager.assets = {};
@@ -101,7 +101,7 @@ exports.config = {
101
101
  ],
102
102
  },
103
103
  {
104
- coin: ['eth', 'trop', 'tgor'],
104
+ coin: ['eth', 'tgor'],
105
105
  min: ['1.8.0', '2.1.0'],
106
106
  comment: ['There were protobuf backwards incompatible changes.'],
107
107
  },
@@ -182,8 +182,14 @@ exports.config = {
182
182
  },
183
183
  {
184
184
  capabilities: ['coinjoin'],
185
- methods: ['authorizeCoinjoin', 'getOwnershipId', 'getOwnershipProof'],
186
- min: ['0', '2.5.3'],
185
+ methods: [
186
+ 'authorizeCoinjoin',
187
+ 'getOwnershipId',
188
+ 'getOwnershipProof',
189
+ 'setBusy',
190
+ 'unlockPath',
191
+ ],
192
+ min: ['1.12.1', '2.5.3'],
187
193
  },
188
194
  ],
189
195
  };
@@ -1,6 +1,5 @@
1
1
  import type { ConnectSettings } from '../types';
2
2
  export declare const DEFAULT_PRIORITY = 2;
3
- export declare const getEnv: () => "web" | "webextension" | "electron" | "react-native";
4
3
  export declare const corsValidator: (url?: string) => string | undefined;
5
4
  export declare const parseConnectSettings: (input?: Partial<ConnectSettings>) => ConnectSettings;
6
5
  //# sourceMappingURL=connectSettings.d.ts.map
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseConnectSettings = exports.corsValidator = exports.getEnv = exports.DEFAULT_PRIORITY = void 0;
3
+ exports.parseConnectSettings = exports.corsValidator = exports.DEFAULT_PRIORITY = void 0;
4
4
  const version_1 = require("./version");
5
5
  exports.DEFAULT_PRIORITY = 2;
6
6
  const initialSettings = {
@@ -8,16 +8,15 @@ const initialSettings = {
8
8
  version: version_1.VERSION,
9
9
  debug: false,
10
10
  priority: exports.DEFAULT_PRIORITY,
11
- trustedHost: false,
11
+ trustedHost: true,
12
12
  connectSrc: version_1.DEFAULT_DOMAIN,
13
13
  iframeSrc: `${version_1.DEFAULT_DOMAIN}iframe.html`,
14
- popup: true,
14
+ popup: false,
15
15
  popupSrc: `${version_1.DEFAULT_DOMAIN}popup.html`,
16
16
  webusbSrc: `${version_1.DEFAULT_DOMAIN}webusb.html`,
17
17
  transports: undefined,
18
18
  pendingTransportEvent: true,
19
- supportedBrowser: typeof navigator !== 'undefined' ? !/Trident|MSIE|Edge/.test(navigator.userAgent) : true,
20
- env: 'web',
19
+ env: 'node',
21
20
  lazyLoad: false,
22
21
  timestamp: new Date().getTime(),
23
22
  interactionTimeout: 600,
@@ -34,25 +33,6 @@ const parseManifest = (manifest) => {
34
33
  appUrl: manifest.appUrl,
35
34
  };
36
35
  };
37
- const getEnv = () => {
38
- if (typeof chrome !== 'undefined' &&
39
- chrome.runtime &&
40
- typeof chrome.runtime.onConnect !== 'undefined') {
41
- return 'webextension';
42
- }
43
- if (typeof navigator !== 'undefined') {
44
- if (typeof navigator.product === 'string' &&
45
- navigator.product.toLowerCase() === 'reactnative') {
46
- return 'react-native';
47
- }
48
- const userAgent = navigator.userAgent.toLowerCase();
49
- if (userAgent.indexOf(' electron/') > -1) {
50
- return 'electron';
51
- }
52
- }
53
- return 'web';
54
- };
55
- exports.getEnv = getEnv;
56
36
  const corsValidator = (url) => {
57
37
  if (typeof url !== 'string')
58
38
  return;
@@ -67,10 +47,9 @@ const corsValidator = (url) => {
67
47
  };
68
48
  exports.corsValidator = corsValidator;
69
49
  const parseConnectSettings = (input = {}) => {
50
+ var _a;
70
51
  const settings = { ...initialSettings };
71
- if (Object.prototype.hasOwnProperty.call(input, 'debug')) {
72
- if (Array.isArray(input)) {
73
- }
52
+ if ('debug' in input) {
74
53
  if (typeof input.debug === 'boolean') {
75
54
  settings.debug = input.debug;
76
55
  }
@@ -78,30 +57,11 @@ const parseConnectSettings = (input = {}) => {
78
57
  settings.debug = input.debug === 'true';
79
58
  }
80
59
  }
81
- if (typeof input.connectSrc === 'string') {
82
- settings.connectSrc = input.connectSrc;
83
- }
84
- let globalSrc;
85
- if (typeof window !== 'undefined') {
86
- globalSrc = window.__TREZOR_CONNECT_SRC;
87
- }
88
- else if (typeof global !== 'undefined') {
89
- globalSrc = global.__TREZOR_CONNECT_SRC;
60
+ if (typeof input.connectSrc === 'string' && ((_a = input.connectSrc) === null || _a === void 0 ? void 0 : _a.startsWith('http'))) {
61
+ settings.connectSrc = (0, exports.corsValidator)(input.connectSrc);
90
62
  }
91
- if (typeof globalSrc === 'string') {
92
- settings.connectSrc = (0, exports.corsValidator)(globalSrc);
93
- settings.debug = true;
94
- }
95
- if (typeof window !== 'undefined' &&
96
- window.location &&
97
- typeof window.location.search === 'string') {
98
- const vars = window.location.search.split('&');
99
- const customUrl = vars.find(v => v.indexOf('trezor-connect-src') >= 0);
100
- if (customUrl) {
101
- const [, connectSrc] = customUrl.split('=');
102
- settings.connectSrc = (0, exports.corsValidator)(decodeURIComponent(connectSrc));
103
- settings.debug = true;
104
- }
63
+ else if (settings.trustedHost) {
64
+ settings.connectSrc = input.connectSrc;
105
65
  }
106
66
  const src = settings.connectSrc || version_1.DEFAULT_DOMAIN;
107
67
  settings.iframeSrc = `${src}iframe.html`;
@@ -125,19 +85,12 @@ const parseConnectSettings = (input = {}) => {
125
85
  if (typeof input.pendingTransportEvent === 'boolean') {
126
86
  settings.pendingTransportEvent = input.pendingTransportEvent;
127
87
  }
128
- if (typeof window !== 'undefined' && window.location && window.location.protocol === 'file:') {
129
- settings.origin = `file://${window.location.pathname}`;
130
- settings.webusb = false;
131
- }
132
88
  if (typeof input.extension === 'string') {
133
89
  settings.extension = input.extension;
134
90
  }
135
91
  if (typeof input.env === 'string') {
136
92
  settings.env = input.env;
137
93
  }
138
- else {
139
- settings.env = (0, exports.getEnv)();
140
- }
141
94
  if (typeof input.timestamp === 'number') {
142
95
  settings.timestamp = input.timestamp;
143
96
  }
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getReleases = exports.getRelease = exports.getFirmwareStatus = exports.getInfo = exports.parseFirmware = void 0;
4
4
  const utils_1 = require("@trezor/utils");
5
5
  const firmwareUtils_1 = require("../utils/firmwareUtils");
6
+ const versionUtils_1 = require("../utils/versionUtils");
6
7
  const releases = {};
7
8
  releases[1] = [];
8
9
  releases[2] = [];
@@ -51,67 +52,68 @@ const isRequired = (changelog) => {
51
52
  return changelog.some(item => item.required);
52
53
  };
53
54
  const isEqual = (release, latest) => utils_1.versionUtils.isEqual(release.version, latest.version);
54
- const getInfo = ({ features, releases }) => {
55
- if (!(0, firmwareUtils_1.isStrictFeatures)(features)) {
56
- throw new Error('Features of unexpected shape provided.');
55
+ const getT1BootloaderVersion = (releases, features) => {
56
+ const { bootloader_mode, major_version, minor_version, patch_version } = features;
57
+ const versionArray = [major_version, minor_version, patch_version];
58
+ if (bootloader_mode) {
59
+ return versionArray;
57
60
  }
58
- if (!(0, firmwareUtils_1.isValidReleases)(releases)) {
59
- throw new Error(`Release object in unexpected shape.`);
61
+ const release = releases.find(({ version }) => utils_1.versionUtils.isEqual(version, versionArray));
62
+ return (release === null || release === void 0 ? void 0 : release.bootloader_version) || [1, 0, 0];
63
+ };
64
+ const getIntermediaryVersion = (releases, features, offerLatest) => {
65
+ if (features.major_version !== 1 || offerLatest) {
66
+ return;
60
67
  }
61
- let parsedReleases = releases;
62
- let score = 0;
63
- if (features.device_id) {
64
- score = (0, firmwareUtils_1.getScore)(features.device_id);
68
+ const bootloaderVersion = getT1BootloaderVersion(releases, features);
69
+ if (utils_1.versionUtils.isNewerOrEqual(bootloaderVersion, [1, 12, 0])) {
70
+ return 3;
65
71
  }
72
+ if (utils_1.versionUtils.isNewerOrEqual(bootloaderVersion, [1, 8, 0])) {
73
+ return 2;
74
+ }
75
+ return 1;
76
+ };
77
+ const getSafeReleases = ({ features, releases }) => {
66
78
  const { bootloader_mode, major_version, minor_version, patch_version, fw_major, fw_minor, fw_patch, } = features;
67
- if (score) {
68
- parsedReleases = parsedReleases.filter(item => {
69
- if (!item.rollout)
70
- return true;
71
- return item.rollout >= score;
72
- });
79
+ const firmwareVersion = [major_version, minor_version, patch_version];
80
+ if (!(0, versionUtils_1.isVersionArray)(firmwareVersion)) {
81
+ return [];
73
82
  }
74
- const latest = parsedReleases[0];
75
83
  if (major_version === 2 && bootloader_mode) {
76
- if (fw_major !== null && fw_minor !== null && fw_patch !== null) {
77
- parsedReleases = (0, firmwareUtils_1.filterSafeListByFirmware)(parsedReleases, [
78
- fw_major,
79
- fw_minor,
80
- fw_patch,
81
- ]);
84
+ const fwVersion = [fw_major, fw_minor, fw_patch];
85
+ if ((0, versionUtils_1.isVersionArray)(fwVersion)) {
86
+ return (0, firmwareUtils_1.filterSafeListByFirmware)(releases, fwVersion);
82
87
  }
83
- parsedReleases = (0, firmwareUtils_1.filterSafeListByBootloader)(parsedReleases, [
84
- major_version,
85
- minor_version,
86
- patch_version,
87
- ]);
88
+ return (0, firmwareUtils_1.filterSafeListByBootloader)(releases, firmwareVersion);
89
+ }
90
+ if (major_version === 1 && bootloader_mode) {
91
+ return (0, firmwareUtils_1.filterSafeListByBootloader)(releases, firmwareVersion);
88
92
  }
89
- else if (major_version === 1 && bootloader_mode) {
90
- parsedReleases = (0, firmwareUtils_1.filterSafeListByBootloader)(parsedReleases, [
91
- major_version,
92
- minor_version,
93
- patch_version,
94
- ]);
93
+ return (0, firmwareUtils_1.filterSafeListByFirmware)(releases, firmwareVersion);
94
+ };
95
+ const getInfo = ({ features, releases }) => {
96
+ if (!(0, firmwareUtils_1.isStrictFeatures)(features)) {
97
+ throw new Error('Features of unexpected shape provided.');
95
98
  }
96
- else {
97
- parsedReleases = (0, firmwareUtils_1.filterSafeListByFirmware)(parsedReleases, [
98
- major_version,
99
- minor_version,
100
- patch_version,
101
- ]);
99
+ if (!(0, firmwareUtils_1.isValidReleases)(releases)) {
100
+ throw new Error(`Release object in unexpected shape.`);
102
101
  }
103
- if (!parsedReleases.length) {
102
+ const latest = releases[0];
103
+ const releasesSafe = getSafeReleases({ features, releases });
104
+ if (!releasesSafe.length) {
104
105
  return null;
105
106
  }
106
- const isLatest = isEqual(parsedReleases[0], latest);
107
- const changelog = getChangelog(parsedReleases, features);
107
+ const releasesParsed = features.major_version === 1 ? releases : releasesSafe;
108
+ const changelog = getChangelog(releasesParsed, features);
109
+ const release = releasesParsed[0];
110
+ const intermediaryVersion = getIntermediaryVersion(releases, features, isEqual(releasesSafe[0], latest));
108
111
  return {
109
112
  changelog,
110
- release: parsedReleases[0],
111
- isLatest,
112
- latest,
113
+ release,
113
114
  isRequired: isRequired(changelog),
114
- isNewer: isNewer(parsedReleases[0], features),
115
+ isNewer: isNewer(latest, features),
116
+ intermediaryVersion,
115
117
  };
116
118
  };
117
119
  exports.getInfo = getInfo;
@@ -1,4 +1,5 @@
1
1
  import type { BridgeInfo } from '../events/transport';
2
2
  export declare const parseBridgeJSON: (json: any) => BridgeInfo;
3
3
  export declare const getBridgeInfo: () => BridgeInfo;
4
+ export declare const suggestBridgeInstaller: (platform?: string) => BridgeInfo;
4
5
  //# sourceMappingURL=transportInfo.d.ts.map
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getBridgeInfo = exports.parseBridgeJSON = void 0;
3
+ exports.suggestBridgeInstaller = exports.getBridgeInfo = exports.parseBridgeJSON = void 0;
4
4
  const info = {
5
5
  version: [],
6
6
  directory: '',
@@ -26,4 +26,17 @@ const parseBridgeJSON = (json) => {
26
26
  exports.parseBridgeJSON = parseBridgeJSON;
27
27
  const getBridgeInfo = () => info;
28
28
  exports.getBridgeInfo = getBridgeInfo;
29
+ const suggestBridgeInstaller = (platform) => {
30
+ const info = (0, exports.getBridgeInfo)();
31
+ if (!info.packages.find(p => p.preferred)) {
32
+ if (platform) {
33
+ info.packages = info.packages.map(p => ({
34
+ ...p,
35
+ preferred: p.platform.indexOf(platform) >= 0,
36
+ }));
37
+ }
38
+ }
39
+ return info;
40
+ };
41
+ exports.suggestBridgeInstaller = suggestBridgeInstaller;
29
42
  //# sourceMappingURL=transportInfo.js.map
@@ -1,3 +1,4 @@
1
1
  import type { UdevInfo } from '../events/transport';
2
2
  export declare const getUdevInfo: () => UdevInfo;
3
+ export declare const suggestUdevInstaller: (platform?: string) => UdevInfo;
3
4
  //# sourceMappingURL=udevInfo.d.ts.map
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getUdevInfo = void 0;
3
+ exports.suggestUdevInstaller = exports.getUdevInfo = void 0;
4
4
  const info = {
5
5
  directory: '',
6
6
  packages: [
@@ -18,4 +18,17 @@ const info = {
18
18
  };
19
19
  const getUdevInfo = () => info;
20
20
  exports.getUdevInfo = getUdevInfo;
21
+ const suggestUdevInstaller = (platform) => {
22
+ const info = (0, exports.getUdevInfo)();
23
+ if (!info.packages.find(p => p.preferred)) {
24
+ if (platform) {
25
+ info.packages = info.packages.map(p => ({
26
+ ...p,
27
+ preferred: p.platform.indexOf(platform) >= 0,
28
+ }));
29
+ }
30
+ }
31
+ return info;
32
+ };
33
+ exports.suggestUdevInstaller = suggestUdevInstaller;
21
34
  //# sourceMappingURL=udevInfo.js.map
@@ -1,3 +1,3 @@
1
- export declare const VERSION = "9.0.7";
1
+ export declare const VERSION = "9.0.9";
2
2
  export declare const DEFAULT_DOMAIN: string;
3
3
  //# sourceMappingURL=version.d.ts.map
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DEFAULT_DOMAIN = exports.VERSION = void 0;
4
- exports.VERSION = '9.0.7';
4
+ exports.VERSION = '9.0.9';
5
5
  const versionN = exports.VERSION.split('.').map(s => parseInt(s, 10));
6
6
  exports.DEFAULT_DOMAIN = `https://connect.trezor.io/${versionN[0]}/`;
7
7
  //# sourceMappingURL=version.js.map
@@ -88,7 +88,7 @@ class DescriptorStream extends events_1.default {
88
88
  const time = new Date().getTime() - this.listenTimestamp;
89
89
  logger.debug('Listen error', 'timestamp', time, typeof error);
90
90
  if (time > 1100) {
91
- await (0, promiseUtils_1.resolveAfter)(1000, null);
91
+ await (0, promiseUtils_1.resolveAfter)(1000, null).promise;
92
92
  if (this.listening)
93
93
  this.listen();
94
94
  }
@@ -40,7 +40,7 @@ export declare class DeviceCommands {
40
40
  serializedPath: string;
41
41
  address: string;
42
42
  }>;
43
- ethereumGetAddress({ address_n, show_display }: Messages.EthereumGetAddress): Promise<{
43
+ ethereumGetAddress({ address_n, show_display, encoded_network, }: Messages.EthereumGetAddress): Promise<{
44
44
  path: number[];
45
45
  serializedPath: string;
46
46
  address: string;
@@ -184,10 +184,11 @@ class DeviceCommands {
184
184
  address: response.message.address,
185
185
  };
186
186
  }
187
- async ethereumGetAddress({ address_n, show_display }) {
187
+ async ethereumGetAddress({ address_n, show_display, encoded_network, }) {
188
188
  const response = await this.typedCall('EthereumGetAddress', 'EthereumAddress', {
189
189
  address_n,
190
190
  show_display,
191
+ encoded_network,
191
192
  });
192
193
  return {
193
194
  path: address_n,
@@ -5,7 +5,6 @@ import { TRANSPORT, DEVICE, TransportInfo } from '../events';
5
5
  import { DescriptorStream } from './DescriptorStream';
6
6
  import { Device } from './Device';
7
7
  import type { Device as DeviceTyped } from '../types';
8
- import type { Controller } from './AbortController';
9
8
  type LowLevelPlugin = {
10
9
  name: 'WebUsbPlugin' | 'ReactNativePlugin';
11
10
  unreadableHidDeviceChange: {
@@ -44,7 +43,7 @@ export declare class DeviceList extends EventEmitter {
44
43
  penalizedDevices: {
45
44
  [deviceID: string]: number;
46
45
  };
47
- fetchController?: Controller | null;
46
+ fetchController?: AbortController | null;
48
47
  constructor();
49
48
  init(): Promise<void>;
50
49
  resolveTransportEvent(): void;
@@ -14,9 +14,9 @@ const transportInfo_1 = require("../data/transportInfo");
14
14
  const debug_1 = require("../utils/debug");
15
15
  const promiseUtils_1 = require("../utils/promiseUtils");
16
16
  const workers_1 = require("../workers/workers");
17
- const AbortController_1 = require("./AbortController");
18
17
  const { BridgeV2, Fallback } = transport_1.default;
19
18
  const _log = (0, debug_1.initLog)('DeviceList');
19
+ let autoResolveTransportEventTimeout;
20
20
  class DeviceList extends events_1.default {
21
21
  constructor() {
22
22
  var _a;
@@ -25,11 +25,11 @@ class DeviceList extends events_1.default {
25
25
  this.creatingDevicesDescriptors = {};
26
26
  this.transportStartPending = 0;
27
27
  this.penalizedDevices = {};
28
- const { env } = DataManager_1.DataManager.settings;
29
- let { transports: transportSettings } = DataManager_1.DataManager.settings;
28
+ const env = DataManager_1.DataManager.getSettings('env');
29
+ let transportSettings = DataManager_1.DataManager.getSettings('transports');
30
30
  const transports = [];
31
31
  if (!(transportSettings === null || transportSettings === void 0 ? void 0 : transportSettings.length)) {
32
- transportSettings = ['BridgeTransport', 'WebUsbTransport'];
32
+ transportSettings = ['BridgeTransport'];
33
33
  }
34
34
  if (env === 'react-native' && typeof workers_1.ReactNativeUsbPlugin !== 'undefined') {
35
35
  transports.push((0, workers_1.ReactNativeUsbPlugin)());
@@ -38,7 +38,7 @@ class DeviceList extends events_1.default {
38
38
  const bridgeLatestVersion = (0, transportInfo_1.getBridgeInfo)().version.join('.');
39
39
  const bridge = new BridgeV2(undefined, undefined);
40
40
  bridge.setBridgeLatestVersion(bridgeLatestVersion);
41
- this.fetchController = (0, AbortController_1.getAbortController)();
41
+ this.fetchController = new AbortController();
42
42
  const { signal } = this.fetchController;
43
43
  const fetchWithSignal = (args, options = {}) => (0, cross_fetch_1.default)(args, { ...options, signal });
44
44
  const isNode = !!((_a = process === null || process === void 0 ? void 0 : process.release) === null || _a === void 0 ? void 0 : _a.name) && process.release.name.search(/node|io\.js/) !== -1;
@@ -92,9 +92,15 @@ class DeviceList extends events_1.default {
92
92
  const stream = new DescriptorStream_1.DescriptorStream(this.transport);
93
93
  stream.on(events_2.TRANSPORT.START_PENDING, (pending) => {
94
94
  this.transportStartPending = pending;
95
+ autoResolveTransportEventTimeout = setTimeout(() => {
96
+ this.resolveTransportEvent();
97
+ }, 5000);
95
98
  });
96
99
  stream.on(events_2.TRANSPORT.START, () => {
97
100
  this.emit(events_2.TRANSPORT.START, this.getTransportInfo());
101
+ if (autoResolveTransportEventTimeout) {
102
+ clearTimeout(autoResolveTransportEventTimeout);
103
+ }
98
104
  });
99
105
  stream.on(events_2.TRANSPORT.UPDATE, (diff) => {
100
106
  new DiffHandler(this, diff).handle();
@@ -176,6 +182,9 @@ class DeviceList extends events_1.default {
176
182
  if (this.stream) {
177
183
  this.stream.stop();
178
184
  }
185
+ if (autoResolveTransportEventTimeout) {
186
+ clearTimeout(autoResolveTransportEventTimeout);
187
+ }
179
188
  await Promise.all(this.allDevices().map(device => device.dispose()));
180
189
  if (this.transport) {
181
190
  this.transport.stop();
@@ -236,20 +245,21 @@ class CreateDeviceHandler {
236
245
  this.path = descriptor.path.toString();
237
246
  }
238
247
  async handle() {
248
+ var _a;
239
249
  this.list.creatingDevicesDescriptors[this.path] = this.descriptor;
240
250
  try {
241
251
  await this._takeAndCreateDevice();
242
252
  }
243
253
  catch (error) {
244
254
  _log.debug('Cannot create device', error);
245
- if (error.code === 'Device_NotFound') {
255
+ if (error.code === 'Device_NotFound' || error.message === 'device not found') {
246
256
  }
247
257
  else if (error.message === constants_1.ERRORS.WRONG_PREVIOUS_SESSION_ERROR_MESSAGE ||
248
258
  error.toString() === constants_1.ERRORS.WEBUSB_ERROR_MESSAGE) {
249
259
  this.list.enumerate();
250
260
  this._handleUsedElsewhere();
251
261
  }
252
- else if (error.message.indexOf(constants_1.ERRORS.LIBUSB_ERROR_MESSAGE) >= 0) {
262
+ else if (((_a = error.message) === null || _a === void 0 ? void 0 : _a.indexOf(constants_1.ERRORS.LIBUSB_ERROR_MESSAGE)) >= 0) {
253
263
  const device = this.list._createUnreadableDevice(this.list.creatingDevicesDescriptors[this.path], error.message);
254
264
  this.list.devices[this.path] = device;
255
265
  this.list.emit(events_2.DEVICE.CONNECT_UNACQUIRED, device.toMessageObject());
@@ -261,7 +271,7 @@ class CreateDeviceHandler {
261
271
  this._handleUsedElsewhere();
262
272
  }
263
273
  else {
264
- await (0, promiseUtils_1.resolveAfter)(501, null);
274
+ await (0, promiseUtils_1.resolveAfter)(501, null).promise;
265
275
  await this.handle();
266
276
  }
267
277
  }
@@ -335,7 +345,7 @@ class DiffHandler {
335
345
  const penalty = this.list.getAuthPenalty();
336
346
  _log.debug('Connected', priority, penalty, descriptor.session, this.list.devices);
337
347
  if (priority || penalty) {
338
- await (0, promiseUtils_1.resolveAfter)(501 + penalty + 100 * priority, null);
348
+ await (0, promiseUtils_1.resolveAfter)(501 + penalty + 100 * priority, null).promise;
339
349
  }
340
350
  if (descriptor.session == null) {
341
351
  await this.list._createAndSaveDevice(descriptor);
@@ -361,7 +371,7 @@ class DiffHandler {
361
371
  const device = this.list.devices[path];
362
372
  if (device) {
363
373
  if (device.isUnacquired() && !device.isInconsistent()) {
364
- await (0, promiseUtils_1.resolveAfter)(501, null);
374
+ await (0, promiseUtils_1.resolveAfter)(501, null).promise;
365
375
  _log.debug('Create device from unacquired', device);
366
376
  await this.list._createAndSaveDevice(descriptor);
367
377
  }
@@ -1,5 +1,5 @@
1
1
  import { UI_EVENT } from './ui-request';
2
- import type { ConnectSettings } from '../types';
2
+ import type { ConnectSettings, SystemInfo } from '../types';
3
3
  import type { MessageFactoryFn } from '../types/utils';
4
4
  export declare const IFRAME: {
5
5
  readonly BOOTSTRAP: "iframe-bootstrap";
@@ -19,6 +19,7 @@ export interface IFrameLoaded {
19
19
  type: typeof IFRAME.LOADED;
20
20
  payload: {
21
21
  useBroadcastChannel: boolean;
22
+ systemInfo: SystemInfo;
22
23
  };
23
24
  }
24
25
  export interface IFrameInit {
@@ -1,6 +1,6 @@
1
1
  import { UI_EVENT } from './ui-request';
2
2
  import type { TransportInfo } from './transport';
3
- import type { ConnectSettings } from '../types';
3
+ import type { ConnectSettings, SystemInfo } from '../types';
4
4
  import type { MessageFactoryFn } from '../types/utils';
5
5
  export declare const POPUP: {
6
6
  readonly BOOTSTRAP: "popup-bootstrap";
@@ -18,6 +18,7 @@ export interface PopupInit {
18
18
  payload: {
19
19
  settings: ConnectSettings;
20
20
  useBroadcastChannel: boolean;
21
+ systemInfo: SystemInfo;
21
22
  };
22
23
  }
23
24
  export interface PopupHandshake {
package/lib/index.js CHANGED
@@ -94,10 +94,7 @@ const init = async (settings = {}) => {
94
94
  if (_core) {
95
95
  throw constants_1.ERRORS.TypedError('Init_AlreadyInitialized');
96
96
  }
97
- _settings = (0, connectSettings_1.parseConnectSettings)({ ..._settings, ...settings });
98
- _settings.origin = 'http://node.trezor.io/';
99
- _settings.popup = false;
100
- _settings.env = 'node';
97
+ _settings = (0, connectSettings_1.parseConnectSettings)({ ..._settings, ...settings, popup: false });
101
98
  if (!_settings.manifest) {
102
99
  throw constants_1.ERRORS.TypedError('Init_ManifestMissing');
103
100
  }