@@ -45,7 +45,7 @@ function requestTunnelMessage(deviceId: number, port: number) {
45
45
}
46
46
47
47
type ResultMessage = { MessageType : 'Result' , Number : number } ;
48
- type AttachedMessage = { MessageType : 'Attached' , DeviceID : number , Properties : Record < string , string | number > } ;
48
+ type AttachedMessage = { MessageType : 'Attached' , DeviceID : number , Properties : DeviceInfo } ;
49
49
type DetachedMessage = { MessageType : 'Detached' , DeviceID : number } ;
50
50
51
51
type ResponseMessage =
@@ -154,6 +154,16 @@ const connectSocket = async (options: net.NetConnectOpts) => {
154
154
return conn ;
155
155
}
156
156
157
+ // Most properties optional because we're not sure what's actually guaranteed:
158
+ export interface DeviceInfo {
159
+ DeviceID : number ;
160
+ ConnectionSpeed ?: number ;
161
+ ConnectionType ?: string ;
162
+ LocationID ?: number ;
163
+ ProductID ?: number ;
164
+ SerialNumber ?: string ;
165
+ }
166
+
157
167
export class UsbmuxClient {
158
168
159
169
constructor (
@@ -209,7 +219,7 @@ export class UsbmuxClient {
209
219
}
210
220
}
211
221
212
- private deviceData : Record < string , Record < string , string | number > > = { } ;
222
+ private deviceData : Record < string , DeviceInfo > = { } ;
213
223
214
224
// Listen for events by using readMessageFromStream in an async iterator:
215
225
async listenToMessages ( socket : net . Socket ) {
@@ -229,7 +239,7 @@ export class UsbmuxClient {
229
239
}
230
240
}
231
241
232
- async getDevices ( ) {
242
+ async getDevices ( ) : Promise < Record < string , DeviceInfo > > {
233
243
await this . startListeningForDevices ( ) ;
234
244
return this . deviceData ;
235
245
}
0 commit comments