@trezor/connect 9.6.4 → 9.6.5-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -9
- package/README.md +1 -1
- package/lib/api/authenticateDevice.d.ts +5 -1
- package/lib/api/authenticateDevice.js +31 -12
- package/lib/api/firmware/getBinary.d.ts +3 -3
- package/lib/api/firmware/getBinary.js +2 -2
- package/lib/api/firmware/uploadFirmware.js +5 -0
- package/lib/api/monero/api/index.d.ts +5 -0
- package/lib/api/monero/api/index.js +13 -0
- package/lib/api/monero/api/moneroGetAddress.d.ts +27 -0
- package/lib/api/monero/api/moneroGetAddress.js +96 -0
- package/lib/api/monero/api/moneroGetWatchKey.d.ts +13 -0
- package/lib/api/monero/api/moneroGetWatchKey.js +43 -0
- package/lib/api/monero/api/moneroKeyImageSync.d.ts +16 -0
- package/lib/api/monero/api/moneroKeyImageSync.js +127 -0
- package/lib/api/monero/api/moneroSignTransaction.d.ts +16 -0
- package/lib/api/monero/api/moneroSignTransaction.js +197 -0
- package/lib/constants/errors.d.ts +1 -0
- package/lib/constants/errors.js +1 -0
- package/lib/constants/network.d.ts +1 -1
- package/lib/constants/network.js +1 -0
- package/lib/core/method.native.js +1 -0
- package/lib/core/onCallFirmwareUpdate.d.ts +1 -0
- package/lib/core/onCallFirmwareUpdate.js +12 -10
- package/lib/data/config.js +23 -0
- package/lib/data/connectSettings.js +1 -1
- package/lib/data/version.d.ts +1 -1
- package/lib/data/version.js +1 -1
- package/lib/device/Device.js +8 -1
- package/lib/device/DeviceCurrentSession.d.ts +78 -0
- package/lib/device/thp/pairing.js +1 -1
- package/lib/device/workflow/checkFirmwareHash.js +1 -1
- package/lib/events/transport.d.ts +0 -2
- package/lib/events/transport.js +0 -2
- package/lib/events/ui-request.d.ts +2 -2
- package/lib/factory.js +17 -0
- package/lib/impl/core-in-module.js +8 -2
- package/lib/tsconfig.lib.tsbuildinfo +1 -1
- package/lib/types/api/authenticateDevice.d.ts +19 -19
- package/lib/types/api/authenticateDevice.js +3 -4
- package/lib/types/api/discoverAccounts.d.ts +8 -0
- package/lib/types/api/discoverAccounts.js +2 -0
- package/lib/types/api/index.d.ts +8 -0
- package/lib/types/api/monero/index.d.ts +275 -0
- package/lib/types/api/monero/index.js +170 -0
- package/lib/types/api/moneroGetAddress.d.ts +5 -0
- package/lib/types/api/moneroGetAddress.js +3 -0
- package/lib/types/api/moneroGetWatchKey.d.ts +4 -0
- package/lib/types/api/moneroGetWatchKey.js +3 -0
- package/lib/types/api/moneroKeyImageSync.d.ts +4 -0
- package/lib/types/api/moneroKeyImageSync.js +3 -0
- package/lib/types/api/moneroSignTransaction.d.ts +4 -0
- package/lib/types/api/moneroSignTransaction.js +3 -0
- package/lib/types/firmware.d.ts +1 -1
- package/lib/types/index.d.ts +1 -0
- package/lib/types/index.js +1 -0
- package/lib/types/settings.d.ts +2 -2
- package/lib/utils/uiPromiseManager.js +5 -0
- package/package.json +14 -13
- package/lib/api/firmware/verifyAuthenticityProof.d.ts +0 -15
- package/lib/api/firmware/verifyAuthenticityProof.js +0 -133
- package/lib/api/firmware/x509certificate.d.ts +0 -88
- package/lib/api/firmware/x509certificate.js +0 -302
- package/lib/data/deviceAuthenticityBlacklist.d.ts +0 -3
- package/lib/data/deviceAuthenticityBlacklist.js +0 -11
- package/lib/data/deviceAuthenticityBlacklistConfig.d.ts +0 -11
- package/lib/data/deviceAuthenticityBlacklistConfig.js +0 -15
- package/lib/data/deviceAuthenticityConfig.d.ts +0 -3
- package/lib/data/deviceAuthenticityConfig.js +0 -47
- package/lib/data/deviceAuthenticityConfigTypes.d.ts +0 -39
- package/lib/data/deviceAuthenticityConfigTypes.js +0 -26
- package/lib/data/transportInfo.d.ts +0 -13
- package/lib/data/transportInfo.js +0 -54
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MoneroSignedTransaction = exports.MoneroRingCtSig = exports.MoneroSignTransaction = exports.MoneroTransactionData = exports.MoneroTransactionRsigData = exports.MoneroTransactionDestinationEntry = exports.MoneroAccountPublicAddress = exports.MoneroTransactionSourceEntry = exports.MoneroMultisigKLRki = exports.MoneroOutputEntry = exports.MoneroKeyImageSyncResult = exports.MoneroExportedKeyImage = exports.MoneroKeyImageSync = exports.MoneroSubAddressIndicesList = exports.MoneroTransferDetails = exports.MoneroWatchKey = exports.MoneroGetWatchKey = exports.MoneroGetAddress = void 0;
|
|
4
|
+
const schema_utils_1 = require("@trezor/schema-utils");
|
|
5
|
+
const constants_1 = require("../../../constants");
|
|
6
|
+
const params_1 = require("../../params");
|
|
7
|
+
exports.MoneroGetAddress = schema_utils_1.Type.Object({
|
|
8
|
+
path: params_1.DerivationPath,
|
|
9
|
+
address: schema_utils_1.Type.Optional(schema_utils_1.Type.String()),
|
|
10
|
+
showOnTrezor: schema_utils_1.Type.Optional(schema_utils_1.Type.Boolean()),
|
|
11
|
+
networkType: schema_utils_1.Type.Optional(constants_1.PROTO.EnumMoneroNetworkType),
|
|
12
|
+
account: schema_utils_1.Type.Optional(schema_utils_1.Type.Number()),
|
|
13
|
+
minor: schema_utils_1.Type.Optional(schema_utils_1.Type.Number()),
|
|
14
|
+
paymentId: schema_utils_1.Type.Optional(schema_utils_1.Type.String()),
|
|
15
|
+
chunkify: schema_utils_1.Type.Optional(schema_utils_1.Type.Boolean()),
|
|
16
|
+
}, {
|
|
17
|
+
$id: 'MoneroGetAddress',
|
|
18
|
+
});
|
|
19
|
+
exports.MoneroGetWatchKey = schema_utils_1.Type.Object({
|
|
20
|
+
path: params_1.DerivationPath,
|
|
21
|
+
networkType: schema_utils_1.Type.Optional(constants_1.PROTO.EnumMoneroNetworkType),
|
|
22
|
+
}, {
|
|
23
|
+
$id: 'MoneroGetWatchKey',
|
|
24
|
+
});
|
|
25
|
+
exports.MoneroWatchKey = schema_utils_1.Type.Object({
|
|
26
|
+
watch_key: schema_utils_1.Type.String(),
|
|
27
|
+
address: schema_utils_1.Type.String(),
|
|
28
|
+
}, {
|
|
29
|
+
$id: 'MoneroWatchKey',
|
|
30
|
+
});
|
|
31
|
+
exports.MoneroTransferDetails = schema_utils_1.Type.Object({
|
|
32
|
+
out_key: schema_utils_1.Type.String(),
|
|
33
|
+
tx_pub_key: schema_utils_1.Type.String(),
|
|
34
|
+
additional_tx_pub_keys: schema_utils_1.Type.Optional(schema_utils_1.Type.Union([schema_utils_1.Type.Array(schema_utils_1.Type.String()), schema_utils_1.Type.String()])),
|
|
35
|
+
internal_output_index: schema_utils_1.Type.Number(),
|
|
36
|
+
sub_addr_major: schema_utils_1.Type.Optional(schema_utils_1.Type.Number()),
|
|
37
|
+
sub_addr_minor: schema_utils_1.Type.Optional(schema_utils_1.Type.Number()),
|
|
38
|
+
}, {
|
|
39
|
+
$id: 'MoneroTransferDetails',
|
|
40
|
+
});
|
|
41
|
+
exports.MoneroSubAddressIndicesList = schema_utils_1.Type.Object({
|
|
42
|
+
account: schema_utils_1.Type.Number(),
|
|
43
|
+
minor_indices: schema_utils_1.Type.Array(schema_utils_1.Type.Number()),
|
|
44
|
+
}, {
|
|
45
|
+
$id: 'MoneroSubAddressIndicesList',
|
|
46
|
+
});
|
|
47
|
+
exports.MoneroKeyImageSync = schema_utils_1.Type.Object({
|
|
48
|
+
path: params_1.DerivationPath,
|
|
49
|
+
networkType: schema_utils_1.Type.Optional(constants_1.PROTO.EnumMoneroNetworkType),
|
|
50
|
+
subs: schema_utils_1.Type.Optional(schema_utils_1.Type.Array(exports.MoneroSubAddressIndicesList)),
|
|
51
|
+
tdis: schema_utils_1.Type.Array(exports.MoneroTransferDetails),
|
|
52
|
+
}, {
|
|
53
|
+
$id: 'MoneroKeyImageSync',
|
|
54
|
+
});
|
|
55
|
+
exports.MoneroExportedKeyImage = schema_utils_1.Type.Object({
|
|
56
|
+
iv: schema_utils_1.Type.String(),
|
|
57
|
+
key_image: schema_utils_1.Type.String(),
|
|
58
|
+
}, {
|
|
59
|
+
$id: 'MoneroExportedKeyImage',
|
|
60
|
+
});
|
|
61
|
+
exports.MoneroKeyImageSyncResult = schema_utils_1.Type.Object({
|
|
62
|
+
key_images: schema_utils_1.Type.Array(exports.MoneroExportedKeyImage),
|
|
63
|
+
signature: schema_utils_1.Type.String(),
|
|
64
|
+
}, {
|
|
65
|
+
$id: 'MoneroKeyImageSyncResult',
|
|
66
|
+
});
|
|
67
|
+
exports.MoneroOutputEntry = schema_utils_1.Type.Object({
|
|
68
|
+
idx: schema_utils_1.Type.Number(),
|
|
69
|
+
key: schema_utils_1.Type.Object({
|
|
70
|
+
dest: schema_utils_1.Type.String(),
|
|
71
|
+
commitment: schema_utils_1.Type.String(),
|
|
72
|
+
}),
|
|
73
|
+
}, {
|
|
74
|
+
$id: 'MoneroOutputEntry',
|
|
75
|
+
});
|
|
76
|
+
exports.MoneroMultisigKLRki = schema_utils_1.Type.Object({
|
|
77
|
+
K: schema_utils_1.Type.Optional(schema_utils_1.Type.String()),
|
|
78
|
+
L: schema_utils_1.Type.Optional(schema_utils_1.Type.String()),
|
|
79
|
+
R: schema_utils_1.Type.Optional(schema_utils_1.Type.String()),
|
|
80
|
+
ki: schema_utils_1.Type.Optional(schema_utils_1.Type.String()),
|
|
81
|
+
}, {
|
|
82
|
+
$id: 'MoneroMultisigKLRki',
|
|
83
|
+
});
|
|
84
|
+
exports.MoneroTransactionSourceEntry = schema_utils_1.Type.Object({
|
|
85
|
+
outputs: schema_utils_1.Type.Array(exports.MoneroOutputEntry),
|
|
86
|
+
real_output: schema_utils_1.Type.Number(),
|
|
87
|
+
real_out_tx_key: schema_utils_1.Type.String(),
|
|
88
|
+
real_out_additional_tx_keys: schema_utils_1.Type.Array(schema_utils_1.Type.String()),
|
|
89
|
+
real_output_in_tx_index: schema_utils_1.Type.Number(),
|
|
90
|
+
amount: schema_utils_1.Type.Number(),
|
|
91
|
+
rct: schema_utils_1.Type.Boolean(),
|
|
92
|
+
mask: schema_utils_1.Type.String(),
|
|
93
|
+
subaddr_minor: schema_utils_1.Type.Number(),
|
|
94
|
+
multisig_kLRki: schema_utils_1.Type.Optional(exports.MoneroMultisigKLRki),
|
|
95
|
+
}, {
|
|
96
|
+
$id: 'MoneroTransactionSourceEntry',
|
|
97
|
+
});
|
|
98
|
+
exports.MoneroAccountPublicAddress = schema_utils_1.Type.Object({
|
|
99
|
+
spend_public_key: schema_utils_1.Type.String(),
|
|
100
|
+
view_public_key: schema_utils_1.Type.String(),
|
|
101
|
+
});
|
|
102
|
+
exports.MoneroTransactionDestinationEntry = schema_utils_1.Type.Object({
|
|
103
|
+
amount: schema_utils_1.Type.Number(),
|
|
104
|
+
addr: exports.MoneroAccountPublicAddress,
|
|
105
|
+
is_subaddress: schema_utils_1.Type.Boolean(),
|
|
106
|
+
original: schema_utils_1.Type.String(),
|
|
107
|
+
is_integrated: schema_utils_1.Type.Boolean(),
|
|
108
|
+
}, {
|
|
109
|
+
$id: 'MoneroTransactionDestinationEntry',
|
|
110
|
+
});
|
|
111
|
+
exports.MoneroTransactionRsigData = schema_utils_1.Type.Object({
|
|
112
|
+
rsig_type: schema_utils_1.Type.Number(),
|
|
113
|
+
offload_type: schema_utils_1.Type.Optional(schema_utils_1.Type.Number()),
|
|
114
|
+
grouping: schema_utils_1.Type.Array(schema_utils_1.Type.Number()),
|
|
115
|
+
mask: schema_utils_1.Type.Optional(schema_utils_1.Type.String()),
|
|
116
|
+
rsig: schema_utils_1.Type.Optional(schema_utils_1.Type.String()),
|
|
117
|
+
rsig_parts: schema_utils_1.Type.Optional(schema_utils_1.Type.Array(schema_utils_1.Type.String())),
|
|
118
|
+
bp_version: schema_utils_1.Type.Number(),
|
|
119
|
+
}, {
|
|
120
|
+
$id: 'MoneroTransactionRsigData',
|
|
121
|
+
});
|
|
122
|
+
exports.MoneroTransactionData = schema_utils_1.Type.Object({
|
|
123
|
+
version: schema_utils_1.Type.Number(),
|
|
124
|
+
payment_id: schema_utils_1.Type.Optional(schema_utils_1.Type.String()),
|
|
125
|
+
unlock_time: schema_utils_1.Type.Number(),
|
|
126
|
+
outputs: schema_utils_1.Type.Array(exports.MoneroTransactionDestinationEntry),
|
|
127
|
+
change_dts: schema_utils_1.Type.Optional(exports.MoneroTransactionDestinationEntry),
|
|
128
|
+
num_inputs: schema_utils_1.Type.Number(),
|
|
129
|
+
mixin: schema_utils_1.Type.Number(),
|
|
130
|
+
fee: schema_utils_1.Type.Number(),
|
|
131
|
+
account: schema_utils_1.Type.Number(),
|
|
132
|
+
rsig_data: exports.MoneroTransactionRsigData,
|
|
133
|
+
minor_indices: schema_utils_1.Type.Optional(schema_utils_1.Type.Array(schema_utils_1.Type.Number())),
|
|
134
|
+
integrated_indices: schema_utils_1.Type.Optional(schema_utils_1.Type.Array(schema_utils_1.Type.Number())),
|
|
135
|
+
client_version: schema_utils_1.Type.Number(),
|
|
136
|
+
hard_fork: schema_utils_1.Type.Number(),
|
|
137
|
+
monero_version: schema_utils_1.Type.Optional(schema_utils_1.Type.String()),
|
|
138
|
+
chunkify: schema_utils_1.Type.Optional(schema_utils_1.Type.Boolean()),
|
|
139
|
+
}, {
|
|
140
|
+
$id: 'MoneroTransactionData',
|
|
141
|
+
});
|
|
142
|
+
exports.MoneroSignTransaction = schema_utils_1.Type.Object({
|
|
143
|
+
path: params_1.DerivationPath,
|
|
144
|
+
networkType: constants_1.PROTO.EnumMoneroNetworkType,
|
|
145
|
+
tsx_data: exports.MoneroTransactionData,
|
|
146
|
+
inputs: schema_utils_1.Type.Array(exports.MoneroTransactionSourceEntry),
|
|
147
|
+
}, {
|
|
148
|
+
$id: 'MoneroSignTransaction',
|
|
149
|
+
});
|
|
150
|
+
exports.MoneroRingCtSig = schema_utils_1.Type.Object({
|
|
151
|
+
txn_fee: schema_utils_1.Type.Optional(schema_utils_1.Type.Number()),
|
|
152
|
+
message: schema_utils_1.Type.Optional(schema_utils_1.Type.String()),
|
|
153
|
+
rv_type: schema_utils_1.Type.Optional(schema_utils_1.Type.Number()),
|
|
154
|
+
}, {
|
|
155
|
+
$id: 'MoneroRingCtSig',
|
|
156
|
+
});
|
|
157
|
+
exports.MoneroSignedTransaction = schema_utils_1.Type.Object({
|
|
158
|
+
signatures: schema_utils_1.Type.Array(schema_utils_1.Type.String()),
|
|
159
|
+
tx_prefix_hash: schema_utils_1.Type.String(),
|
|
160
|
+
rv: exports.MoneroRingCtSig,
|
|
161
|
+
cout_key: schema_utils_1.Type.Optional(schema_utils_1.Type.String()),
|
|
162
|
+
salt: schema_utils_1.Type.Optional(schema_utils_1.Type.String()),
|
|
163
|
+
rand_mult: schema_utils_1.Type.Optional(schema_utils_1.Type.String()),
|
|
164
|
+
tx_enc_keys: schema_utils_1.Type.Optional(schema_utils_1.Type.String()),
|
|
165
|
+
opening_key: schema_utils_1.Type.Optional(schema_utils_1.Type.String()),
|
|
166
|
+
pseudo_outs: schema_utils_1.Type.Array(schema_utils_1.Type.String()),
|
|
167
|
+
}, {
|
|
168
|
+
$id: 'MoneroSignedTransaction',
|
|
169
|
+
});
|
|
170
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { MoneroAddress, MoneroGetAddress as MoneroGetAddressParams } from './monero';
|
|
2
|
+
import type { BundledParams, Params, Response } from '../params';
|
|
3
|
+
export declare function moneroGetAddress(params: Params<MoneroGetAddressParams>): Response<MoneroAddress>;
|
|
4
|
+
export declare function moneroGetAddress(params: BundledParams<MoneroGetAddressParams>): Response<MoneroAddress[]>;
|
|
5
|
+
//# sourceMappingURL=moneroGetAddress.d.ts.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Params, Response } from '../params';
|
|
2
|
+
import type { MoneroGetWatchKey, MoneroWatchKey } from './monero';
|
|
3
|
+
export declare function moneroGetWatchKey(params: Params<MoneroGetWatchKey>): Response<MoneroWatchKey>;
|
|
4
|
+
//# sourceMappingURL=moneroGetWatchKey.d.ts.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Params, Response } from '../params';
|
|
2
|
+
import type { MoneroKeyImageSync, MoneroKeyImageSyncResult } from './monero';
|
|
3
|
+
export declare function moneroKeyImageSync(params: Params<MoneroKeyImageSync>): Response<MoneroKeyImageSyncResult>;
|
|
4
|
+
//# sourceMappingURL=moneroKeyImageSync.d.ts.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Params, Response } from '../params';
|
|
2
|
+
import type { MoneroSignTransaction, MoneroSignedTransaction } from './monero';
|
|
3
|
+
export declare function moneroSignTransaction(params: Params<MoneroSignTransaction>): Response<MoneroSignedTransaction>;
|
|
4
|
+
//# sourceMappingURL=moneroSignTransaction.d.ts.map
|
package/lib/types/firmware.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export type FirmwareRange = Record<DeviceModelInternal, {
|
|
|
6
6
|
export type BinaryInfo = {
|
|
7
7
|
binary: ArrayBuffer;
|
|
8
8
|
binaryVersion: VersionArray;
|
|
9
|
-
|
|
9
|
+
release?: FirmwareRelease;
|
|
10
10
|
};
|
|
11
11
|
export type FirmwareReleaseConfigInfo = {
|
|
12
12
|
firmwareType: FirmwareType;
|
package/lib/types/index.d.ts
CHANGED
package/lib/types/index.js
CHANGED
|
@@ -15,6 +15,7 @@ tslib_1.__exportStar(require("./api/bitcoin"), exports);
|
|
|
15
15
|
tslib_1.__exportStar(require("./api/eos"), exports);
|
|
16
16
|
tslib_1.__exportStar(require("./api/ripple"), exports);
|
|
17
17
|
tslib_1.__exportStar(require("./api/ethereum"), exports);
|
|
18
|
+
tslib_1.__exportStar(require("./api/monero"), exports);
|
|
18
19
|
tslib_1.__exportStar(require("./api/solana"), exports);
|
|
19
20
|
tslib_1.__exportStar(require("./api/stellar"), exports);
|
|
20
21
|
tslib_1.__exportStar(require("./api/tezos"), exports);
|
package/lib/types/settings.d.ts
CHANGED
|
@@ -62,11 +62,11 @@ export interface ConnectSettingsInternal {
|
|
|
62
62
|
}
|
|
63
63
|
export interface ConnectSettingsWeb {
|
|
64
64
|
hostLabel?: string;
|
|
65
|
-
coreMode?: 'auto' | 'popup' | 'iframe' | 'deeplink' | 'suite-desktop';
|
|
65
|
+
coreMode?: 'auto' | 'popup' | 'iframe' | 'deeplink' | 'suite-desktop' | 'suite-web';
|
|
66
66
|
}
|
|
67
67
|
export interface ConnectSettingsWebextension {
|
|
68
68
|
_extendWebextensionLifetime?: boolean;
|
|
69
|
-
coreMode?: 'auto' | 'popup' | 'suite-desktop';
|
|
69
|
+
coreMode?: 'auto' | 'popup' | 'suite-desktop' | 'suite-web';
|
|
70
70
|
}
|
|
71
71
|
export interface ConnectSettingsMobile {
|
|
72
72
|
deeplinkUrl: string;
|
|
@@ -11,6 +11,11 @@ const createUiPromiseManager = (interactionTimeout) => {
|
|
|
11
11
|
...(0, utils_1.createDeferred)(promiseEvent),
|
|
12
12
|
device,
|
|
13
13
|
};
|
|
14
|
+
const existing = _uiPromises.findIndex(p => p.id === promiseEvent);
|
|
15
|
+
if (existing >= 0) {
|
|
16
|
+
console.warn(`UiPromise '${promiseEvent}' already exists.`);
|
|
17
|
+
_uiPromises.splice(existing, 1);
|
|
18
|
+
}
|
|
14
19
|
_uiPromises.push(uiPromise);
|
|
15
20
|
interactionTimeout();
|
|
16
21
|
return uiPromise;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trezor/connect",
|
|
3
|
-
"version": "9.6.
|
|
3
|
+
"version": "9.6.5-beta.1",
|
|
4
4
|
"author": "Trezor <info@trezor.io>",
|
|
5
5
|
"homepage": "https://github.com/trezor/trezor-suite/tree/develop/packages/connect",
|
|
6
6
|
"description": "High-level javascript interface for Trezor hardware wallet.",
|
|
@@ -79,21 +79,22 @@
|
|
|
79
79
|
"@solana-program/token": "^0.5.1",
|
|
80
80
|
"@solana-program/token-2022": "^0.4.2",
|
|
81
81
|
"@solana/kit": "^2.3.0",
|
|
82
|
-
"@trezor/blockchain-link": "2.5.
|
|
83
|
-
"@trezor/blockchain-link-types": "1.4.
|
|
84
|
-
"@trezor/blockchain-link-utils": "1.4.
|
|
85
|
-
"@trezor/connect-analytics": "1.3.
|
|
86
|
-
"@trezor/connect-common": "0.4.
|
|
82
|
+
"@trezor/blockchain-link": "2.5.5-beta.1",
|
|
83
|
+
"@trezor/blockchain-link-types": "1.4.5-beta.1",
|
|
84
|
+
"@trezor/blockchain-link-utils": "1.4.5-beta.1",
|
|
85
|
+
"@trezor/connect-analytics": "1.3.7-beta.1",
|
|
86
|
+
"@trezor/connect-common": "0.4.5-beta.1",
|
|
87
87
|
"@trezor/crypto-utils": "1.1.5",
|
|
88
|
-
"@trezor/device-
|
|
88
|
+
"@trezor/device-authenticity": "1.0.0",
|
|
89
|
+
"@trezor/device-utils": "1.1.5-beta.1",
|
|
89
90
|
"@trezor/env-utils": "^1.4.3",
|
|
90
|
-
"@trezor/protobuf": "1.4.
|
|
91
|
-
"@trezor/protocol": "1.2.
|
|
91
|
+
"@trezor/protobuf": "1.4.5-beta.1",
|
|
92
|
+
"@trezor/protocol": "1.2.11-beta.1",
|
|
92
93
|
"@trezor/schema-utils": "1.3.4",
|
|
93
|
-
"@trezor/transport": "1.5.
|
|
94
|
+
"@trezor/transport": "1.5.5-beta.1",
|
|
94
95
|
"@trezor/type-utils": "1.1.9",
|
|
95
|
-
"@trezor/utils": "9.4.
|
|
96
|
-
"@trezor/utxo-lib": "2.4.
|
|
96
|
+
"@trezor/utils": "9.4.5-beta.1",
|
|
97
|
+
"@trezor/utxo-lib": "2.4.5-beta.1",
|
|
97
98
|
"blakejs": "^1.2.1",
|
|
98
99
|
"bs58": "^6.0.0",
|
|
99
100
|
"bs58check": "^4.0.0",
|
|
@@ -122,7 +123,7 @@
|
|
|
122
123
|
"ts-node": "^10.9.2",
|
|
123
124
|
"tsx": "^4.20.3",
|
|
124
125
|
"web3-utils": "^4.3.2",
|
|
125
|
-
"webpack": "5.
|
|
126
|
+
"webpack": "5.102.1",
|
|
126
127
|
"ws": "^8.18.0"
|
|
127
128
|
},
|
|
128
129
|
"peerDependencies": {
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { PROTO } from '../../constants';
|
|
2
|
-
import { DeviceAuthenticityBlacklistConfig } from '../../data/deviceAuthenticityBlacklistConfig';
|
|
3
|
-
import { DeviceAuthenticityConfig } from '../../data/deviceAuthenticityConfigTypes';
|
|
4
|
-
import { AuthenticateDeviceResult } from '../../types/api/authenticateDevice';
|
|
5
|
-
interface AuthenticityProofData extends PROTO.AuthenticityProof {
|
|
6
|
-
challenge: Buffer;
|
|
7
|
-
config: DeviceAuthenticityConfig;
|
|
8
|
-
blacklistConfig: DeviceAuthenticityBlacklistConfig;
|
|
9
|
-
allowDebugKeys?: boolean;
|
|
10
|
-
deviceModel: keyof typeof PROTO.DeviceModelInternal;
|
|
11
|
-
}
|
|
12
|
-
export declare const getRandomChallenge: () => Buffer<ArrayBufferLike>;
|
|
13
|
-
export declare const verifyAuthenticityProof: ({ optiga_certificates, optiga_signature, challenge, config, blacklistConfig, allowDebugKeys, deviceModel, }: AuthenticityProofData) => Promise<AuthenticateDeviceResult>;
|
|
14
|
-
export {};
|
|
15
|
-
//# sourceMappingURL=verifyAuthenticityProof.d.ts.map
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.verifyAuthenticityProof = exports.getRandomChallenge = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const crypto = tslib_1.__importStar(require("crypto"));
|
|
6
|
-
const crypto_utils_1 = require("@trezor/crypto-utils");
|
|
7
|
-
const utils_1 = require("@trezor/utils");
|
|
8
|
-
const x509certificate_1 = require("./x509certificate");
|
|
9
|
-
const verifySignature = async (rawKey, data, signature) => {
|
|
10
|
-
const signer = crypto.createVerify('sha256');
|
|
11
|
-
signer.update(Buffer.from(data));
|
|
12
|
-
const SubtleCrypto = (0, crypto_utils_1.getSubtleCrypto)();
|
|
13
|
-
const ecPubKey = await SubtleCrypto.importKey('raw', rawKey, { name: 'ECDSA', namedCurve: 'P-256' }, true, ['verify']);
|
|
14
|
-
const spkiPubKey = await SubtleCrypto.exportKey('spki', ecPubKey);
|
|
15
|
-
const key = `-----BEGIN PUBLIC KEY-----\n${Buffer.from(spkiPubKey).toString('base64')}\n-----END PUBLIC KEY-----`;
|
|
16
|
-
return signer.verify({ key }, Buffer.from(signature));
|
|
17
|
-
};
|
|
18
|
-
const getRandomChallenge = () => crypto.randomBytes(32);
|
|
19
|
-
exports.getRandomChallenge = getRandomChallenge;
|
|
20
|
-
const validateCaCertExtensions = (cert, pathLen) => {
|
|
21
|
-
let hasKeyUsage, hasBasicConstraints = false;
|
|
22
|
-
cert.tbsCertificate.extensions.forEach(ext => {
|
|
23
|
-
if (ext.key === 'keyUsage') {
|
|
24
|
-
if (ext.keyCertSign !== '1') {
|
|
25
|
-
throw new Error(`CA keyCertSign not set`);
|
|
26
|
-
}
|
|
27
|
-
hasKeyUsage = true;
|
|
28
|
-
}
|
|
29
|
-
else if (ext.key === 'basicConstraints') {
|
|
30
|
-
if (!ext.cA) {
|
|
31
|
-
throw new Error(`CA basicConstraints.cA not set`);
|
|
32
|
-
}
|
|
33
|
-
if (typeof ext.pathLenConstraint != 'number') {
|
|
34
|
-
throw new Error('CA basicConstraints.pathLenConstraint not set');
|
|
35
|
-
}
|
|
36
|
-
if (ext.pathLenConstraint < pathLen) {
|
|
37
|
-
throw new Error('Issuer was not permitted to issue certificate');
|
|
38
|
-
}
|
|
39
|
-
hasBasicConstraints = true;
|
|
40
|
-
}
|
|
41
|
-
else if (ext.critical) {
|
|
42
|
-
throw new Error(`Unknown critical extension ${ext.key} in CA certificate`);
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
if (!hasKeyUsage || !hasBasicConstraints) {
|
|
46
|
-
throw new Error(`CA missing extensions keyUsage: ${hasKeyUsage}, basicConstraints: ${hasBasicConstraints}`);
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
const verifyAuthenticityProof = async ({ optiga_certificates, optiga_signature, challenge, config, blacklistConfig, allowDebugKeys, deviceModel, }) => {
|
|
50
|
-
const modelConfig = config[deviceModel];
|
|
51
|
-
if (!modelConfig) {
|
|
52
|
-
throw new Error(`Pubkeys for ${deviceModel} not found in config`);
|
|
53
|
-
}
|
|
54
|
-
const { debug } = modelConfig;
|
|
55
|
-
const { blacklistedCaPubKeys, debug: debugBlacklist } = blacklistConfig;
|
|
56
|
-
const [deviceCert, caCert] = optiga_certificates.map((c, i) => {
|
|
57
|
-
const cert = (0, x509certificate_1.parseCertificate)(new Uint8Array(Buffer.from(c, 'hex')));
|
|
58
|
-
if (i === 0) {
|
|
59
|
-
return cert;
|
|
60
|
-
}
|
|
61
|
-
validateCaCertExtensions(cert, i - 1);
|
|
62
|
-
return cert;
|
|
63
|
-
});
|
|
64
|
-
const caPubKey = Buffer.from(caCert.tbsCertificate.subjectPublicKeyInfo.bits.bytes).toString('hex');
|
|
65
|
-
const rootPubKeys = allowDebugKeys
|
|
66
|
-
? modelConfig.rootPubKeys.concat(debug?.rootPubKeys || [])
|
|
67
|
-
: modelConfig.rootPubKeys;
|
|
68
|
-
const isCertSignedByRootPubkey = await Promise.all(rootPubKeys.map(rootPubKey => verifySignature(Buffer.from(rootPubKey, 'hex'), caCert.tbsCertificate.asn1.raw, caCert.signatureValue.bits.bytes)));
|
|
69
|
-
const rootPubKeyIndex = isCertSignedByRootPubkey.findIndex(valid => !!valid);
|
|
70
|
-
const rootPubKey = rootPubKeys[rootPubKeyIndex];
|
|
71
|
-
const isDebugRootPubKey = debug?.rootPubKeys.includes(rootPubKey);
|
|
72
|
-
const caCertValidityFrom = caCert.tbsCertificate.validity.from.getTime();
|
|
73
|
-
if (caCertValidityFrom > new Date().getTime()) {
|
|
74
|
-
throw new Error(`CA validity from ${caCertValidityFrom} cant't be in the future!`);
|
|
75
|
-
}
|
|
76
|
-
if (!rootPubKey) {
|
|
77
|
-
return {
|
|
78
|
-
valid: false,
|
|
79
|
-
caPubKey,
|
|
80
|
-
error: 'ROOT_PUBKEY_NOT_FOUND',
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
const [subject] = deviceCert.tbsCertificate.subject;
|
|
84
|
-
if (!subject.parameters || subject.algorithm !== '2.5.4.3') {
|
|
85
|
-
throw new Error('Missing certificate subject');
|
|
86
|
-
}
|
|
87
|
-
const subjectValue = Buffer.from(subject.parameters.asn1.contents.subarray(0, 4)).toString();
|
|
88
|
-
if (subjectValue !== deviceModel) {
|
|
89
|
-
return {
|
|
90
|
-
valid: false,
|
|
91
|
-
caPubKey,
|
|
92
|
-
error: 'INVALID_DEVICE_MODEL',
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
const isDeviceCertValid = await verifySignature(Buffer.from(caCert.tbsCertificate.subjectPublicKeyInfo.bits.bytes), deviceCert.tbsCertificate.asn1.raw, deviceCert.signatureValue.bits.bytes);
|
|
96
|
-
const challengePrefix = Buffer.from('AuthenticateDevice:');
|
|
97
|
-
const prefixedChallenge = Buffer.concat([
|
|
98
|
-
utils_1.bufferUtils.getChunkSize(challengePrefix.length),
|
|
99
|
-
challengePrefix,
|
|
100
|
-
utils_1.bufferUtils.getChunkSize(challenge.length),
|
|
101
|
-
challenge,
|
|
102
|
-
]);
|
|
103
|
-
const isSignatureValid = await verifySignature(Buffer.from(deviceCert.tbsCertificate.subjectPublicKeyInfo.bits.bytes), prefixedChallenge, (0, x509certificate_1.fixSignature)(Buffer.from(optiga_signature, 'hex')));
|
|
104
|
-
if (rootPubKey && isDeviceCertValid && isSignatureValid) {
|
|
105
|
-
if ((!isDebugRootPubKey && blacklistedCaPubKeys.includes(caPubKey)) ||
|
|
106
|
-
(isDebugRootPubKey && debugBlacklist?.blacklistedCaPubKeys.includes(caPubKey))) {
|
|
107
|
-
return {
|
|
108
|
-
valid: false,
|
|
109
|
-
caPubKey,
|
|
110
|
-
error: 'CA_PUBKEY_BLACKLISTED',
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
return {
|
|
114
|
-
valid: true,
|
|
115
|
-
caPubKey,
|
|
116
|
-
debugKey: isDebugRootPubKey,
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
if (!isDeviceCertValid) {
|
|
120
|
-
return {
|
|
121
|
-
valid: false,
|
|
122
|
-
caPubKey,
|
|
123
|
-
error: 'INVALID_DEVICE_CERTIFICATE',
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
return {
|
|
127
|
-
valid: false,
|
|
128
|
-
caPubKey,
|
|
129
|
-
error: 'INVALID_DEVICE_SIGNATURE',
|
|
130
|
-
};
|
|
131
|
-
};
|
|
132
|
-
exports.verifyAuthenticityProof = verifyAuthenticityProof;
|
|
133
|
-
//# sourceMappingURL=verifyAuthenticityProof.js.map
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
interface Asn1 {
|
|
2
|
-
cls: number;
|
|
3
|
-
tag: number;
|
|
4
|
-
structured: boolean;
|
|
5
|
-
byteLength: number;
|
|
6
|
-
contents: Uint8Array;
|
|
7
|
-
raw: Uint8Array;
|
|
8
|
-
}
|
|
9
|
-
type Oid = `${number}.${number}.${number}.${number}`;
|
|
10
|
-
type Extension = {
|
|
11
|
-
key: 'keyUsage';
|
|
12
|
-
critical?: boolean;
|
|
13
|
-
keyCertSign: '0' | '1';
|
|
14
|
-
} | {
|
|
15
|
-
key: 'basicConstraints';
|
|
16
|
-
critical?: boolean;
|
|
17
|
-
cA: boolean;
|
|
18
|
-
pathLenConstraint?: number;
|
|
19
|
-
} | (Asn1 & {
|
|
20
|
-
key: Oid;
|
|
21
|
-
critical?: boolean;
|
|
22
|
-
});
|
|
23
|
-
export declare const fixSignature: (byteArray: Uint8Array) => Uint8Array<ArrayBuffer>;
|
|
24
|
-
export declare const parseName: (asn1: Asn1) => {
|
|
25
|
-
asn1: Asn1;
|
|
26
|
-
algorithm: `${number}.${number}.${number}.${number}`;
|
|
27
|
-
parameters: {
|
|
28
|
-
asn1: Asn1;
|
|
29
|
-
} | null;
|
|
30
|
-
}[];
|
|
31
|
-
export declare const parseCertificate: (byteArray: Uint8Array) => {
|
|
32
|
-
asn1: Asn1;
|
|
33
|
-
tbsCertificate: {
|
|
34
|
-
asn1: Asn1;
|
|
35
|
-
version: Asn1;
|
|
36
|
-
serialNumber: Asn1;
|
|
37
|
-
signature: {
|
|
38
|
-
asn1: Asn1;
|
|
39
|
-
algorithm: `${number}.${number}.${number}.${number}`;
|
|
40
|
-
parameters: {
|
|
41
|
-
asn1: Asn1;
|
|
42
|
-
} | null;
|
|
43
|
-
};
|
|
44
|
-
issuer: Asn1;
|
|
45
|
-
validity: {
|
|
46
|
-
from: Date;
|
|
47
|
-
to: Date;
|
|
48
|
-
};
|
|
49
|
-
subject: {
|
|
50
|
-
asn1: Asn1;
|
|
51
|
-
algorithm: `${number}.${number}.${number}.${number}`;
|
|
52
|
-
parameters: {
|
|
53
|
-
asn1: Asn1;
|
|
54
|
-
} | null;
|
|
55
|
-
}[];
|
|
56
|
-
subjectPublicKeyInfo: {
|
|
57
|
-
asn1: Asn1;
|
|
58
|
-
algorithm: {
|
|
59
|
-
asn1: Asn1;
|
|
60
|
-
algorithm: `${number}.${number}.${number}.${number}`;
|
|
61
|
-
parameters: {
|
|
62
|
-
asn1: Asn1;
|
|
63
|
-
} | null;
|
|
64
|
-
};
|
|
65
|
-
bits: {
|
|
66
|
-
unusedBits: number;
|
|
67
|
-
bytes: Uint8Array<ArrayBufferLike>;
|
|
68
|
-
};
|
|
69
|
-
};
|
|
70
|
-
extensions: Extension[];
|
|
71
|
-
};
|
|
72
|
-
signatureAlgorithm: {
|
|
73
|
-
asn1: Asn1;
|
|
74
|
-
algorithm: `${number}.${number}.${number}.${number}`;
|
|
75
|
-
parameters: {
|
|
76
|
-
asn1: Asn1;
|
|
77
|
-
} | null;
|
|
78
|
-
};
|
|
79
|
-
signatureValue: {
|
|
80
|
-
asn1: Asn1;
|
|
81
|
-
bits: {
|
|
82
|
-
unusedBits: number;
|
|
83
|
-
bytes: Uint8Array<ArrayBuffer>;
|
|
84
|
-
};
|
|
85
|
-
};
|
|
86
|
-
};
|
|
87
|
-
export {};
|
|
88
|
-
//# sourceMappingURL=x509certificate.d.ts.map
|