@onekeyfe/hwk-trezor-adapter 1.2.2-alpha.1 → 1.2.2-alpha.100
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/dist/index.d.mts +2 -89
- package/dist/index.d.ts +2 -89
- package/dist/index.js +28 -811
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3 -786
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -6
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IHardwareWallet, IConnector, TransportType, DeviceInfo, Response, ChainCapability, AllNetworkGetAddressParams, AllNetworkAddressResponse,
|
|
1
|
+
import { IHardwareWallet, IConnector, TransportType, DeviceInfo, Response, ChainCapability, AllNetworkGetAddressParams, AllNetworkAddressResponse, TrezorDeviceSettingsParams, TrezorBrightnessParams, TrezorChangePinParams, UiResponseEvent, ChainForFingerprint, ICommonCallParams, EvmGetAddressParams, EvmAddress, EvmSignTxTrezorParams, EvmSignedTx, EvmSignMsgParams, EvmSignature, EvmSignTypedDataParams, BtcGetAddressParams, BtcAddress, BtcGetPublicKeyParams, BtcPublicKey, BtcSignTxParams, BtcSignedTx, BtcSignPsbtParams, BtcSignedPsbt, BtcSignMsgParams, BtcSignature, SolGetAddressParams, SolAddress, SolSignTxParams, SolSignedTx, SolSignMsgParams, SolSignature, TronGetAddressParams, TronAddress, TronSignTxParams, TronSignedTx, TronSignMsgParams, TronSignature, HardwareEventMap, DeviceEventListener, EvmEthereumDefinitions, ConnectorDevice } from '@onekeyfe/hwk-adapter-core';
|
|
2
2
|
|
|
3
3
|
type TrezorPassphraseCallParams = {
|
|
4
4
|
passphraseState?: string;
|
|
@@ -48,7 +48,6 @@ declare class TrezorAdapter implements IHardwareWallet {
|
|
|
48
48
|
private static _isStaleSessionError;
|
|
49
49
|
private static _errorCode;
|
|
50
50
|
private static _isConnectionUnavailableError;
|
|
51
|
-
private static _isRecoverableProtocolResidueError;
|
|
52
51
|
/**
|
|
53
52
|
* Race a promise against an abort signal. Copied from LedgerAdapter:
|
|
54
53
|
* IConnector.call() can't actually be cancelled at the protocol level, but
|
|
@@ -77,21 +76,6 @@ declare class TrezorAdapter implements IHardwareWallet {
|
|
|
77
76
|
getSupportedChains(): ChainCapability[];
|
|
78
77
|
allNetworkGetAddress(connectId: string, deviceId: string, params: AllNetworkGetAddressParams): Promise<Response<AllNetworkAddressResponse[]>>;
|
|
79
78
|
getFeatures(connectId: string): Promise<Response<Record<string, unknown>>>;
|
|
80
|
-
/**
|
|
81
|
-
* Device authenticity attestation. Sends a host-generated challenge, has the
|
|
82
|
-
* device sign it with its secure-element key, then verifies the returned
|
|
83
|
-
* certificate chain up to a trusted Trezor root CA. On success returns a
|
|
84
|
-
* `deviceId` that uniquely identifies the physical device, survives wipe, and
|
|
85
|
-
* cannot be forged from a seed. Only trust the result when `verified` is true
|
|
86
|
-
* (and `usedDebugKey` is false in production).
|
|
87
|
-
*
|
|
88
|
-
* Requires a secure-element model (Safe 3 = T2B1/T3B1, Safe 5 = T3T1, T3W1)
|
|
89
|
-
* and an on-device confirmation. Older models (T1B1, T2T1) will fail.
|
|
90
|
-
*
|
|
91
|
-
* `dangerouslyAllowDebugKeys` accepts simulator / development root keys — NEVER
|
|
92
|
-
* enable it in a production accounting flow, it lets an emulator mint any id.
|
|
93
|
-
*/
|
|
94
|
-
verifyDeviceAuthenticity(connectId: string, params?: DeviceAuthenticityParams): Promise<Response<DeviceAuthenticityResult>>;
|
|
95
79
|
deviceSettings(connectId: string, params: TrezorDeviceSettingsParams): Promise<Response<Record<string, unknown>>>;
|
|
96
80
|
setBrightness(connectId: string, params?: TrezorBrightnessParams): Promise<Response<Record<string, unknown>>>;
|
|
97
81
|
changePin(connectId: string, params?: TrezorChangePinParams): Promise<Response<Record<string, unknown>>>;
|
|
@@ -208,77 +192,6 @@ declare class TrezorAdapter implements IHardwareWallet {
|
|
|
208
192
|
private _ensureDevicePermission;
|
|
209
193
|
}
|
|
210
194
|
|
|
211
|
-
type CertPubKeys = {
|
|
212
|
-
rootPubKeysOptiga: string[];
|
|
213
|
-
rootPubKeysTropic?: string[];
|
|
214
|
-
};
|
|
215
|
-
type ModelPubKeys = CertPubKeys & {
|
|
216
|
-
debug?: CertPubKeys;
|
|
217
|
-
};
|
|
218
|
-
interface DeviceAuthenticityConfig {
|
|
219
|
-
version: number;
|
|
220
|
-
[model: string]: ModelPubKeys | number | undefined;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
/** Raw fields taken from a Trezor `AuthenticityProof` message. */
|
|
224
|
-
type AuthenticityProof = {
|
|
225
|
-
optiga_certificates: string[];
|
|
226
|
-
optiga_signature: string;
|
|
227
|
-
tropic_certificates?: string[];
|
|
228
|
-
tropic_signature?: string;
|
|
229
|
-
mcu_certificates?: string[];
|
|
230
|
-
mcu_signature?: string;
|
|
231
|
-
};
|
|
232
|
-
type AuthenticateDeviceResult = {
|
|
233
|
-
/**
|
|
234
|
-
* True only when every layer implemented by this verifier and required by
|
|
235
|
-
* the explicit model policy verified up to a trusted Trezor root CA AND the
|
|
236
|
-
* device signed our challenge:
|
|
237
|
-
* - Optiga (all secure-element models), and
|
|
238
|
-
* - Tropic (T3W1 / Safe 7).
|
|
239
|
-
* This is the currently implemented client policy, not full parity with the
|
|
240
|
-
* latest capability-based Trezor Connect policy. Raw MCU fields remain in the
|
|
241
|
-
* returned proof but are not yet a client-side pass/fail condition.
|
|
242
|
-
* The reward backend must independently verify the same raw proof under its
|
|
243
|
-
* own versioned policy; this client result is only a UX preview.
|
|
244
|
-
*/
|
|
245
|
-
verified: boolean;
|
|
246
|
-
/**
|
|
247
|
-
* SHA3-256 of the verified Optiga device-attestation public key. It survives
|
|
248
|
-
* wipe/recovery and has one representation across supported models. Do NOT
|
|
249
|
-
* trust it when `verified` is false — it is then attacker-controlled.
|
|
250
|
-
*/
|
|
251
|
-
deviceId?: string;
|
|
252
|
-
/** Raw device attestation public key (hex) from the Optiga device certificate. */
|
|
253
|
-
deviceCertPubKey?: string;
|
|
254
|
-
/** X.509 subject serial number (hex), only present on T3W1 and above. */
|
|
255
|
-
serialNumber?: string;
|
|
256
|
-
rootPubKey?: string;
|
|
257
|
-
caPubKey?: string;
|
|
258
|
-
/**
|
|
259
|
-
* True when the chain matched a DEBUG/staging root key (simulator / dev
|
|
260
|
-
* device). A production accounting flow must reject verified results that
|
|
261
|
-
* have `usedDebugKey === true`.
|
|
262
|
-
*/
|
|
263
|
-
usedDebugKey?: boolean;
|
|
264
|
-
/** Failure reason when `verified` is false. */
|
|
265
|
-
error?: string;
|
|
266
|
-
};
|
|
267
|
-
declare const getRequiredDeviceAuthenticityLayers: (deviceModel: string) => readonly ('optiga' | 'tropic')[];
|
|
268
|
-
/**
|
|
269
|
-
* Verify a Trezor `AuthenticityProof` against a challenge and derive a stable
|
|
270
|
-
* per-device id. `challenge` must be the exact random bytes sent in the
|
|
271
|
-
* `AuthenticateDevice` request. Never throws — malformed input from a malicious
|
|
272
|
-
* device is folded into `{ verified: false }`.
|
|
273
|
-
*/
|
|
274
|
-
declare const authenticateDeviceFromProof: ({ proof, challenge, deviceModel, config, allowDebugKeys, }: {
|
|
275
|
-
proof: AuthenticityProof;
|
|
276
|
-
challenge: Buffer;
|
|
277
|
-
deviceModel: string;
|
|
278
|
-
config?: DeviceAuthenticityConfig | undefined;
|
|
279
|
-
allowDebugKeys?: boolean | undefined;
|
|
280
|
-
}) => AuthenticateDeviceResult;
|
|
281
|
-
|
|
282
195
|
/**
|
|
283
196
|
* Opt-in helpers for fetching Trezor Ethereum "definitions" — the SatoshiLabs-
|
|
284
197
|
* signed network/token metadata a Trezor device uses to render friendly names
|
|
@@ -413,4 +326,4 @@ declare function isTrezorBleServiceUuid(uuid: string): boolean;
|
|
|
413
326
|
declare function isTrezorBleDescriptor(descriptor: TrezorBleDescriptor): boolean;
|
|
414
327
|
declare function resolveTrezorBleConnectId(descriptor: TrezorBleDescriptor): string;
|
|
415
328
|
|
|
416
|
-
export { type
|
|
329
|
+
export { type BuildEthereumDefinitionsForPathParams, type BuildEthereumDefinitionsForSignTxParams, DEFAULT_ETHEREUM_DEFINITIONS_BASE_URL, DEFAULT_SOLANA_TOKEN_DEFINITION_BASE_URL, type FetchEthereumDefinitionsParams, type FetchLike, type FetchSolanaTokenDefinitionParams, type SdkEvent, type SdkEventListener, type SdkLogEvent, TREZOR_BLE_PACKET_SIZE, TREZOR_BLE_SUPPORTED_MODELS, TREZOR_BLE_UUIDS, TREZOR_SAFE_7_MODEL, TrezorAdapter, type TrezorBleDescriptor, type TrezorBleTransport, type TrezorBleTransportFactory, type TrezorConnectedDevice, type TrezorConnectorDevice, buildEthereumDefinitionsForPath, buildEthereumDefinitionsForSignTx, fetchEthereumDefinitions, fetchSolanaTokenDefinition, getSlip44FromPath, isTrezorBleDescriptor, isTrezorBleServiceUuid, isTrezorBleSupportedModel, isTrezorSafe7BleDescriptor, isTrezorSafe7BleName, normalizeTrezorBleUuid, offSdkEvent, onSdkEvent, resolveTrezorBleConnectId };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IHardwareWallet, IConnector, TransportType, DeviceInfo, Response, ChainCapability, AllNetworkGetAddressParams, AllNetworkAddressResponse,
|
|
1
|
+
import { IHardwareWallet, IConnector, TransportType, DeviceInfo, Response, ChainCapability, AllNetworkGetAddressParams, AllNetworkAddressResponse, TrezorDeviceSettingsParams, TrezorBrightnessParams, TrezorChangePinParams, UiResponseEvent, ChainForFingerprint, ICommonCallParams, EvmGetAddressParams, EvmAddress, EvmSignTxTrezorParams, EvmSignedTx, EvmSignMsgParams, EvmSignature, EvmSignTypedDataParams, BtcGetAddressParams, BtcAddress, BtcGetPublicKeyParams, BtcPublicKey, BtcSignTxParams, BtcSignedTx, BtcSignPsbtParams, BtcSignedPsbt, BtcSignMsgParams, BtcSignature, SolGetAddressParams, SolAddress, SolSignTxParams, SolSignedTx, SolSignMsgParams, SolSignature, TronGetAddressParams, TronAddress, TronSignTxParams, TronSignedTx, TronSignMsgParams, TronSignature, HardwareEventMap, DeviceEventListener, EvmEthereumDefinitions, ConnectorDevice } from '@onekeyfe/hwk-adapter-core';
|
|
2
2
|
|
|
3
3
|
type TrezorPassphraseCallParams = {
|
|
4
4
|
passphraseState?: string;
|
|
@@ -48,7 +48,6 @@ declare class TrezorAdapter implements IHardwareWallet {
|
|
|
48
48
|
private static _isStaleSessionError;
|
|
49
49
|
private static _errorCode;
|
|
50
50
|
private static _isConnectionUnavailableError;
|
|
51
|
-
private static _isRecoverableProtocolResidueError;
|
|
52
51
|
/**
|
|
53
52
|
* Race a promise against an abort signal. Copied from LedgerAdapter:
|
|
54
53
|
* IConnector.call() can't actually be cancelled at the protocol level, but
|
|
@@ -77,21 +76,6 @@ declare class TrezorAdapter implements IHardwareWallet {
|
|
|
77
76
|
getSupportedChains(): ChainCapability[];
|
|
78
77
|
allNetworkGetAddress(connectId: string, deviceId: string, params: AllNetworkGetAddressParams): Promise<Response<AllNetworkAddressResponse[]>>;
|
|
79
78
|
getFeatures(connectId: string): Promise<Response<Record<string, unknown>>>;
|
|
80
|
-
/**
|
|
81
|
-
* Device authenticity attestation. Sends a host-generated challenge, has the
|
|
82
|
-
* device sign it with its secure-element key, then verifies the returned
|
|
83
|
-
* certificate chain up to a trusted Trezor root CA. On success returns a
|
|
84
|
-
* `deviceId` that uniquely identifies the physical device, survives wipe, and
|
|
85
|
-
* cannot be forged from a seed. Only trust the result when `verified` is true
|
|
86
|
-
* (and `usedDebugKey` is false in production).
|
|
87
|
-
*
|
|
88
|
-
* Requires a secure-element model (Safe 3 = T2B1/T3B1, Safe 5 = T3T1, T3W1)
|
|
89
|
-
* and an on-device confirmation. Older models (T1B1, T2T1) will fail.
|
|
90
|
-
*
|
|
91
|
-
* `dangerouslyAllowDebugKeys` accepts simulator / development root keys — NEVER
|
|
92
|
-
* enable it in a production accounting flow, it lets an emulator mint any id.
|
|
93
|
-
*/
|
|
94
|
-
verifyDeviceAuthenticity(connectId: string, params?: DeviceAuthenticityParams): Promise<Response<DeviceAuthenticityResult>>;
|
|
95
79
|
deviceSettings(connectId: string, params: TrezorDeviceSettingsParams): Promise<Response<Record<string, unknown>>>;
|
|
96
80
|
setBrightness(connectId: string, params?: TrezorBrightnessParams): Promise<Response<Record<string, unknown>>>;
|
|
97
81
|
changePin(connectId: string, params?: TrezorChangePinParams): Promise<Response<Record<string, unknown>>>;
|
|
@@ -208,77 +192,6 @@ declare class TrezorAdapter implements IHardwareWallet {
|
|
|
208
192
|
private _ensureDevicePermission;
|
|
209
193
|
}
|
|
210
194
|
|
|
211
|
-
type CertPubKeys = {
|
|
212
|
-
rootPubKeysOptiga: string[];
|
|
213
|
-
rootPubKeysTropic?: string[];
|
|
214
|
-
};
|
|
215
|
-
type ModelPubKeys = CertPubKeys & {
|
|
216
|
-
debug?: CertPubKeys;
|
|
217
|
-
};
|
|
218
|
-
interface DeviceAuthenticityConfig {
|
|
219
|
-
version: number;
|
|
220
|
-
[model: string]: ModelPubKeys | number | undefined;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
/** Raw fields taken from a Trezor `AuthenticityProof` message. */
|
|
224
|
-
type AuthenticityProof = {
|
|
225
|
-
optiga_certificates: string[];
|
|
226
|
-
optiga_signature: string;
|
|
227
|
-
tropic_certificates?: string[];
|
|
228
|
-
tropic_signature?: string;
|
|
229
|
-
mcu_certificates?: string[];
|
|
230
|
-
mcu_signature?: string;
|
|
231
|
-
};
|
|
232
|
-
type AuthenticateDeviceResult = {
|
|
233
|
-
/**
|
|
234
|
-
* True only when every layer implemented by this verifier and required by
|
|
235
|
-
* the explicit model policy verified up to a trusted Trezor root CA AND the
|
|
236
|
-
* device signed our challenge:
|
|
237
|
-
* - Optiga (all secure-element models), and
|
|
238
|
-
* - Tropic (T3W1 / Safe 7).
|
|
239
|
-
* This is the currently implemented client policy, not full parity with the
|
|
240
|
-
* latest capability-based Trezor Connect policy. Raw MCU fields remain in the
|
|
241
|
-
* returned proof but are not yet a client-side pass/fail condition.
|
|
242
|
-
* The reward backend must independently verify the same raw proof under its
|
|
243
|
-
* own versioned policy; this client result is only a UX preview.
|
|
244
|
-
*/
|
|
245
|
-
verified: boolean;
|
|
246
|
-
/**
|
|
247
|
-
* SHA3-256 of the verified Optiga device-attestation public key. It survives
|
|
248
|
-
* wipe/recovery and has one representation across supported models. Do NOT
|
|
249
|
-
* trust it when `verified` is false — it is then attacker-controlled.
|
|
250
|
-
*/
|
|
251
|
-
deviceId?: string;
|
|
252
|
-
/** Raw device attestation public key (hex) from the Optiga device certificate. */
|
|
253
|
-
deviceCertPubKey?: string;
|
|
254
|
-
/** X.509 subject serial number (hex), only present on T3W1 and above. */
|
|
255
|
-
serialNumber?: string;
|
|
256
|
-
rootPubKey?: string;
|
|
257
|
-
caPubKey?: string;
|
|
258
|
-
/**
|
|
259
|
-
* True when the chain matched a DEBUG/staging root key (simulator / dev
|
|
260
|
-
* device). A production accounting flow must reject verified results that
|
|
261
|
-
* have `usedDebugKey === true`.
|
|
262
|
-
*/
|
|
263
|
-
usedDebugKey?: boolean;
|
|
264
|
-
/** Failure reason when `verified` is false. */
|
|
265
|
-
error?: string;
|
|
266
|
-
};
|
|
267
|
-
declare const getRequiredDeviceAuthenticityLayers: (deviceModel: string) => readonly ('optiga' | 'tropic')[];
|
|
268
|
-
/**
|
|
269
|
-
* Verify a Trezor `AuthenticityProof` against a challenge and derive a stable
|
|
270
|
-
* per-device id. `challenge` must be the exact random bytes sent in the
|
|
271
|
-
* `AuthenticateDevice` request. Never throws — malformed input from a malicious
|
|
272
|
-
* device is folded into `{ verified: false }`.
|
|
273
|
-
*/
|
|
274
|
-
declare const authenticateDeviceFromProof: ({ proof, challenge, deviceModel, config, allowDebugKeys, }: {
|
|
275
|
-
proof: AuthenticityProof;
|
|
276
|
-
challenge: Buffer;
|
|
277
|
-
deviceModel: string;
|
|
278
|
-
config?: DeviceAuthenticityConfig | undefined;
|
|
279
|
-
allowDebugKeys?: boolean | undefined;
|
|
280
|
-
}) => AuthenticateDeviceResult;
|
|
281
|
-
|
|
282
195
|
/**
|
|
283
196
|
* Opt-in helpers for fetching Trezor Ethereum "definitions" — the SatoshiLabs-
|
|
284
197
|
* signed network/token metadata a Trezor device uses to render friendly names
|
|
@@ -413,4 +326,4 @@ declare function isTrezorBleServiceUuid(uuid: string): boolean;
|
|
|
413
326
|
declare function isTrezorBleDescriptor(descriptor: TrezorBleDescriptor): boolean;
|
|
414
327
|
declare function resolveTrezorBleConnectId(descriptor: TrezorBleDescriptor): string;
|
|
415
328
|
|
|
416
|
-
export { type
|
|
329
|
+
export { type BuildEthereumDefinitionsForPathParams, type BuildEthereumDefinitionsForSignTxParams, DEFAULT_ETHEREUM_DEFINITIONS_BASE_URL, DEFAULT_SOLANA_TOKEN_DEFINITION_BASE_URL, type FetchEthereumDefinitionsParams, type FetchLike, type FetchSolanaTokenDefinitionParams, type SdkEvent, type SdkEventListener, type SdkLogEvent, TREZOR_BLE_PACKET_SIZE, TREZOR_BLE_SUPPORTED_MODELS, TREZOR_BLE_UUIDS, TREZOR_SAFE_7_MODEL, TrezorAdapter, type TrezorBleDescriptor, type TrezorBleTransport, type TrezorBleTransportFactory, type TrezorConnectedDevice, type TrezorConnectorDevice, buildEthereumDefinitionsForPath, buildEthereumDefinitionsForSignTx, fetchEthereumDefinitions, fetchSolanaTokenDefinition, getSlip44FromPath, isTrezorBleDescriptor, isTrezorBleServiceUuid, isTrezorBleSupportedModel, isTrezorSafe7BleDescriptor, isTrezorSafe7BleName, normalizeTrezorBleUuid, offSdkEvent, onSdkEvent, resolveTrezorBleConnectId };
|