@@ -10,18 +10,17 @@ import {
10
10
hookLogger as hookProxyLogger ,
11
11
createAgent ,
12
12
} from '@mongodb-js/devtools-proxy-support' ;
13
- import type { Tunnel } from '@mongodb-js/devtools-proxy-support' ;
13
+ import type {
14
+ DevtoolsProxyOptions ,
15
+ Tunnel ,
16
+ } from '@mongodb-js/devtools-proxy-support' ;
14
17
import EventEmitter from 'events' ;
15
18
import ConnectionString from 'mongodb-connection-string-url' ;
16
19
import _ from 'lodash' ;
17
20
18
21
import { redactConnectionOptions , redactConnectionString } from './redact' ;
19
22
import type { ConnectionOptions } from './connection-options' ;
20
- import {
21
- getCurrentApplicationProxyOptions ,
22
- getTunnelOptions ,
23
- waitForTunnelError ,
24
- } from './ssh-tunnel-helpers' ;
23
+ import { getTunnelOptions , waitForTunnelError } from './ssh-tunnel-helpers' ;
25
24
import { runCommand } from './run-command' ;
26
25
import type { UnboundDataServiceImplLogger } from './logger' ;
27
26
import { debug as _debug } from './logger' ;
@@ -65,11 +64,17 @@ function matchingAllowedHosts(
65
64
return [ ...new Set ( suffixes ) ] ;
66
65
}
67
66
68
- export function prepareOIDCOptions (
69
- connectionOptions : Readonly < ConnectionOptions > ,
70
- signal ?: AbortSignal ,
71
- reauthenticationHandler ?: ReauthenticationHandler
72
- ) : Required <
67
+ export function prepareOIDCOptions ( {
68
+ connectionOptions,
69
+ proxyOptions = { } ,
70
+ signal,
71
+ reauthenticationHandler,
72
+ } : {
73
+ connectionOptions : Readonly < ConnectionOptions > ;
74
+ proxyOptions ?: DevtoolsProxyOptions ;
75
+ signal ?: AbortSignal ;
76
+ reauthenticationHandler ?: ReauthenticationHandler ;
77
+ } ) : Required <
73
78
Pick <
74
79
DevtoolsConnectOptions ,
75
80
'oidc' | 'authMechanismProperties' | 'applyProxyToOIDC'
@@ -108,7 +113,7 @@ export function prepareOIDCOptions(
108
113
options . applyProxyToOIDC = true ;
109
114
} else {
110
115
options . oidc . customHttpOptions = {
111
- agent : createAgent ( getCurrentApplicationProxyOptions ( ) ) ,
116
+ agent : createAgent ( proxyOptions ) ,
112
117
} ;
113
118
}
114
119
@@ -119,6 +124,7 @@ export function prepareOIDCOptions(
119
124
120
125
export async function connectMongoClientDataService ( {
121
126
connectionOptions,
127
+ proxyOptions = { } ,
122
128
setupListeners,
123
129
signal,
124
130
logger,
@@ -127,6 +133,7 @@ export async function connectMongoClientDataService({
127
133
reauthenticationHandler,
128
134
} : {
129
135
connectionOptions : Readonly < ConnectionOptions > ;
136
+ proxyOptions ?: Readonly < DevtoolsProxyOptions > ;
130
137
setupListeners : ( client : MongoClient ) => void ;
131
138
signal ?: AbortSignal ;
132
139
logger ?: UnboundDataServiceImplLogger ;
@@ -147,11 +154,12 @@ export async function connectMongoClientDataService({
147
154
redactConnectionOptions ( connectionOptions )
148
155
) ;
149
156
150
- const oidcOptions = prepareOIDCOptions (
157
+ const oidcOptions = prepareOIDCOptions ( {
151
158
connectionOptions,
159
+ proxyOptions,
152
160
signal,
153
- reauthenticationHandler
154
- ) ;
161
+ reauthenticationHandler,
162
+ } ) ;
155
163
156
164
const url = connectionOptions . connectionString ;
157
165
const options : DevtoolsConnectOptions = {
@@ -189,7 +197,7 @@ export async function connectMongoClientDataService({
189
197
// If connectionOptions.sshTunnel is not defined, the tunnel
190
198
// will also be undefined.
191
199
const tunnel = createSocks5Tunnel (
192
- getTunnelOptions ( connectionOptions ) ,
200
+ getTunnelOptions ( connectionOptions , proxyOptions ) ,
193
201
'generate-credentials' ,
194
202
'mongodb://'
195
203
) ;
0 commit comments