Skip to content

Commit 2109d34

Browse files
feat(hardware-trezor): whitelist trezor safe 3 device model
1 parent c359086 commit 2109d34

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

packages/hardware-trezor/src/TrezorKeyAgent.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
errors,
1717
util
1818
} from '@cardano-sdk/key-management';
19+
import { WhitelistedDeviceModel } from './utils';
1920
import { areStringsEqualInConstantTime } from '@cardano-sdk/util';
2021
import { txToTrezor } from './transformers/tx';
2122
import _TrezorConnectWeb from '@trezor/connect-web';
@@ -129,7 +130,7 @@ export class TrezorKeyAgent extends KeyAgentBase {
129130
if (!deviceFeatures.success) {
130131
throw new errors.TransportError('Failed to get device', deviceFeatures.payload);
131132
}
132-
if (deviceFeatures.payload.model !== 'T') {
133+
if (!(Object.values(WhitelistedDeviceModel) as string[]).includes(deviceFeatures.payload.model)) {
133134
throw new errors.TransportError(`Trezor device model "${deviceFeatures.payload.model}" is not supported.`);
134135
}
135136
return deviceFeatures.payload;

packages/hardware-trezor/src/utils.ts

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export enum WhitelistedDeviceModel {
2+
ModelT = 'T',
3+
Safe3 = 'Safe 3'
4+
}

0 commit comments

Comments
 (0)