Skip to content

Commit

Permalink
feat(hardware-trezor): whitelist trezor safe 3 device model
Browse files Browse the repository at this point in the history
  • Loading branch information
tomislavhoracek committed Jun 17, 2024
1 parent c359086 commit 2109d34
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/hardware-trezor/src/TrezorKeyAgent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
errors,
util
} from '@cardano-sdk/key-management';
import { WhitelistedDeviceModel } from './utils';
import { areStringsEqualInConstantTime } from '@cardano-sdk/util';
import { txToTrezor } from './transformers/tx';
import _TrezorConnectWeb from '@trezor/connect-web';
Expand Down Expand Up @@ -129,7 +130,7 @@ export class TrezorKeyAgent extends KeyAgentBase {
if (!deviceFeatures.success) {
throw new errors.TransportError('Failed to get device', deviceFeatures.payload);
}
if (deviceFeatures.payload.model !== 'T') {
if (!(Object.values(WhitelistedDeviceModel) as string[]).includes(deviceFeatures.payload.model)) {
throw new errors.TransportError(`Trezor device model "${deviceFeatures.payload.model}" is not supported.`);
}
return deviceFeatures.payload;
Expand Down
4 changes: 4 additions & 0 deletions packages/hardware-trezor/src/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export enum WhitelistedDeviceModel {
ModelT = 'T',
Safe3 = 'Safe 3'
}

0 comments on commit 2109d34

Please sign in to comment.