feat: expose fetch option on ManagementClient#1352
Open
tsushanth wants to merge 1 commit into
Open
Conversation
Closes auth0#1330. The internal fetcher layer added `BaseClientOptions.fetch?: typeof fetch` in auth0#1238 and routes it through `fetcherImpl(args.fetchFn ?? …)`. The public wrapper, however, both omitted `fetch` from `ManagementClientOptions` and explicitly deleted it from the incoming options bag, so library consumers had no supported way to provide their own HTTP transport — even though the SDK is already capable of using one. - Drop `"fetch"` from the `Omit<FernClient.Options, …>` list so the field is part of the public surface. - Stop deleting `_options.fetch` in the `ManagementClient` constructor. The internal `fetcher` is still stripped (it's a Fern implementation detail), with a comment explaining why. Adds a focused test in `tests/management/ManagementClient.test.ts` that constructs a `ManagementClient` with a custom `fetch`, fires a request, and asserts the custom implementation was invoked against the expected URL. Also covers the no-`fetch` happy path to make sure the default global-fetch route is unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Closes #1330.
The internal fetcher layer added `BaseClientOptions.fetch?: typeof fetch` in #1238 and routes it through `fetcherImpl(args.fetchFn ?? …)`. The public wrapper, however, both omitted `fetch` from `ManagementClientOptions` and explicitly deleted it from the incoming options bag, so library consumers had no supported way to provide their own HTTP transport — even though the SDK is already capable of using one. Typical use cases the reporter and downstream Auth0 users have called out: proxies / corporate egress, retry middlewares, OpenTelemetry instrumentation, and Cloudflare Workers / Bun targets where the global `fetch` needs swapping.
What
Tests
`tests/management/ManagementClient.test.ts` — two cases:
`npx jest tests/management/ManagementClient.test.ts` — both pass. `npx tsc --noEmit` clean. `eslint` clean.
Compat
Source-compatible: existing call sites that didn't pass `fetch` see no behavioural difference. Callers can now opt in:
```ts
new ManagementClient({
domain: 'tenant.auth0.com',
token: '...',
fetch: myInstrumentedFetch,
});
```