@trezor/connect
Version:
High-level javascript interface for Trezor hardware wallet.
155 lines • 4.96 kB
TypeScript
import { Descriptor } from '@trezor/transport';
import type { PROTO } from '../constants';
import type { ReleaseInfo } from './firmware';
export type DeviceStatus = 'available' | 'occupied' | 'used';
export type DeviceMode = 'normal' | 'bootloader' | 'initialize' | 'seedless';
export type DeviceFirmwareStatus = 'valid' | 'outdated' | 'required' | 'unknown' | 'custom' | 'none';
export type UnavailableCapability = 'no-capability' | 'no-support' | 'update-required' | 'trezor-connect-outdated';
export declare enum FirmwareType {
BitcoinOnly = "bitcoin-only",
Regular = "regular"
}
export type StaticSessionId = `${string}@${string}:${number}`;
export type DeviceState = {
sessionId?: string;
staticSessionId?: StaticSessionId;
deriveCardano?: boolean;
};
export type UnavailableCapabilities = {
[key: string]: UnavailableCapability;
};
export type FirmwareRevisionCheckError = 'revision-mismatch' | 'firmware-version-unknown' | 'cannot-perform-check-offline' | 'other-error';
export type FirmwareRevisionCheckResult = {
success: true;
} | {
success: false;
error: FirmwareRevisionCheckError;
};
export type FirmwareHashCheckError = 'hash-mismatch' | 'check-skipped' | 'check-unsupported' | 'unknown-release' | 'other-error';
export type FirmwareHashCheckResult = {
success: true;
attemptCount?: number;
warningPayload?: unknown;
} | {
success: false;
error: FirmwareHashCheckError;
attemptCount?: number;
errorPayload?: unknown;
};
export type DeviceUniquePath = string & {
__type: 'DeviceUniquePath';
};
export declare const DeviceUniquePath: (id: string) => DeviceUniquePath;
type BaseDevice = {
path: DeviceUniquePath;
name: string;
};
export type BluetoothDeviceProps = {
id: string;
};
export type KnownDevice = BaseDevice & {
type: 'acquired';
id: string | null;
label: string;
error?: typeof undefined;
firmware: DeviceFirmwareStatus;
firmwareRelease?: ReleaseInfo | null;
firmwareType?: FirmwareType;
color?: string;
status: DeviceStatus;
mode: DeviceMode;
_state?: DeviceState;
state?: DeviceState['staticSessionId'];
features: PROTO.Features;
unavailableCapabilities: UnavailableCapabilities;
availableTranslations: string[];
authenticityChecks?: {
firmwareRevision: FirmwareRevisionCheckResult | null;
firmwareHash: FirmwareHashCheckResult | null;
};
transportSessionOwner?: undefined;
transportDescriptorType?: typeof undefined;
bluetoothProps?: BluetoothDeviceProps;
};
export type UnknownDevice = BaseDevice & {
type: 'unacquired';
label: 'Unacquired device';
id?: typeof undefined;
error?: typeof undefined;
features?: typeof undefined;
firmware?: typeof undefined;
firmwareRelease?: typeof undefined;
firmwareType?: typeof undefined;
color?: typeof undefined;
status?: typeof undefined;
mode?: typeof undefined;
_state?: typeof undefined;
state?: typeof undefined;
unavailableCapabilities?: typeof undefined;
availableTranslations?: typeof undefined;
transportSessionOwner?: string;
transportDescriptorType?: typeof undefined;
bluetoothProps?: BluetoothDeviceProps;
};
export type UnreadableDevice = BaseDevice & {
type: 'unreadable';
label: 'Unreadable device';
error: string;
id?: typeof undefined;
features?: typeof undefined;
firmware?: typeof undefined;
firmwareRelease?: typeof undefined;
firmwareType?: typeof undefined;
color?: typeof undefined;
status?: typeof undefined;
mode?: typeof undefined;
_state?: typeof undefined;
state?: typeof undefined;
unavailableCapabilities?: typeof undefined;
availableTranslations?: typeof undefined;
transportSessionOwner?: undefined;
transportDescriptorType: Descriptor['type'];
bluetoothProps?: BluetoothDeviceProps;
};
export type Device = KnownDevice | UnknownDevice | UnreadableDevice;
export type Features = PROTO.Features;
export { DeviceModelInternal } from '@trezor/protobuf';
export type DisplayRotation = PROTO.DisplayRotation;
type FeaturesNarrowing = {
major_version: 2;
fw_major: null;
fw_minor: null;
fw_patch: null;
bootloader_mode: true;
firmware_present: false;
} | {
major_version: 2;
fw_major: null;
fw_minor: null;
fw_patch: null;
bootloader_mode: null;
firmware_present: null;
} | {
major_version: 2;
fw_major: 2;
fw_minor: number;
fw_patch: number;
bootloader_mode: true;
firmware_present: true;
} | {
major_version: 1;
fw_major: null;
fw_minor: null;
fw_patch: null;
bootloader_mode: true;
firmware_present: false;
} | {
major_version: 1;
fw_major: null;
fw_minor: null;
fw_patch: null;
bootloader_mode: true;
firmware_present: true;
};
export type StrictFeatures = Features & FeaturesNarrowing;
//# sourceMappingURL=device.d.ts.map