1- import net from 'node:net' ;
1+ import type net from 'node:net' ;
22
33import { getLogger } from '../../../lib/logger.js' ;
44import {
55 PlistUID ,
66 createBinaryPlist ,
77 parseBinaryPlist ,
88} from '../../../lib/plist/index.js' ;
9- import type { PlistDictionary } from '../../../lib/types.js' ;
9+ import type {
10+ PlistDictionary ,
11+ SendMessageOptions ,
12+ } from '../../../lib/types.js' ;
1013import { ServiceConnection } from '../../../service-connection.js' ;
11- import { BaseService , type Service } from '../base-service.js' ;
14+ import { BaseService , type Service , stripSSL } from '../base-service.js' ;
1215import { ChannelFragmenter } from './channel-fragmenter.js' ;
1316import { Channel } from './channel.js' ;
1417import { DTXMessage , DTX_CONSTANTS , MessageAux } from './dtx-message.js' ;
@@ -68,11 +71,7 @@ export class DVTSecureSocketProxyService extends BaseService {
6871 // DVT uses DTX binary protocol, connect without plist-based RSDCheckin
6972 this . connection = await this . startLockdownWithoutCheckin ( service ) ;
7073 this . socket = this . connection . getSocket ( ) ;
71-
72- // Remove SSL context if present for raw DTX communication
73- if ( '_sslobj' in this . socket ) {
74- ( this . socket as any ) . _sslobj = null ;
75- }
74+ stripSSL ( this . socket ) ;
7675
7776 await this . performHandshake ( ) ;
7877 }
@@ -105,7 +104,7 @@ export class DVTSecureSocketProxyService extends BaseService {
105104 args . appendInt ( channelCode ) ;
106105 args . appendObj ( identifier ) ;
107106
108- await this . sendMessage ( 0 , '_requestChannelWithCode:identifier:' , args ) ;
107+ await this . sendMessage ( 0 , '_requestChannelWithCode:identifier:' , { args } ) ;
109108
110109 const [ ret ] = await this . recvPlist ( ) ;
111110
@@ -123,15 +122,14 @@ export class DVTSecureSocketProxyService extends BaseService {
123122 * Send a DTX message on a channel
124123 * @param channel The channel code
125124 * @param selector The ObjectiveC method selector
126- * @param args Optional message arguments
127- * @param expectsReply Whether a reply is expected
125+ * @param options Optional message options
128126 */
129127 async sendMessage (
130128 channel : number ,
131129 selector : string | null = null ,
132- args : MessageAux | null = null ,
133- expectsReply : boolean = true ,
130+ options : SendMessageOptions = { } ,
134131 ) : Promise < void > {
132+ const { args = null , expectsReply = true } = options ;
135133 if ( ! this . socket ) {
136134 throw new Error ( 'Not connected to DVT service' ) ;
137135 }
@@ -273,8 +271,7 @@ export class DVTSecureSocketProxyService extends BaseService {
273271 await this . sendMessage (
274272 DVTSecureSocketProxyService . BROADCAST_CHANNEL ,
275273 '_channelCanceled:' ,
276- args ,
277- false ,
274+ { args, expectsReply : false } ,
278275 ) ;
279276 } catch ( error ) {
280277 log . debug ( 'Error sending channel canceled message:' , error ) ;
@@ -302,7 +299,10 @@ export class DVTSecureSocketProxyService extends BaseService {
302299 'com.apple.private.DTXBlockCompression' : 0 ,
303300 'com.apple.private.DTXConnection' : 1 ,
304301 } ) ;
305- await this . sendMessage ( 0 , '_notifyOfPublishedCapabilities:' , args , false ) ;
302+ await this . sendMessage ( 0 , '_notifyOfPublishedCapabilities:' , {
303+ args,
304+ expectsReply : false ,
305+ } ) ;
306306
307307 const [ retData , aux ] = await this . recvMessage ( ) ;
308308 const ret = retData ? parseBinaryPlist ( retData ) : null ;
0 commit comments