Skip to content

Commit

Permalink
feat(connect): add bluetoothProps to Device
Browse files Browse the repository at this point in the history
  • Loading branch information
szymonlesisz authored and peter-sanderson committed Feb 17, 2025
1 parent 390942e commit bb65a0a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/connect/src/device/Device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ export class Device extends TypedEmitter<DeviceEvents> {
public readonly transportPath;
private readonly transportSessionOwner;
private readonly transportDescriptorType;
private readonly bluetoothProps;
private session;
private lastAcquiredHere;

Expand Down Expand Up @@ -220,6 +221,7 @@ export class Device extends TypedEmitter<DeviceEvents> {
this.transportPath = descriptor.path;
this.transportSessionOwner = descriptor.sessionOwner;
this.transportDescriptorType = descriptor.type;
this.bluetoothProps = descriptor.uuid ? { uuid: descriptor.uuid } : undefined;

this.session = descriptor.session;
this.lastAcquiredHere = false;
Expand Down Expand Up @@ -1217,6 +1219,7 @@ export class Device extends TypedEmitter<DeviceEvents> {
label: 'Unacquired device',
name: this.name,
transportSessionOwner: this.transportSessionOwner,
bluetoothProps: this.bluetoothProps,
};
}
const defaultLabel = 'My Trezor';
Expand All @@ -1242,6 +1245,7 @@ export class Device extends TypedEmitter<DeviceEvents> {
unavailableCapabilities: this.unavailableCapabilities,
availableTranslations: this.availableTranslations,
authenticityChecks: this.authenticityChecks,
bluetoothProps: this.bluetoothProps,
};
}
}
7 changes: 7 additions & 0 deletions packages/connect/src/types/device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ type BaseDevice = {
name: string;
};

export type BluetoothDeviceProps = {
uuid: string;
};

export type KnownDevice = BaseDevice & {
type: 'acquired';
id: string | null;
Expand All @@ -105,6 +109,7 @@ export type KnownDevice = BaseDevice & {
};
transportSessionOwner?: undefined;
transportDescriptorType?: typeof undefined;
bluetoothProps?: BluetoothDeviceProps;
};

export type UnknownDevice = BaseDevice & {
Expand All @@ -126,6 +131,7 @@ export type UnknownDevice = BaseDevice & {
availableTranslations?: typeof undefined;
transportSessionOwner?: string;
transportDescriptorType?: typeof undefined;
bluetoothProps?: BluetoothDeviceProps;
};

export type UnreadableDevice = BaseDevice & {
Expand All @@ -147,6 +153,7 @@ export type UnreadableDevice = BaseDevice & {
availableTranslations?: typeof undefined;
transportSessionOwner?: undefined;
transportDescriptorType: Descriptor['type'];
bluetoothProps?: BluetoothDeviceProps;
};

export type Device = KnownDevice | UnknownDevice | UnreadableDevice;
Expand Down
1 change: 1 addition & 0 deletions packages/transport/src/api/abstract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export enum DEVICE_TYPE {
TypeT2 = 3,
TypeT2Boot = 4,
TypeEmulator = 5,
TypeBluetooth = 6,
}

type AccessLock = {
Expand Down
2 changes: 2 additions & 0 deletions packages/transport/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export type Descriptor = Omit<DescriptorApiLevel, 'path'> & {
debugSession?: null | Session;
/** only reported by old bridge */
debug?: boolean;
/** only reported by transport-bluetooth */
uuid?: string;
};

export interface Logger {
Expand Down

0 comments on commit bb65a0a

Please sign in to comment.