Skip to content

Commit e6fbda3

Browse files
authored
fix(devtools-connect): give application code for custom OIDC HTTP options precedence (#321)
Instead of using the application callback first and then potentially transforming the result with options computed by devtools-connect, do the reverse. This gives the application using devtools-connect more flexibility about how exactly to modify OIDC HTTP options. The goal here is to enable usage of HTTP proxies in conjunction with `useSystemCA` and explicit `tlsCAFile` settings; devtools-connect correctly passes the former to the OIDC plugin, but after this change, the application can also pass it to the proxy agent, if it creates one. None of our team's applications currently make use of the function variant of this options, so this will not affect existing code in any way.
1 parent ba4ffe0 commit e6fbda3

File tree

3 files changed

+13
-15
lines changed

3 files changed

+13
-15
lines changed

package-lock.json

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/devtools-connect/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
"peerDependencies": {
5757
"@mongodb-js/oidc-plugin": "^0.4.0",
5858
"mongodb": "^5.8.1 || ^6.0.0",
59-
"mongodb-log-writer": "^1.2.0"
59+
"mongodb-log-writer": "^1.4.2"
6060
},
6161
"devDependencies": {
6262
"@mongodb-js/oidc-plugin": "^0.4.0",
@@ -76,7 +76,7 @@
7676
"gen-esm-wrapper": "^1.1.0",
7777
"mocha": "^8.4.0",
7878
"mongodb": "^5.8.1 || ^6.0.0",
79-
"mongodb-log-writer": "^1.2.0",
79+
"mongodb-log-writer": "^1.4.2",
8080
"nyc": "^15.1.0",
8181
"os-dns-native": "^1.2.0",
8282
"resolve-mongodb-srv": "^1.1.1",

packages/devtools-connect/src/connect.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -536,10 +536,8 @@ function addCAToOIDCPluginHttpOptions(
536536
const existingCustomOptions = existingOIDCPluginOptions?.customHttpOptions;
537537
if (typeof existingCustomOptions === 'function') {
538538
return {
539-
customHttpOptions: (...args) => ({
540-
...existingCustomOptions(...args),
541-
ca,
542-
}),
539+
customHttpOptions: (url, options, ...restArgs) =>
540+
existingCustomOptions(url, { ...options, ca }, ...restArgs),
543541
};
544542
}
545543
return { customHttpOptions: { ...existingCustomOptions, ca } };

0 commit comments

Comments
 (0)