@trezor/connect 9.0.0-beta.2 → 9.0.0-beta.5
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/README.md +15 -4
- package/lib/api/cardano/cardanoInputs.d.ts +1 -0
- package/lib/api/cardano/cardanoInputs.js +12 -1
- package/lib/api/cardano/cardanoOutputs.d.ts +6 -3
- package/lib/api/cardano/cardanoOutputs.js +37 -1
- package/lib/api/cardano/cardanoUtils.d.ts +3 -0
- package/lib/api/cardano/cardanoUtils.js +17 -0
- package/lib/api/cardano/cardanoWitnesses.js +4 -4
- package/lib/api/cardanoSignTransaction.d.ts +7 -3
- package/lib/api/cardanoSignTransaction.js +40 -17
- package/lib/api/firmware/calculateFirmwareHash.d.ts +6 -0
- package/lib/api/firmware/calculateFirmwareHash.js +26 -0
- package/lib/api/firmware/getBinary.d.ts +2 -2
- package/lib/api/firmware/getBinary.js +2 -3
- package/lib/api/firmware/index.d.ts +5 -0
- package/lib/api/firmware/index.js +13 -0
- package/lib/api/firmware/modifyFirmware.d.ts +3 -5
- package/lib/api/firmware/modifyFirmware.js +12 -10
- package/lib/api/{management → firmware}/uploadFirmware.d.ts +0 -0
- package/lib/api/{management → firmware}/uploadFirmware.js +0 -0
- package/lib/api/firmwareUpdate.d.ts +4 -1
- package/lib/api/firmwareUpdate.js +8 -13
- package/lib/api/getFirmwareHash.d.ts +7 -0
- package/lib/api/getFirmwareHash.js +29 -0
- package/lib/api/index.d.ts +1 -0
- package/lib/api/index.js +4 -2
- package/lib/constants/errors.js +1 -1
- package/lib/core/index.d.ts +1 -1
- package/lib/core/method.d.ts +1 -1
- package/lib/data/firmwareInfo.js +0 -9
- package/lib/data/version.d.ts +1 -1
- package/lib/data/version.js +1 -1
- package/lib/factory.js +1 -0
- package/lib/types/api/cardanoSignTransaction.d.ts +12 -4
- package/lib/types/api/firmwareUpdate.d.ts +6 -3
- package/lib/types/api/getFirmwareHash.d.ts +4 -0
- package/lib/types/api/getFirmwareHash.js +3 -0
- package/lib/types/api/index.d.ts +2 -0
- package/lib/utils/assetUtils.d.ts +2 -0
- package/lib/utils/assetUtils.js +22 -0
- package/lib/utils/assets-native.d.ts +2 -0
- package/lib/utils/assets-native.js +7 -0
- package/lib/utils/assets.js +5 -13
- package/package.json +11 -7
- package/CHANGELOG.md +0 -26
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# @trezor/connect API version 9.0.0-beta.
|
|
1
|
+
# @trezor/connect API version 9.0.0-beta.5
|
|
2
2
|
|
|
3
3
|
[](https://github.com/trezor/trezor-suite/actions/workflows/connect-test.yml)
|
|
4
4
|
[](https://www.npmjs.org/package/@trezor/connect)
|
|
@@ -21,13 +21,14 @@ Version 9+ will be available as `@trezor/connect` and `@trezor/connect-web` npm
|
|
|
21
21
|
|
|
22
22
|
## Step by step release process
|
|
23
23
|
|
|
24
|
-
- Make sure you have released all [npm dependencies](../../releases/npm-packages.md)
|
|
25
|
-
-
|
|
24
|
+
- Make sure you have released all [npm dependencies](../../releases/npm-packages.md).
|
|
25
|
+
- Optional: if unsure run `node ./ci/scripts/check-npm-dependencies.js connect`. Please note that this script will report unreleased dependencies even for changes that do not affect runtime (READMEs etc.)
|
|
26
|
+
- bump version in all @trezor/connect\* packages (except plugin packages). `yarn workspace @trezor/connect version:<beta|patch|minor|major>`
|
|
26
27
|
- make sure CHANGELOG files have been updated
|
|
27
28
|
- merge into develop branch
|
|
28
29
|
- from develop branch create a pull requests into branch `release/connect-v9`
|
|
29
30
|
- gitlab: click manual release `@trezor/connect-web` and `@trezor/connect` into npm
|
|
30
|
-
- gitlab: click manual
|
|
31
|
+
- gitlab: click manual deploy job to connect.trezor.io/9
|
|
31
32
|
|
|
32
33
|
## Version 8 (stable)
|
|
33
34
|
|
|
@@ -43,6 +44,16 @@ With regards to this repo - All updates should go to current version branch, the
|
|
|
43
44
|
|
|
44
45
|
For deployment process of trezor-connect v8 refer to [trezor/connect repository](https://github.com/trezor/connect/blob/develop/docs/deployment/index.md)
|
|
45
46
|
|
|
47
|
+
## Docs
|
|
48
|
+
|
|
49
|
+
Interactive API explorer is available on https://connect.trezor.io/9/#/
|
|
50
|
+
|
|
51
|
+
Documentation is available [docs/packages/connect](../../docs/packages/connect/index.md)
|
|
52
|
+
|
|
53
|
+
## Examples
|
|
54
|
+
|
|
55
|
+
A collection of examples on how to implement @trezor/connect in various environments is available in [packages/connect-examples](../connect-examples/README.md)
|
|
56
|
+
|
|
46
57
|
## Tests
|
|
47
58
|
|
|
48
59
|
For integration testing against trezord and emulator refer to [this document](https://github.com/trezor/trezor-suite/blob/develop/packages/integration-tests/projects/connect/README.md).
|
|
@@ -10,4 +10,5 @@ export declare type CollateralInputWithPath = {
|
|
|
10
10
|
};
|
|
11
11
|
export declare const transformInput: (input: any) => InputWithPath;
|
|
12
12
|
export declare const transformCollateralInput: (collateralInput: any) => CollateralInputWithPath;
|
|
13
|
+
export declare const transformReferenceInput: (referenceInput: any) => PROTO.CardanoTxReferenceInput;
|
|
13
14
|
//# sourceMappingURL=cardanoInputs.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.transformCollateralInput = exports.transformInput = void 0;
|
|
3
|
+
exports.transformReferenceInput = exports.transformCollateralInput = exports.transformInput = void 0;
|
|
4
4
|
const paramsValidator_1 = require("../common/paramsValidator");
|
|
5
5
|
const pathUtils_1 = require("../../utils/pathUtils");
|
|
6
6
|
const transformInput = (input) => {
|
|
@@ -31,4 +31,15 @@ const transformCollateralInput = (collateralInput) => {
|
|
|
31
31
|
};
|
|
32
32
|
};
|
|
33
33
|
exports.transformCollateralInput = transformCollateralInput;
|
|
34
|
+
const transformReferenceInput = (referenceInput) => {
|
|
35
|
+
(0, paramsValidator_1.validateParams)(referenceInput, [
|
|
36
|
+
{ name: 'prev_hash', type: 'string', required: true },
|
|
37
|
+
{ name: 'prev_index', type: 'number', required: true },
|
|
38
|
+
]);
|
|
39
|
+
return {
|
|
40
|
+
prev_hash: referenceInput.prev_hash,
|
|
41
|
+
prev_index: referenceInput.prev_index,
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
exports.transformReferenceInput = transformReferenceInput;
|
|
34
45
|
//# sourceMappingURL=cardanoInputs.js.map
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import type { AssetGroupWithTokens } from './cardanoTokenBundle';
|
|
2
|
-
import
|
|
3
|
-
export declare type
|
|
2
|
+
import { PROTO } from '../../constants';
|
|
3
|
+
export declare type OutputWithData = {
|
|
4
4
|
output: PROTO.CardanoTxOutput;
|
|
5
5
|
tokenBundle?: AssetGroupWithTokens[];
|
|
6
|
+
inlineDatum?: string;
|
|
7
|
+
referenceScript?: string;
|
|
6
8
|
};
|
|
7
|
-
export declare const transformOutput: (output: any) =>
|
|
9
|
+
export declare const transformOutput: (output: any) => OutputWithData;
|
|
10
|
+
export declare const sendOutput: (typedCall: any, outputWithData: OutputWithData) => Promise<void>;
|
|
8
11
|
//# sourceMappingURL=cardanoOutputs.d.ts.map
|
|
@@ -1,22 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.transformOutput = void 0;
|
|
3
|
+
exports.sendOutput = exports.transformOutput = void 0;
|
|
4
4
|
const paramsValidator_1 = require("../common/paramsValidator");
|
|
5
5
|
const cardanoAddressParameters_1 = require("./cardanoAddressParameters");
|
|
6
6
|
const cardanoTokenBundle_1 = require("./cardanoTokenBundle");
|
|
7
|
+
const cardanoUtils_1 = require("./cardanoUtils");
|
|
7
8
|
const transformOutput = (output) => {
|
|
8
9
|
(0, paramsValidator_1.validateParams)(output, [
|
|
9
10
|
{ name: 'address', type: 'string' },
|
|
10
11
|
{ name: 'amount', type: 'uint', required: true },
|
|
11
12
|
{ name: 'tokenBundle', type: 'array', allowEmpty: true },
|
|
12
13
|
{ name: 'datumHash', type: 'string' },
|
|
14
|
+
{ name: 'format', type: 'number' },
|
|
15
|
+
{ name: 'inlineDatum', type: 'string' },
|
|
16
|
+
{ name: 'referenceScript', type: 'string' },
|
|
13
17
|
]);
|
|
14
18
|
const result = {
|
|
15
19
|
output: {
|
|
16
20
|
amount: output.amount,
|
|
17
21
|
asset_groups_count: 0,
|
|
18
22
|
datum_hash: output.datumHash,
|
|
23
|
+
format: output.format,
|
|
24
|
+
inline_datum_size: output.inlineDatum
|
|
25
|
+
? (0, cardanoUtils_1.hexStringByteLength)(output.inlineDatum)
|
|
26
|
+
: undefined,
|
|
27
|
+
reference_script_size: output.referenceScript
|
|
28
|
+
? (0, cardanoUtils_1.hexStringByteLength)(output.referenceScript)
|
|
29
|
+
: undefined,
|
|
19
30
|
},
|
|
31
|
+
inlineDatum: output.inlineDatum,
|
|
32
|
+
referenceScript: output.referenceScript,
|
|
20
33
|
};
|
|
21
34
|
if (output.addressParameters) {
|
|
22
35
|
(0, cardanoAddressParameters_1.validateAddressParameters)(output.addressParameters);
|
|
@@ -35,4 +48,27 @@ const transformOutput = (output) => {
|
|
|
35
48
|
return result;
|
|
36
49
|
};
|
|
37
50
|
exports.transformOutput = transformOutput;
|
|
51
|
+
const sendOutput = async (typedCall, outputWithData) => {
|
|
52
|
+
const MAX_CHUNK_SIZE = 1024 * 2;
|
|
53
|
+
const { output, tokenBundle, inlineDatum, referenceScript } = outputWithData;
|
|
54
|
+
await typedCall('CardanoTxOutput', 'CardanoTxItemAck', output);
|
|
55
|
+
if (tokenBundle) {
|
|
56
|
+
for (const assetGroup of tokenBundle) {
|
|
57
|
+
await typedCall('CardanoAssetGroup', 'CardanoTxItemAck', {
|
|
58
|
+
policy_id: assetGroup.policyId,
|
|
59
|
+
tokens_count: assetGroup.tokens.length,
|
|
60
|
+
});
|
|
61
|
+
for (const token of assetGroup.tokens) {
|
|
62
|
+
await typedCall('CardanoToken', 'CardanoTxItemAck', token);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (inlineDatum) {
|
|
67
|
+
await (0, cardanoUtils_1.sendChunkedHexString)(typedCall, inlineDatum, MAX_CHUNK_SIZE, 'CardanoTxInlineDatumChunk');
|
|
68
|
+
}
|
|
69
|
+
if (referenceScript) {
|
|
70
|
+
await (0, cardanoUtils_1.sendChunkedHexString)(typedCall, referenceScript, MAX_CHUNK_SIZE, 'CardanoTxReferenceScriptChunk');
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
exports.sendOutput = sendOutput;
|
|
38
74
|
//# sourceMappingURL=cardanoOutputs.js.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sendChunkedHexString = exports.hexStringByteLength = void 0;
|
|
4
|
+
const hexStringByteLength = (s) => s.length / 2;
|
|
5
|
+
exports.hexStringByteLength = hexStringByteLength;
|
|
6
|
+
const sendChunkedHexString = async (typedCall, data, chunkSize, messageType) => {
|
|
7
|
+
let processedSize = 0;
|
|
8
|
+
while (processedSize < data.length) {
|
|
9
|
+
const chunk = data.slice(processedSize, processedSize + chunkSize);
|
|
10
|
+
await typedCall(messageType, 'CardanoTxItemAck', {
|
|
11
|
+
data: chunk,
|
|
12
|
+
});
|
|
13
|
+
processedSize += chunkSize;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
exports.sendChunkedHexString = sendChunkedHexString;
|
|
17
|
+
//# sourceMappingURL=cardanoUtils.js.map
|
|
@@ -34,11 +34,11 @@ const gatherWitnessPaths = (inputsWithPath, certificatesWithPoolOwnersAndRelays,
|
|
|
34
34
|
if (path)
|
|
35
35
|
_insert(path);
|
|
36
36
|
});
|
|
37
|
-
requiredSigners.forEach(({ key_path }) => {
|
|
38
|
-
if (key_path)
|
|
39
|
-
_insert(key_path);
|
|
40
|
-
});
|
|
41
37
|
}
|
|
38
|
+
requiredSigners.forEach(({ key_path }) => {
|
|
39
|
+
if (key_path)
|
|
40
|
+
_insert(key_path);
|
|
41
|
+
});
|
|
42
42
|
additionalWitnessRequests.forEach(path => {
|
|
43
43
|
_insert(path);
|
|
44
44
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AbstractMethod } from '../core/AbstractMethod';
|
|
2
2
|
import type { CertificateWithPoolOwnersAndRelays } from './cardano/cardanoCertificate';
|
|
3
|
-
import
|
|
4
|
-
import type {
|
|
3
|
+
import { Path, InputWithPath, CollateralInputWithPath } from './cardano/cardanoInputs';
|
|
4
|
+
import type { OutputWithData } from './cardano/cardanoOutputs';
|
|
5
5
|
import { PROTO } from '../constants';
|
|
6
6
|
import type { CardanoSignedTxData } from '../types/api/cardanoSignTransaction';
|
|
7
7
|
import type { AssetGroupWithTokens } from './cardano/cardanoTokenBundle';
|
|
@@ -14,11 +14,12 @@ declare const CardanoSignTransactionFeatures: Readonly<{
|
|
|
14
14
|
ScriptDataHash: string[];
|
|
15
15
|
Plutus: string[];
|
|
16
16
|
KeyHashStakeCredential: string[];
|
|
17
|
+
Babbage: string[];
|
|
17
18
|
}>;
|
|
18
19
|
export declare type CardanoSignTransactionParams = {
|
|
19
20
|
signingMode: PROTO.CardanoTxSigningMode;
|
|
20
21
|
inputsWithPath: InputWithPath[];
|
|
21
|
-
|
|
22
|
+
outputsWithData: OutputWithData[];
|
|
22
23
|
fee: PROTO.UintType;
|
|
23
24
|
ttl?: PROTO.UintType;
|
|
24
25
|
certificatesWithPoolOwnersAndRelays: CertificateWithPoolOwnersAndRelays[];
|
|
@@ -29,6 +30,9 @@ export declare type CardanoSignTransactionParams = {
|
|
|
29
30
|
scriptDataHash?: string;
|
|
30
31
|
collateralInputsWithPath: CollateralInputWithPath[];
|
|
31
32
|
requiredSigners: PROTO.CardanoTxRequiredSigner[];
|
|
33
|
+
collateralReturnWithData?: OutputWithData;
|
|
34
|
+
totalCollateral?: PROTO.UintType;
|
|
35
|
+
referenceInputs: PROTO.CardanoTxReferenceInput[];
|
|
32
36
|
protocolMagic: number;
|
|
33
37
|
networkId: number;
|
|
34
38
|
witnessPaths: Path[];
|
|
@@ -20,6 +20,7 @@ const CardanoSignTransactionFeatures = Object.freeze({
|
|
|
20
20
|
ScriptDataHash: ['0', '2.4.4'],
|
|
21
21
|
Plutus: ['0', '2.4.4'],
|
|
22
22
|
KeyHashStakeCredential: ['0', '2.4.4'],
|
|
23
|
+
Babbage: ['0', '2.5.2'],
|
|
23
24
|
});
|
|
24
25
|
class CardanoSignTransaction extends AbstractMethod_1.AbstractMethod {
|
|
25
26
|
init() {
|
|
@@ -46,6 +47,8 @@ class CardanoSignTransaction extends AbstractMethod_1.AbstractMethod {
|
|
|
46
47
|
{ name: 'scriptDataHash', type: 'string' },
|
|
47
48
|
{ name: 'collateralInputs', type: 'array', allowEmpty: true },
|
|
48
49
|
{ name: 'requiredSigners', type: 'array', allowEmpty: true },
|
|
50
|
+
{ name: 'totalCollateral', type: 'uint' },
|
|
51
|
+
{ name: 'referenceInputs', type: 'array', allowEmpty: true },
|
|
49
52
|
{ name: 'protocolMagic', type: 'number', required: true },
|
|
50
53
|
{ name: 'networkId', type: 'number', required: true },
|
|
51
54
|
{ name: 'additionalWitnessRequests', type: 'array', allowEmpty: true },
|
|
@@ -53,7 +56,7 @@ class CardanoSignTransaction extends AbstractMethod_1.AbstractMethod {
|
|
|
53
56
|
{ name: 'includeNetworkId', type: 'boolean' },
|
|
54
57
|
]);
|
|
55
58
|
const inputsWithPath = payload.inputs.map(cardanoInputs_1.transformInput);
|
|
56
|
-
const
|
|
59
|
+
const outputsWithData = payload.outputs.map(cardanoOutputs_1.transformOutput);
|
|
57
60
|
let certificatesWithPoolOwnersAndRelays = [];
|
|
58
61
|
if (payload.certificates) {
|
|
59
62
|
certificatesWithPoolOwnersAndRelays = payload.certificates.map(cardanoCertificate_1.transformCertificate);
|
|
@@ -102,10 +105,17 @@ class CardanoSignTransaction extends AbstractMethod_1.AbstractMethod {
|
|
|
102
105
|
};
|
|
103
106
|
});
|
|
104
107
|
}
|
|
108
|
+
const collateralReturnWithData = payload.collateralReturn
|
|
109
|
+
? (0, cardanoOutputs_1.transformOutput)(payload.collateralReturn)
|
|
110
|
+
: undefined;
|
|
111
|
+
let referenceInputs = [];
|
|
112
|
+
if (payload.referenceInputs) {
|
|
113
|
+
referenceInputs = payload.referenceInputs.map(cardanoInputs_1.transformReferenceInput);
|
|
114
|
+
}
|
|
105
115
|
this.params = {
|
|
106
116
|
signingMode: payload.signingMode,
|
|
107
117
|
inputsWithPath,
|
|
108
|
-
|
|
118
|
+
outputsWithData,
|
|
109
119
|
fee: payload.fee,
|
|
110
120
|
ttl: payload.ttl,
|
|
111
121
|
certificatesWithPoolOwnersAndRelays,
|
|
@@ -116,6 +126,9 @@ class CardanoSignTransaction extends AbstractMethod_1.AbstractMethod {
|
|
|
116
126
|
scriptDataHash: payload.scriptDataHash,
|
|
117
127
|
collateralInputsWithPath,
|
|
118
128
|
requiredSigners,
|
|
129
|
+
collateralReturnWithData,
|
|
130
|
+
totalCollateral: payload.totalCollateral,
|
|
131
|
+
referenceInputs,
|
|
119
132
|
protocolMagic: payload.protocolMagic,
|
|
120
133
|
networkId: payload.networkId,
|
|
121
134
|
witnessPaths: (0, cardanoWitnesses_1.gatherWitnessPaths)(inputsWithPath, certificatesWithPoolOwnersAndRelays, withdrawals, collateralInputsWithPath, requiredSigners, additionalWitnessRequests, payload.signingMode),
|
|
@@ -142,7 +155,7 @@ class CardanoSignTransaction extends AbstractMethod_1.AbstractMethod {
|
|
|
142
155
|
this._ensureFeatureIsSupported('KeyHashStakeCredential');
|
|
143
156
|
}
|
|
144
157
|
});
|
|
145
|
-
params.
|
|
158
|
+
params.outputsWithData.forEach(({ output }) => {
|
|
146
159
|
if (output.datum_hash) {
|
|
147
160
|
this._ensureFeatureIsSupported('OutputDatumHash');
|
|
148
161
|
}
|
|
@@ -168,6 +181,18 @@ class CardanoSignTransaction extends AbstractMethod_1.AbstractMethod {
|
|
|
168
181
|
if (params.signingMode === constants_1.PROTO.CardanoTxSigningMode.PLUTUS_TRANSACTION) {
|
|
169
182
|
this._ensureFeatureIsSupported('Plutus');
|
|
170
183
|
}
|
|
184
|
+
params.outputsWithData.forEach(({ output, inlineDatum, referenceScript }) => {
|
|
185
|
+
if (output.format === constants_1.PROTO.CardanoTxOutputSerializationFormat.MAP_BABBAGE ||
|
|
186
|
+
inlineDatum ||
|
|
187
|
+
referenceScript) {
|
|
188
|
+
this._ensureFeatureIsSupported('Babbage');
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
if (params.collateralReturnWithData ||
|
|
192
|
+
params.totalCollateral != null ||
|
|
193
|
+
params.referenceInputs.length > 0) {
|
|
194
|
+
this._ensureFeatureIsSupported('Babbage');
|
|
195
|
+
}
|
|
171
196
|
}
|
|
172
197
|
async _sign_tx() {
|
|
173
198
|
const typedCall = this.device.getCommands().typedCall.bind(this.device.getCommands());
|
|
@@ -177,7 +202,7 @@ class CardanoSignTransaction extends AbstractMethod_1.AbstractMethod {
|
|
|
177
202
|
protocol_magic: this.params.protocolMagic,
|
|
178
203
|
network_id: this.params.networkId,
|
|
179
204
|
inputs_count: this.params.inputsWithPath.length,
|
|
180
|
-
outputs_count: this.params.
|
|
205
|
+
outputs_count: this.params.outputsWithData.length,
|
|
181
206
|
fee: this.params.fee,
|
|
182
207
|
ttl: this.params.ttl,
|
|
183
208
|
certificates_count: this.params.certificatesWithPoolOwnersAndRelays.length,
|
|
@@ -189,6 +214,9 @@ class CardanoSignTransaction extends AbstractMethod_1.AbstractMethod {
|
|
|
189
214
|
script_data_hash: this.params.scriptDataHash,
|
|
190
215
|
collateral_inputs_count: this.params.collateralInputsWithPath.length,
|
|
191
216
|
required_signers_count: this.params.requiredSigners.length,
|
|
217
|
+
has_collateral_return: this.params.collateralReturnWithData != null,
|
|
218
|
+
total_collateral: this.params.totalCollateral,
|
|
219
|
+
reference_inputs_count: this.params.referenceInputs.length,
|
|
192
220
|
derivation_type: this.params.derivationType,
|
|
193
221
|
include_network_id: this.params.includeNetworkId,
|
|
194
222
|
};
|
|
@@ -196,19 +224,8 @@ class CardanoSignTransaction extends AbstractMethod_1.AbstractMethod {
|
|
|
196
224
|
for (const { input } of this.params.inputsWithPath) {
|
|
197
225
|
await typedCall('CardanoTxInput', 'CardanoTxItemAck', input);
|
|
198
226
|
}
|
|
199
|
-
for (const
|
|
200
|
-
await
|
|
201
|
-
if (tokenBundle) {
|
|
202
|
-
for (const assetGroup of tokenBundle) {
|
|
203
|
-
await typedCall('CardanoAssetGroup', 'CardanoTxItemAck', {
|
|
204
|
-
policy_id: assetGroup.policyId,
|
|
205
|
-
tokens_count: assetGroup.tokens.length,
|
|
206
|
-
});
|
|
207
|
-
for (const token of assetGroup.tokens) {
|
|
208
|
-
await typedCall('CardanoToken', 'CardanoTxItemAck', token);
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
}
|
|
227
|
+
for (const outputWithData of this.params.outputsWithData) {
|
|
228
|
+
await (0, cardanoOutputs_1.sendOutput)(typedCall, outputWithData);
|
|
212
229
|
}
|
|
213
230
|
for (const { certificate, poolOwners, poolRelays } of this.params
|
|
214
231
|
.certificatesWithPoolOwnersAndRelays) {
|
|
@@ -260,6 +277,12 @@ class CardanoSignTransaction extends AbstractMethod_1.AbstractMethod {
|
|
|
260
277
|
for (const requiredSigner of this.params.requiredSigners) {
|
|
261
278
|
await typedCall('CardanoTxRequiredSigner', 'CardanoTxItemAck', requiredSigner);
|
|
262
279
|
}
|
|
280
|
+
if (this.params.collateralReturnWithData) {
|
|
281
|
+
await (0, cardanoOutputs_1.sendOutput)(typedCall, this.params.collateralReturnWithData);
|
|
282
|
+
}
|
|
283
|
+
for (const referenceInput of this.params.referenceInputs) {
|
|
284
|
+
await typedCall('CardanoTxReferenceInput', 'CardanoTxItemAck', referenceInput);
|
|
285
|
+
}
|
|
263
286
|
const witnesses = [];
|
|
264
287
|
for (const path of this.params.witnessPaths) {
|
|
265
288
|
const { message } = await typedCall('CardanoTxWitnessRequest', 'CardanoTxWitnessResponse', { path });
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.calculateFirmwareHash = void 0;
|
|
4
|
+
const blakejs_1 = require("blakejs");
|
|
5
|
+
const SIZE_T1 = (7 * 128 + 64) * 1024;
|
|
6
|
+
const SIZE_TT = 13 * 128 * 1024;
|
|
7
|
+
const calculateFirmwareHash = (major_version, fw, key) => {
|
|
8
|
+
const size = major_version === 1 ? SIZE_T1 : SIZE_TT;
|
|
9
|
+
const padding = size - fw.byteLength;
|
|
10
|
+
if (padding < 0) {
|
|
11
|
+
throw new Error('Firmware too big');
|
|
12
|
+
}
|
|
13
|
+
const data = new Uint8Array(new ArrayBuffer(size));
|
|
14
|
+
data.set(new Uint8Array(fw));
|
|
15
|
+
if (padding > 0) {
|
|
16
|
+
const zeroBytes = Buffer.alloc(padding);
|
|
17
|
+
zeroBytes.fill(Buffer.from('ff', 'hex'));
|
|
18
|
+
data.set(zeroBytes, fw.byteLength);
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
hash: key && key.length > 0 ? (0, blakejs_1.blake2sHex)(data, key) : (0, blakejs_1.blake2sHex)(data),
|
|
22
|
+
challenge: key ? key.toString('hex') : '',
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
exports.calculateFirmwareHash = calculateFirmwareHash;
|
|
26
|
+
//# sourceMappingURL=calculateFirmwareHash.js.map
|
|
@@ -6,9 +6,9 @@ interface GetBinaryProps extends GetInfoProps {
|
|
|
6
6
|
intermediary?: boolean;
|
|
7
7
|
}
|
|
8
8
|
export declare const getBinary: ({ features, releases, baseUrl, version, btcOnly, intermediary, }: GetBinaryProps) => Promise<{
|
|
9
|
-
binary:
|
|
9
|
+
binary: any;
|
|
10
10
|
} | {
|
|
11
|
-
binary:
|
|
11
|
+
binary: any;
|
|
12
12
|
changelog: import("../..").FirmwareRelease[] | null;
|
|
13
13
|
release: import("../..").FirmwareRelease;
|
|
14
14
|
isLatest: boolean;
|
|
@@ -5,14 +5,13 @@ const utils_1 = require("@trezor/utils");
|
|
|
5
5
|
const assets_1 = require("../../utils/assets");
|
|
6
6
|
const firmwareUtils_1 = require("../../utils/firmwareUtils");
|
|
7
7
|
const firmwareInfo_1 = require("../../data/firmwareInfo");
|
|
8
|
-
const modifyFirmware_1 = require("./modifyFirmware");
|
|
9
8
|
const getBinary = async ({ features, releases, baseUrl, version, btcOnly, intermediary = false, }) => {
|
|
10
9
|
if (!(0, firmwareUtils_1.isStrictFeatures)(features)) {
|
|
11
10
|
throw new Error('Features of unexpected shape provided');
|
|
12
11
|
}
|
|
13
12
|
if (intermediary && features.major_version !== 2) {
|
|
14
13
|
const fw = await (0, assets_1.httpRequest)(`${baseUrl}/firmware/1/trezor-inter-1.10.0.bin`, 'binary');
|
|
15
|
-
return { binary:
|
|
14
|
+
return { binary: fw };
|
|
16
15
|
}
|
|
17
16
|
const infoByBootloader = (0, firmwareInfo_1.getInfo)({ features, releases });
|
|
18
17
|
const releaseByFirmware = releases.find(r => version &&
|
|
@@ -30,7 +29,7 @@ const getBinary = async ({ features, releases, baseUrl, version, btcOnly, interm
|
|
|
30
29
|
const fw = await (0, assets_1.httpRequest)(`${baseUrl}/${btcOnly ? releaseByFirmware.url_bitcoinonly : releaseByFirmware.url}`, 'binary');
|
|
31
30
|
return {
|
|
32
31
|
...infoByBootloader,
|
|
33
|
-
binary:
|
|
32
|
+
binary: fw,
|
|
34
33
|
};
|
|
35
34
|
};
|
|
36
35
|
exports.getBinary = getBinary;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { getBinary } from './getBinary';
|
|
2
|
+
export { shouldStripFwHeaders, stripFwHeaders } from './modifyFirmware';
|
|
3
|
+
export { uploadFirmware } from './uploadFirmware';
|
|
4
|
+
export { calculateFirmwareHash } from './calculateFirmwareHash';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.calculateFirmwareHash = exports.uploadFirmware = exports.stripFwHeaders = exports.shouldStripFwHeaders = exports.getBinary = void 0;
|
|
4
|
+
var getBinary_1 = require("./getBinary");
|
|
5
|
+
Object.defineProperty(exports, "getBinary", { enumerable: true, get: function () { return getBinary_1.getBinary; } });
|
|
6
|
+
var modifyFirmware_1 = require("./modifyFirmware");
|
|
7
|
+
Object.defineProperty(exports, "shouldStripFwHeaders", { enumerable: true, get: function () { return modifyFirmware_1.shouldStripFwHeaders; } });
|
|
8
|
+
Object.defineProperty(exports, "stripFwHeaders", { enumerable: true, get: function () { return modifyFirmware_1.stripFwHeaders; } });
|
|
9
|
+
var uploadFirmware_1 = require("./uploadFirmware");
|
|
10
|
+
Object.defineProperty(exports, "uploadFirmware", { enumerable: true, get: function () { return uploadFirmware_1.uploadFirmware; } });
|
|
11
|
+
var calculateFirmwareHash_1 = require("./calculateFirmwareHash");
|
|
12
|
+
Object.defineProperty(exports, "calculateFirmwareHash", { enumerable: true, get: function () { return calculateFirmwareHash_1.calculateFirmwareHash; } });
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const
|
|
3
|
-
|
|
4
|
-
features: StrictFeatures;
|
|
5
|
-
}) => ArrayBuffer;
|
|
1
|
+
import type { Features } from '../../types';
|
|
2
|
+
export declare const shouldStripFwHeaders: (features: Features) => boolean;
|
|
3
|
+
export declare const stripFwHeaders: (fw: ArrayBuffer) => ArrayBuffer;
|
|
6
4
|
//# sourceMappingURL=modifyFirmware.d.ts.map
|
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.stripFwHeaders = exports.shouldStripFwHeaders = void 0;
|
|
4
4
|
const utils_1 = require("@trezor/utils");
|
|
5
|
-
const
|
|
5
|
+
const shouldStripFwHeaders = (features) => {
|
|
6
6
|
if (features.major_version === 2)
|
|
7
|
-
return
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
return false;
|
|
8
|
+
return utils_1.versionUtils.isNewerOrEqual([features.major_version, features.minor_version, features.patch_version], [1, 8, 0]);
|
|
9
|
+
};
|
|
10
|
+
exports.shouldStripFwHeaders = shouldStripFwHeaders;
|
|
11
|
+
const stripFwHeaders = (fw) => {
|
|
12
|
+
const fwView = new Uint8Array(fw);
|
|
13
|
+
if (String.fromCharCode(...Array.from(fwView.slice(0, 4))) === 'TRZR' &&
|
|
14
|
+
String.fromCharCode(...Array.from(fwView.slice(256, 260))) === 'TRZF') {
|
|
15
|
+
return fw.slice(256);
|
|
14
16
|
}
|
|
15
17
|
return fw;
|
|
16
18
|
};
|
|
17
|
-
exports.
|
|
19
|
+
exports.stripFwHeaders = stripFwHeaders;
|
|
18
20
|
//# sourceMappingURL=modifyFirmware.js.map
|
|
File without changes
|
|
File without changes
|
|
@@ -9,7 +9,10 @@ declare type Params = {
|
|
|
9
9
|
export default class FirmwareUpdate extends AbstractMethod<'firmwareUpdate', Params> {
|
|
10
10
|
init(): void;
|
|
11
11
|
confirmation(): Promise<boolean>;
|
|
12
|
-
run(): Promise<
|
|
12
|
+
run(): Promise<{
|
|
13
|
+
hash: string;
|
|
14
|
+
challenge: string;
|
|
15
|
+
}>;
|
|
13
16
|
}
|
|
14
17
|
export {};
|
|
15
18
|
//# sourceMappingURL=firmwareUpdate.d.ts.map
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
4
|
-
const
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const randombytes_1 = (0, tslib_1.__importDefault)(require("randombytes"));
|
|
5
5
|
const AbstractMethod_1 = require("../core/AbstractMethod");
|
|
6
6
|
const constants_1 = require("../constants");
|
|
7
7
|
const events_1 = require("../events");
|
|
8
|
-
const
|
|
8
|
+
const firmware_1 = require("./firmware");
|
|
9
9
|
const paramsValidator_1 = require("./common/paramsValidator");
|
|
10
10
|
const firmwareInfo_1 = require("../data/firmwareInfo");
|
|
11
|
-
const firmwareUtils_1 = require("../utils/firmwareUtils");
|
|
12
11
|
class FirmwareUpdate extends AbstractMethod_1.AbstractMethod {
|
|
13
12
|
init() {
|
|
14
13
|
this.useEmptyPassphrase = true;
|
|
@@ -59,16 +58,10 @@ class FirmwareUpdate extends AbstractMethod_1.AbstractMethod {
|
|
|
59
58
|
let binary;
|
|
60
59
|
try {
|
|
61
60
|
if (params.binary) {
|
|
62
|
-
|
|
63
|
-
throw new Error('Features of unexpected shape provided');
|
|
64
|
-
}
|
|
65
|
-
binary = (0, modifyFirmware_1.modifyFirmware)({
|
|
66
|
-
fw: params.binary,
|
|
67
|
-
features: device.features,
|
|
68
|
-
});
|
|
61
|
+
binary = params.binary;
|
|
69
62
|
}
|
|
70
63
|
else {
|
|
71
|
-
const firmware = await (0,
|
|
64
|
+
const firmware = await (0, firmware_1.getBinary)({
|
|
72
65
|
features: device.features,
|
|
73
66
|
releases: (0, firmwareInfo_1.getReleases)(device.features.major_version),
|
|
74
67
|
version: params.version,
|
|
@@ -82,7 +75,9 @@ class FirmwareUpdate extends AbstractMethod_1.AbstractMethod {
|
|
|
82
75
|
catch (err) {
|
|
83
76
|
throw constants_1.ERRORS.TypedError('Method_FirmwareUpdate_DownloadFailed', 'Failed to download firmware binary');
|
|
84
77
|
}
|
|
85
|
-
|
|
78
|
+
const stripped = (0, firmware_1.stripFwHeaders)(binary);
|
|
79
|
+
await (0, firmware_1.uploadFirmware)(this.device.getCommands().typedCall.bind(this.device.getCommands()), this.postMessage, device, { payload: (0, firmware_1.shouldStripFwHeaders)(device.features) ? stripped : binary });
|
|
80
|
+
return (0, firmware_1.calculateFirmwareHash)(device.features.major_version, stripped, (0, randombytes_1.default)(32));
|
|
86
81
|
}
|
|
87
82
|
}
|
|
88
83
|
exports.default = FirmwareUpdate;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AbstractMethod } from '../core/AbstractMethod';
|
|
2
|
+
import { PROTO } from '../constants';
|
|
3
|
+
export default class GetFirmwareHash extends AbstractMethod<'getFirmwareHash', PROTO.GetFirmwareHash> {
|
|
4
|
+
init(): void;
|
|
5
|
+
run(): Promise<PROTO.FirmwareHash>;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=getFirmwareHash.d.ts.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const AbstractMethod_1 = require("../core/AbstractMethod");
|
|
4
|
+
const events_1 = require("../events");
|
|
5
|
+
const paramsValidator_1 = require("./common/paramsValidator");
|
|
6
|
+
class GetFirmwareHash extends AbstractMethod_1.AbstractMethod {
|
|
7
|
+
init() {
|
|
8
|
+
this.requiredPermissions = ['management'];
|
|
9
|
+
this.useEmptyPassphrase = true;
|
|
10
|
+
this.useDeviceState = false;
|
|
11
|
+
this.allowDeviceMode = [events_1.UI.INITIALIZE];
|
|
12
|
+
const { payload } = this;
|
|
13
|
+
(0, paramsValidator_1.validateParams)(payload, [{ name: 'challenge', type: 'string' }]);
|
|
14
|
+
this.firmwareRange = (0, paramsValidator_1.getFirmwareRange)(this.name, null, {
|
|
15
|
+
1: { min: '1.11.1', max: '0' },
|
|
16
|
+
2: { min: '2.5.1', max: '0' },
|
|
17
|
+
});
|
|
18
|
+
this.params = {
|
|
19
|
+
challenge: payload.challenge,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
async run() {
|
|
23
|
+
const cmd = this.device.getCommands();
|
|
24
|
+
const response = await cmd.typedCall('GetFirmwareHash', 'FirmwareHash', this.params);
|
|
25
|
+
return response.message;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.default = GetFirmwareHash;
|
|
29
|
+
//# sourceMappingURL=getFirmwareHash.js.map
|
package/lib/api/index.d.ts
CHANGED
|
@@ -38,6 +38,7 @@ export { default as getAddress } from './getAddress';
|
|
|
38
38
|
export { default as getCoinInfo } from './getCoinInfo';
|
|
39
39
|
export { default as getDeviceState } from './getDeviceState';
|
|
40
40
|
export { default as getFeatures } from './getFeatures';
|
|
41
|
+
export { default as getFirmwareHash } from './getFirmwareHash';
|
|
41
42
|
export { default as getOwnershipId } from './getOwnershipId';
|
|
42
43
|
export { default as getOwnershipProof } from './getOwnershipProof';
|
|
43
44
|
export { default as getPublicKey } from './getPublicKey';
|
package/lib/api/index.js
CHANGED
|
@@ -3,8 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
7
|
-
exports.wipeDevice = exports.verifyMessage = exports.tezosSignTransaction = exports.tezosGetPublicKey = exports.tezosGetAddress = exports.stellarSignTransaction = exports.stellarGetAddress = exports.signTransaction = exports.signMessage = exports.setProxy = exports.rippleSignTransaction = exports.rippleGetAddress = exports.resetDevice = void 0;
|
|
6
|
+
exports.recoveryDevice = exports.rebootToBootloader = exports.pushTransaction = exports.nemSignTransaction = exports.nemGetAddress = exports.getSettings = exports.getPublicKey = exports.getOwnershipProof = exports.getOwnershipId = exports.getFirmwareHash = exports.getFeatures = exports.getDeviceState = exports.getCoinInfo = exports.getAddress = exports.getAccountInfo = exports.firmwareUpdate = exports.ethereumVerifyMessage = exports.ethereumSignTypedData = exports.ethereumSignTransaction = exports.ethereumSignMessage = exports.ethereumGetPublicKey = exports.ethereumGetAddress = exports.eosSignTransaction = exports.eosGetPublicKey = exports.customMessage = exports.composeTransaction = exports.cipherKeyValue = exports.changePin = exports.cardanoSignTransaction = exports.cardanoGetPublicKey = exports.cardanoGetNativeScriptHash = exports.cardanoGetAddress = exports.blockchainUnsubscribeFiatRates = exports.blockchainUnsubscribe = exports.blockchainSubscribeFiatRates = exports.blockchainSubscribe = exports.blockchainSetCustomBackend = exports.blockchainGetTransactions = exports.blockchainGetFiatRatesForTimestamps = exports.blockchainGetCurrentFiatRates = exports.blockchainGetAccountBalanceHistory = exports.blockchainEstimateFee = exports.blockchainDisconnect = exports.binanceSignTransaction = exports.binanceGetPublicKey = exports.binanceGetAddress = exports.backupDevice = exports.authorizeCoinJoin = exports.applySettings = exports.applyFlags = void 0;
|
|
7
|
+
exports.wipeDevice = exports.verifyMessage = exports.tezosSignTransaction = exports.tezosGetPublicKey = exports.tezosGetAddress = exports.stellarSignTransaction = exports.stellarGetAddress = exports.signTransaction = exports.signMessage = exports.setProxy = exports.rippleSignTransaction = exports.rippleGetAddress = exports.resetDevice = exports.requestLogin = void 0;
|
|
8
8
|
var applyFlags_1 = require("./applyFlags");
|
|
9
9
|
Object.defineProperty(exports, "applyFlags", { enumerable: true, get: function () { return __importDefault(applyFlags_1).default; } });
|
|
10
10
|
var applySettings_1 = require("./applySettings");
|
|
@@ -85,6 +85,8 @@ var getDeviceState_1 = require("./getDeviceState");
|
|
|
85
85
|
Object.defineProperty(exports, "getDeviceState", { enumerable: true, get: function () { return __importDefault(getDeviceState_1).default; } });
|
|
86
86
|
var getFeatures_1 = require("./getFeatures");
|
|
87
87
|
Object.defineProperty(exports, "getFeatures", { enumerable: true, get: function () { return __importDefault(getFeatures_1).default; } });
|
|
88
|
+
var getFirmwareHash_1 = require("./getFirmwareHash");
|
|
89
|
+
Object.defineProperty(exports, "getFirmwareHash", { enumerable: true, get: function () { return __importDefault(getFirmwareHash_1).default; } });
|
|
88
90
|
var getOwnershipId_1 = require("./getOwnershipId");
|
|
89
91
|
Object.defineProperty(exports, "getOwnershipId", { enumerable: true, get: function () { return __importDefault(getOwnershipId_1).default; } });
|
|
90
92
|
var getOwnershipProof_1 = require("./getOwnershipProof");
|
package/lib/constants/errors.js
CHANGED
|
@@ -6,7 +6,7 @@ exports.ERROR_CODES = {
|
|
|
6
6
|
Init_AlreadyInitialized: 'TrezorConnect has been already initialized',
|
|
7
7
|
Init_IframeBlocked: 'Iframe blocked',
|
|
8
8
|
Init_IframeTimeout: 'Iframe timeout',
|
|
9
|
-
Init_ManifestMissing: 'Manifest not set. Read more at https://github.com/trezor/
|
|
9
|
+
Init_ManifestMissing: 'Manifest not set. Read more at https://github.com/trezor/trezor-suite/blob/develop/docs/packages/connect/index.md',
|
|
10
10
|
Popup_ConnectionMissing: 'Unable to establish connection with iframe',
|
|
11
11
|
Transport_Missing: 'Transport is missing',
|
|
12
12
|
Transport_InvalidProtobuf: '',
|
package/lib/core/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export declare const onCall: (message: CoreMessage) => Promise<void>;
|
|
|
7
7
|
export declare class Core extends EventEmitter {
|
|
8
8
|
handleMessage(message: any, isTrustedOrigin: boolean): void;
|
|
9
9
|
dispose(): void;
|
|
10
|
-
getCurrentMethod(): (import("../api").applyFlags | import("../api").applySettings | import("../api").authorizeCoinJoin | import("../api").backupDevice | import("../api").binanceGetAddress | import("../api").binanceGetPublicKey | import("../api").binanceSignTransaction | import("../api").blockchainDisconnect | import("../api").blockchainEstimateFee | import("../api").blockchainGetAccountBalanceHistory | import("../api").blockchainGetCurrentFiatRates | import("../api").blockchainGetFiatRatesForTimestamps | import("../api").blockchainGetTransactions | import("../api").blockchainSetCustomBackend | import("../api").blockchainSubscribe | import("../api").blockchainSubscribeFiatRates | import("../api").blockchainUnsubscribe | import("../api").blockchainUnsubscribeFiatRates | import("../api").cardanoGetAddress | import("../api").cardanoGetNativeScriptHash | import("../api").cardanoGetPublicKey | import("../api").cardanoSignTransaction | import("../api").changePin | import("../api").cipherKeyValue | import("../api").composeTransaction | import("../api").customMessage | import("../api").eosGetPublicKey | import("../api").eosSignTransaction | import("../api").ethereumGetAddress | import("../api").ethereumGetPublicKey | import("../api").ethereumSignMessage | import("../api").ethereumSignTransaction | import("../api").ethereumSignTypedData | import("../api").ethereumVerifyMessage | import("../api").firmwareUpdate | import("../api").getAccountInfo | import("../api").getAddress | import("../api").getCoinInfo | import("../api").getDeviceState | import("../api").getFeatures | import("../api").getOwnershipId | import("../api").getOwnershipProof | import("../api").getPublicKey | import("../api").getSettings | import("../api").nemGetAddress | import("../api").nemSignTransaction | import("../api").pushTransaction | import("../api").rebootToBootloader | import("../api").recoveryDevice | import("../api").requestLogin | import("../api").resetDevice | import("../api").rippleGetAddress | import("../api").rippleSignTransaction | import("../api").setProxy | import("../api").signMessage | import("../api").signTransaction | import("../api").stellarGetAddress | import("../api").stellarSignTransaction | import("../api").tezosGetAddress | import("../api").tezosGetPublicKey | import("../api").tezosSignTransaction | import("../api").verifyMessage | import("../api").wipeDevice)[];
|
|
10
|
+
getCurrentMethod(): (import("../api").applyFlags | import("../api").applySettings | import("../api").authorizeCoinJoin | import("../api").backupDevice | import("../api").binanceGetAddress | import("../api").binanceGetPublicKey | import("../api").binanceSignTransaction | import("../api").blockchainDisconnect | import("../api").blockchainEstimateFee | import("../api").blockchainGetAccountBalanceHistory | import("../api").blockchainGetCurrentFiatRates | import("../api").blockchainGetFiatRatesForTimestamps | import("../api").blockchainGetTransactions | import("../api").blockchainSetCustomBackend | import("../api").blockchainSubscribe | import("../api").blockchainSubscribeFiatRates | import("../api").blockchainUnsubscribe | import("../api").blockchainUnsubscribeFiatRates | import("../api").cardanoGetAddress | import("../api").cardanoGetNativeScriptHash | import("../api").cardanoGetPublicKey | import("../api").cardanoSignTransaction | import("../api").changePin | import("../api").cipherKeyValue | import("../api").composeTransaction | import("../api").customMessage | import("../api").eosGetPublicKey | import("../api").eosSignTransaction | import("../api").ethereumGetAddress | import("../api").ethereumGetPublicKey | import("../api").ethereumSignMessage | import("../api").ethereumSignTransaction | import("../api").ethereumSignTypedData | import("../api").ethereumVerifyMessage | import("../api").firmwareUpdate | import("../api").getAccountInfo | import("../api").getAddress | import("../api").getCoinInfo | import("../api").getDeviceState | import("../api").getFeatures | import("../api").getFirmwareHash | import("../api").getOwnershipId | import("../api").getOwnershipProof | import("../api").getPublicKey | import("../api").getSettings | import("../api").nemGetAddress | import("../api").nemSignTransaction | import("../api").pushTransaction | import("../api").rebootToBootloader | import("../api").recoveryDevice | import("../api").requestLogin | import("../api").resetDevice | import("../api").rippleGetAddress | import("../api").rippleSignTransaction | import("../api").setProxy | import("../api").signMessage | import("../api").signTransaction | import("../api").stellarGetAddress | import("../api").stellarSignTransaction | import("../api").tezosGetAddress | import("../api").tezosGetPublicKey | import("../api").tezosSignTransaction | import("../api").verifyMessage | import("../api").wipeDevice)[];
|
|
11
11
|
getTransportInfo(): TransportInfo;
|
|
12
12
|
}
|
|
13
13
|
export declare const initCore: () => Core;
|
package/lib/core/method.d.ts
CHANGED
|
@@ -2,5 +2,5 @@ import * as Methods from '../api';
|
|
|
2
2
|
import type { IFrameCallMessage } from '../events';
|
|
3
3
|
export declare const getMethod: (message: IFrameCallMessage & {
|
|
4
4
|
id?: number;
|
|
5
|
-
}) => Methods.applyFlags | Methods.applySettings | Methods.authorizeCoinJoin | Methods.backupDevice | Methods.binanceGetAddress | Methods.binanceGetPublicKey | Methods.binanceSignTransaction | Methods.blockchainDisconnect | Methods.blockchainEstimateFee | Methods.blockchainGetAccountBalanceHistory | Methods.blockchainGetCurrentFiatRates | Methods.blockchainGetFiatRatesForTimestamps | Methods.blockchainGetTransactions | Methods.blockchainSetCustomBackend | Methods.blockchainSubscribe | Methods.blockchainSubscribeFiatRates | Methods.blockchainUnsubscribe | Methods.blockchainUnsubscribeFiatRates | Methods.cardanoGetAddress | Methods.cardanoGetNativeScriptHash | Methods.cardanoGetPublicKey | Methods.cardanoSignTransaction | Methods.changePin | Methods.cipherKeyValue | Methods.composeTransaction | Methods.customMessage | Methods.eosGetPublicKey | Methods.eosSignTransaction | Methods.ethereumGetAddress | Methods.ethereumGetPublicKey | Methods.ethereumSignMessage | Methods.ethereumSignTransaction | Methods.ethereumSignTypedData | Methods.ethereumVerifyMessage | Methods.firmwareUpdate | Methods.getAccountInfo | Methods.getAddress | Methods.getCoinInfo | Methods.getDeviceState | Methods.getFeatures | Methods.getOwnershipId | Methods.getOwnershipProof | Methods.getPublicKey | Methods.getSettings | Methods.nemGetAddress | Methods.nemSignTransaction | Methods.pushTransaction | Methods.rebootToBootloader | Methods.recoveryDevice | Methods.requestLogin | Methods.resetDevice | Methods.rippleGetAddress | Methods.rippleSignTransaction | Methods.setProxy | Methods.signMessage | Methods.signTransaction | Methods.stellarGetAddress | Methods.stellarSignTransaction | Methods.tezosGetAddress | Methods.tezosGetPublicKey | Methods.tezosSignTransaction | Methods.verifyMessage | Methods.wipeDevice;
|
|
5
|
+
}) => Methods.applyFlags | Methods.applySettings | Methods.authorizeCoinJoin | Methods.backupDevice | Methods.binanceGetAddress | Methods.binanceGetPublicKey | Methods.binanceSignTransaction | Methods.blockchainDisconnect | Methods.blockchainEstimateFee | Methods.blockchainGetAccountBalanceHistory | Methods.blockchainGetCurrentFiatRates | Methods.blockchainGetFiatRatesForTimestamps | Methods.blockchainGetTransactions | Methods.blockchainSetCustomBackend | Methods.blockchainSubscribe | Methods.blockchainSubscribeFiatRates | Methods.blockchainUnsubscribe | Methods.blockchainUnsubscribeFiatRates | Methods.cardanoGetAddress | Methods.cardanoGetNativeScriptHash | Methods.cardanoGetPublicKey | Methods.cardanoSignTransaction | Methods.changePin | Methods.cipherKeyValue | Methods.composeTransaction | Methods.customMessage | Methods.eosGetPublicKey | Methods.eosSignTransaction | Methods.ethereumGetAddress | Methods.ethereumGetPublicKey | Methods.ethereumSignMessage | Methods.ethereumSignTransaction | Methods.ethereumSignTypedData | Methods.ethereumVerifyMessage | Methods.firmwareUpdate | Methods.getAccountInfo | Methods.getAddress | Methods.getCoinInfo | Methods.getDeviceState | Methods.getFeatures | Methods.getFirmwareHash | Methods.getOwnershipId | Methods.getOwnershipProof | Methods.getPublicKey | Methods.getSettings | Methods.nemGetAddress | Methods.nemSignTransaction | Methods.pushTransaction | Methods.rebootToBootloader | Methods.recoveryDevice | Methods.requestLogin | Methods.resetDevice | Methods.rippleGetAddress | Methods.rippleSignTransaction | Methods.setProxy | Methods.signMessage | Methods.signTransaction | Methods.stellarGetAddress | Methods.stellarSignTransaction | Methods.tezosGetAddress | Methods.tezosGetPublicKey | Methods.tezosSignTransaction | Methods.verifyMessage | Methods.wipeDevice;
|
|
6
6
|
//# sourceMappingURL=method.d.ts.map
|
package/lib/data/firmwareInfo.js
CHANGED
|
@@ -6,20 +6,11 @@ const firmwareUtils_1 = require("../utils/firmwareUtils");
|
|
|
6
6
|
const releases = {};
|
|
7
7
|
releases[1] = [];
|
|
8
8
|
releases[2] = [];
|
|
9
|
-
const cleanUrl = (url) => {
|
|
10
|
-
if (typeof url !== 'string')
|
|
11
|
-
return;
|
|
12
|
-
if (url.indexOf('data/') === 0)
|
|
13
|
-
return url.substring(5);
|
|
14
|
-
return url;
|
|
15
|
-
};
|
|
16
9
|
const parseFirmware = (json, model) => {
|
|
17
10
|
Object.keys(json).forEach(key => {
|
|
18
11
|
const release = json[key];
|
|
19
12
|
releases[model].push({
|
|
20
13
|
...release,
|
|
21
|
-
url: cleanUrl(release.url),
|
|
22
|
-
url_bitcoinonly: cleanUrl(release.url_bitcoinonly),
|
|
23
14
|
});
|
|
24
15
|
});
|
|
25
16
|
};
|
package/lib/data/version.d.ts
CHANGED
package/lib/data/version.js
CHANGED
|
@@ -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.0-beta.
|
|
4
|
+
exports.VERSION = '9.0.0-beta.5';
|
|
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
|
package/lib/factory.js
CHANGED
|
@@ -63,6 +63,7 @@ const factory = ({ eventEmitter, manifest, init, call, customMessage, requestLog
|
|
|
63
63
|
}),
|
|
64
64
|
getDeviceState: params => call({ ...params, method: 'getDeviceState' }),
|
|
65
65
|
getFeatures: params => call({ ...params, method: 'getFeatures' }),
|
|
66
|
+
getFirmwareHash: params => call({ ...params, method: 'getFirmwareHash' }),
|
|
66
67
|
getOwnershipId: params => call({ ...params, method: 'getOwnershipId' }),
|
|
67
68
|
getOwnershipProof: params => call({ ...params, method: 'getOwnershipProof' }),
|
|
68
69
|
getPublicKey: params => call({ ...params, method: 'getPublicKey' }),
|
|
@@ -15,16 +15,17 @@ export interface CardanoAssetGroup {
|
|
|
15
15
|
policyId: string;
|
|
16
16
|
tokenAmounts: CardanoToken[];
|
|
17
17
|
}
|
|
18
|
-
export declare type CardanoOutput = {
|
|
18
|
+
export declare type CardanoOutput = ({
|
|
19
19
|
addressParameters: CardanoAddressParameters;
|
|
20
|
-
amount: string;
|
|
21
|
-
tokenBundle?: CardanoAssetGroup[];
|
|
22
|
-
datumHash?: string;
|
|
23
20
|
} | {
|
|
24
21
|
address: string;
|
|
22
|
+
}) & {
|
|
25
23
|
amount: string;
|
|
26
24
|
tokenBundle?: CardanoAssetGroup[];
|
|
27
25
|
datumHash?: string;
|
|
26
|
+
format?: PROTO.CardanoTxOutputSerializationFormat;
|
|
27
|
+
inlineDatum?: string;
|
|
28
|
+
referenceScript?: string;
|
|
28
29
|
};
|
|
29
30
|
export interface CardanoPoolOwner {
|
|
30
31
|
stakingKeyPath?: string | number[];
|
|
@@ -80,6 +81,10 @@ export interface CardanoRequiredSigner {
|
|
|
80
81
|
keyPath?: string | number[];
|
|
81
82
|
keyHash?: string;
|
|
82
83
|
}
|
|
84
|
+
export interface CardanoReferenceInput {
|
|
85
|
+
prev_hash: string;
|
|
86
|
+
prev_index: number;
|
|
87
|
+
}
|
|
83
88
|
export interface CardanoCatalystRegistrationParameters {
|
|
84
89
|
votingPublicKey: string;
|
|
85
90
|
stakingPath: string | number[];
|
|
@@ -103,6 +108,9 @@ export interface CardanoSignTransaction {
|
|
|
103
108
|
scriptDataHash?: string;
|
|
104
109
|
collateralInputs?: CardanoCollateralInput[];
|
|
105
110
|
requiredSigners?: CardanoRequiredSigner[];
|
|
111
|
+
collateralReturn?: CardanoOutput;
|
|
112
|
+
totalCollateral?: string;
|
|
113
|
+
referenceInputs?: CardanoReferenceInput[];
|
|
106
114
|
additionalWitnessRequests?: (string | number[])[];
|
|
107
115
|
protocolMagic: number;
|
|
108
116
|
networkId: number;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { PROTO } from '../../constants';
|
|
2
1
|
import type { Params, Response } from '../params';
|
|
3
2
|
export interface FirmwareUpdateBinary {
|
|
4
3
|
binary: ArrayBuffer;
|
|
@@ -9,6 +8,10 @@ export interface FirmwareUpdate {
|
|
|
9
8
|
baseUrl?: string;
|
|
10
9
|
intermediary?: boolean;
|
|
11
10
|
}
|
|
12
|
-
export
|
|
13
|
-
|
|
11
|
+
export interface FirmwareUpdateResponse {
|
|
12
|
+
hash: string;
|
|
13
|
+
challenge: string;
|
|
14
|
+
}
|
|
15
|
+
export declare function firmwareUpdate(params: Params<FirmwareUpdate>): Response<FirmwareUpdateResponse>;
|
|
16
|
+
export declare function firmwareUpdate(params: Params<FirmwareUpdateBinary>): Response<FirmwareUpdateResponse>;
|
|
14
17
|
//# sourceMappingURL=firmwareUpdate.d.ts.map
|
package/lib/types/api/index.d.ts
CHANGED
|
@@ -41,6 +41,7 @@ import { getAddress } from './getAddress';
|
|
|
41
41
|
import { getCoinInfo } from './getCoinInfo';
|
|
42
42
|
import { getDeviceState } from './getDeviceState';
|
|
43
43
|
import { getFeatures } from './getFeatures';
|
|
44
|
+
import { getFirmwareHash } from './getFirmwareHash';
|
|
44
45
|
import { getOwnershipId } from './getOwnershipId';
|
|
45
46
|
import { getOwnershipProof } from './getOwnershipProof';
|
|
46
47
|
import { getPublicKey } from './getPublicKey';
|
|
@@ -115,6 +116,7 @@ export interface TrezorConnect {
|
|
|
115
116
|
getCoinInfo: typeof getCoinInfo;
|
|
116
117
|
getDeviceState: typeof getDeviceState;
|
|
117
118
|
getFeatures: typeof getFeatures;
|
|
119
|
+
getFirmwareHash: typeof getFirmwareHash;
|
|
118
120
|
getOwnershipId: typeof getOwnershipId;
|
|
119
121
|
getOwnershipProof: typeof getOwnershipProof;
|
|
120
122
|
getPublicKey: typeof getPublicKey;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAssetByUrl = void 0;
|
|
4
|
+
const getAssetByUrl = (url) => {
|
|
5
|
+
const fileUrl = url.split('?')[0];
|
|
6
|
+
switch (fileUrl) {
|
|
7
|
+
case './data/coins.json':
|
|
8
|
+
return require('@trezor/connect-common/files/coins.json');
|
|
9
|
+
case './data/bridge/releases.json':
|
|
10
|
+
return require('@trezor/connect-common/files/bridge/releases.json');
|
|
11
|
+
case './data/firmware/1/releases.json':
|
|
12
|
+
return require('@trezor/connect-common/files/firmware/1/releases.json');
|
|
13
|
+
case './data/firmware/2/releases.json':
|
|
14
|
+
return require('@trezor/connect-common/files/firmware/2/releases.json');
|
|
15
|
+
case './data/messages/messages.json':
|
|
16
|
+
return require('@trezor/transport/messages.json');
|
|
17
|
+
default:
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
exports.getAssetByUrl = getAssetByUrl;
|
|
22
|
+
//# sourceMappingURL=assetUtils.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.httpRequest = void 0;
|
|
4
|
+
const assetUtils_1 = require("./assetUtils");
|
|
5
|
+
const httpRequest = (url, _type) => (0, assetUtils_1.getAssetByUrl)(url);
|
|
6
|
+
exports.httpRequest = httpRequest;
|
|
7
|
+
//# sourceMappingURL=assets-native.js.map
|
package/lib/utils/assets.js
CHANGED
|
@@ -5,24 +5,16 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const cross_fetch_1 = (0, tslib_1.__importDefault)(require("cross-fetch"));
|
|
6
6
|
const fs_1 = require("fs");
|
|
7
7
|
const assets_browser_1 = require("./assets-browser");
|
|
8
|
+
const assetUtils_1 = require("./assetUtils");
|
|
8
9
|
if (global && typeof global.fetch !== 'function') {
|
|
9
10
|
global.fetch = cross_fetch_1.default;
|
|
10
11
|
}
|
|
11
12
|
const httpRequest = (url, _type) => {
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return require('@trezor/connect-common/files/coins.json');
|
|
16
|
-
case './data/bridge/releases.json':
|
|
17
|
-
return require('@trezor/connect-common/files/bridge/releases.json');
|
|
18
|
-
case './data/firmware/1/releases.json':
|
|
19
|
-
return require('@trezor/connect-common/files/firmware/1/releases.json');
|
|
20
|
-
case './data/firmware/2/releases.json':
|
|
21
|
-
return require('@trezor/connect-common/files/firmware/2/releases.json');
|
|
22
|
-
case './data/messages/messages.json':
|
|
23
|
-
return require('@trezor/transport/messages.json');
|
|
13
|
+
const asset = (0, assetUtils_1.getAssetByUrl)(url);
|
|
14
|
+
if (!asset) {
|
|
15
|
+
return /^https?/.test(url) ? (0, assets_browser_1.httpRequest)(url) : fs_1.promises.readFile(url);
|
|
24
16
|
}
|
|
25
|
-
return
|
|
17
|
+
return asset;
|
|
26
18
|
};
|
|
27
19
|
exports.httpRequest = httpRequest;
|
|
28
20
|
//# sourceMappingURL=assets.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trezor/connect",
|
|
3
|
-
"version": "9.0.0-beta.
|
|
3
|
+
"version": "9.0.0-beta.5",
|
|
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.",
|
|
@@ -25,7 +25,9 @@
|
|
|
25
25
|
"./lib/utils/assets": "./lib/utils/assets-browser"
|
|
26
26
|
},
|
|
27
27
|
"react-native": {
|
|
28
|
-
"./lib/
|
|
28
|
+
"./lib/index": "./lib/index",
|
|
29
|
+
"./lib/workers/workers": "./lib/workers/workers-react-native",
|
|
30
|
+
"./lib/utils/assets": "./lib/utils/assets-native"
|
|
29
31
|
},
|
|
30
32
|
"files": [
|
|
31
33
|
"lib/",
|
|
@@ -36,17 +38,19 @@
|
|
|
36
38
|
"test:unit": "jest",
|
|
37
39
|
"type-check": "tsc --build",
|
|
38
40
|
"build:lib": "rimraf ./lib && tsc --build tsconfig.lib.json",
|
|
39
|
-
"version:beta": "
|
|
40
|
-
"version:patch": "
|
|
41
|
-
"version:minor": "
|
|
42
|
-
"version:major": "
|
|
41
|
+
"version:beta": "node scripts/bump-version.js prerelease",
|
|
42
|
+
"version:patch": "node scripts/bump-version.js patch",
|
|
43
|
+
"version:minor": "node scripts/bump-version.js minor",
|
|
44
|
+
"version:major": "node scripts/bump-version.js major"
|
|
43
45
|
},
|
|
44
46
|
"dependencies": {
|
|
45
47
|
"@trezor/blockchain-link": "^2.1.3",
|
|
46
|
-
"@trezor/
|
|
48
|
+
"@trezor/connect-common": "0.0.8",
|
|
49
|
+
"@trezor/transport": "^1.1.4",
|
|
47
50
|
"@trezor/utils": "^9.0.2",
|
|
48
51
|
"@trezor/utxo-lib": "^1.0.0",
|
|
49
52
|
"bignumber.js": "^9.0.2",
|
|
53
|
+
"blakejs": "^1.2.1",
|
|
50
54
|
"bowser": "^2.11.0",
|
|
51
55
|
"cross-fetch": "^3.1.5",
|
|
52
56
|
"events": "^3.3.0",
|
package/CHANGELOG.md
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
# 9.0.0
|
|
2
|
-
|
|
3
|
-
## Breaking changes:
|
|
4
|
-
|
|
5
|
-
- Changed codebase to typescript.
|
|
6
|
-
- Removed `Lisk` methods from api.
|
|
7
|
-
- Exported constants:
|
|
8
|
-
- `CARDANO.ADDRESS_TYPE` => `PROTO.CardanoAddressType`
|
|
9
|
-
- `CARDANO.CERTIFICATE_TYPE` => `PROTO.CardanoCertificateType`
|
|
10
|
-
- `CARDANO.POOL_RELAY_TYPE` => `PROTO.CardanoPoolRelayType`
|
|
11
|
-
- `CardanoCertificateType`
|
|
12
|
-
- `CardanoNativeScriptType` => `PROTO.CardanoNativeScriptType`
|
|
13
|
-
- `CardanoNativeScriptHashDisplayFormat` => `PROTO.CardanoNativeScriptHashDisplayFormat`
|
|
14
|
-
- `CardanoPoolRelayType` => `PROTO.CardanoPoolRelayType`
|
|
15
|
-
- `CardanoTxSigningMode` => `PROTO.CardanoTxSigningMode`
|
|
16
|
-
- `CardanoTxWitnessType` => `PROTO.CardanoTxWitnessType`
|
|
17
|
-
- removed unused `DEVICE.WAIT_FOR_SELECTION`
|
|
18
|
-
- removed unused `UI.CHANGE_ACCOUNT`
|
|
19
|
-
- Minimum firmware requirements bumped:
|
|
20
|
-
- 2.4.2 CardanoSignTransaction
|
|
21
|
-
|
|
22
|
-
## Added:
|
|
23
|
-
|
|
24
|
-
- `getOwnershipId` method
|
|
25
|
-
- `getOwnershipProof` method
|
|
26
|
-
- `authorizeCoinJoin` method
|