@@ -26,6 +26,10 @@ export interface WebRTCDirectListenerOptions extends ListenerOptions{
26
26
channelOptions ?: Object
27
27
}
28
28
29
+ export interface WebRTCDirectDialOptions extends AbortOptions {
30
+ channelOptions ?: Object
31
+ }
32
+
29
33
export class WebRTCDirect implements Transport < AbortOptions , ListenerOptions > {
30
34
private readonly _upgrader : Upgrader
31
35
@@ -39,7 +43,7 @@ export class WebRTCDirect implements Transport<AbortOptions, ListenerOptions> {
39
43
this . _upgrader = upgrader
40
44
}
41
45
42
- async dial ( ma : Multiaddr , options : AbortOptions = { } ) {
46
+ async dial ( ma : Multiaddr , options : WebRTCDirectDialOptions = { } ) {
43
47
const socket = await this . _connect ( ma , options )
44
48
const maConn = toMultiaddrConnection ( socket , { remoteAddr : ma , signal : options . signal } )
45
49
log ( 'new outbound connection %s' , maConn . remoteAddr )
@@ -48,16 +52,16 @@ export class WebRTCDirect implements Transport<AbortOptions, ListenerOptions> {
48
52
return conn
49
53
}
50
54
51
- async _connect ( ma : Multiaddr , options :any = { } ) {
55
+ async _connect ( ma : Multiaddr , options :WebRTCDirectDialOptions = { } ) {
52
56
if ( options . signal && options . signal . aborted ) {
53
57
throw new AbortError ( )
54
58
}
55
59
56
- options = {
60
+ const channelOptions = {
57
61
initiator : true ,
58
62
trickle : false ,
59
63
wrtc : isNode ? wrtc : undefined ,
60
- ...options
64
+ ...options ?. channelOptions
61
65
}
62
66
63
67
return new Promise ( ( resolve , reject ) => {
@@ -67,7 +71,7 @@ export class WebRTCDirect implements Transport<AbortOptions, ListenerOptions> {
67
71
const cOpts = ma . toOptions ( )
68
72
log ( 'Dialing %s:%s' , cOpts . host , cOpts . port )
69
73
70
- const channel = new SimplePeer ( options )
74
+ const channel = new SimplePeer ( channelOptions )
71
75
72
76
const onError = ( err : Error ) => {
73
77
if ( ! connected ) {
0 commit comments