Skip to content

Commit

Permalink
fix(devtools-connect): give application code for custom OIDC HTTP opt…
Browse files Browse the repository at this point in the history
…ions 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.
  • Loading branch information
addaleax authored May 15, 2024
1 parent ba4ffe0 commit e6fbda3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/devtools-connect/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"peerDependencies": {
"@mongodb-js/oidc-plugin": "^0.4.0",
"mongodb": "^5.8.1 || ^6.0.0",
"mongodb-log-writer": "^1.2.0"
"mongodb-log-writer": "^1.4.2"
},
"devDependencies": {
"@mongodb-js/oidc-plugin": "^0.4.0",
Expand All @@ -76,7 +76,7 @@
"gen-esm-wrapper": "^1.1.0",
"mocha": "^8.4.0",
"mongodb": "^5.8.1 || ^6.0.0",
"mongodb-log-writer": "^1.2.0",
"mongodb-log-writer": "^1.4.2",
"nyc": "^15.1.0",
"os-dns-native": "^1.2.0",
"resolve-mongodb-srv": "^1.1.1",
Expand Down
6 changes: 2 additions & 4 deletions packages/devtools-connect/src/connect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -536,10 +536,8 @@ function addCAToOIDCPluginHttpOptions(
const existingCustomOptions = existingOIDCPluginOptions?.customHttpOptions;
if (typeof existingCustomOptions === 'function') {
return {
customHttpOptions: (...args) => ({
...existingCustomOptions(...args),
ca,
}),
customHttpOptions: (url, options, ...restArgs) =>
existingCustomOptions(url, { ...options, ca }, ...restArgs),
};
}
return { customHttpOptions: { ...existingCustomOptions, ca } };
Expand Down

0 comments on commit e6fbda3

Please sign in to comment.