@ai-sdk/provider-utils 4.0.65 → 4.0.66

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @ai-sdk/provider-utils
2
2
 
3
+ ## 4.0.66
4
+
5
+ ### Patch Changes
6
+
7
+ - 88bb257: Require a DNS-pinned fetch for untrusted MCP OAuth discovery and metadata-derived token/registration URLs on server runtimes without a protected default transport. Preserve developer-configured endpoints and allow explicitly supplied fetch implementations that provide equivalent connect-time validation. Browser workers without a DOM follow the same explicit custom-fetch requirement.
8
+
3
9
  ## 4.0.65
4
10
 
5
11
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -238,7 +238,7 @@ type FetchFunction = typeof globalThis.fetch;
238
238
  * Redirects are rejected by default. Callers using `redirect: 'manual'` must
239
239
  * validate the Location target before issuing another request.
240
240
  */
241
- declare function fetchWithValidatedEndpoint({ url, init, fetch: customFetch, trustedOrigin, redirect, }: {
241
+ declare function fetchWithValidatedEndpoint({ url, init, fetch: customFetch, trustedOrigin, redirect, requireDnsValidation, }: {
242
242
  url: string | URL;
243
243
  init?: RequestInit;
244
244
  fetch?: FetchFunction;
@@ -248,6 +248,11 @@ declare function fetchWithValidatedEndpoint({ url, init, fetch: customFetch, tru
248
248
  */
249
249
  trustedOrigin?: string;
250
250
  redirect?: 'error' | 'manual';
251
+ /**
252
+ * Reject untrusted URLs on server runtimes without a DNS-pinned default
253
+ * transport unless an explicit custom fetch provides equivalent validation.
254
+ */
255
+ requireDnsValidation?: boolean;
251
256
  }): Promise<Response>;
252
257
  /**
253
258
  * Fetches a URL while enforcing the download guard on every hop.
package/dist/index.d.ts CHANGED
@@ -238,7 +238,7 @@ type FetchFunction = typeof globalThis.fetch;
238
238
  * Redirects are rejected by default. Callers using `redirect: 'manual'` must
239
239
  * validate the Location target before issuing another request.
240
240
  */
241
- declare function fetchWithValidatedEndpoint({ url, init, fetch: customFetch, trustedOrigin, redirect, }: {
241
+ declare function fetchWithValidatedEndpoint({ url, init, fetch: customFetch, trustedOrigin, redirect, requireDnsValidation, }: {
242
242
  url: string | URL;
243
243
  init?: RequestInit;
244
244
  fetch?: FetchFunction;
@@ -248,6 +248,11 @@ declare function fetchWithValidatedEndpoint({ url, init, fetch: customFetch, tru
248
248
  */
249
249
  trustedOrigin?: string;
250
250
  redirect?: 'error' | 'manual';
251
+ /**
252
+ * Reject untrusted URLs on server runtimes without a DNS-pinned default
253
+ * transport unless an explicit custom fetch provides equivalent validation.
254
+ */
255
+ requireDnsValidation?: boolean;
251
256
  }): Promise<Response>;
252
257
  /**
253
258
  * Fetches a URL while enforcing the download guard on every hop.
package/dist/index.js CHANGED
@@ -690,12 +690,20 @@ async function fetchWithValidatedEndpoint({
690
690
  init,
691
691
  fetch: customFetch,
692
692
  trustedOrigin,
693
- redirect = "error"
693
+ redirect = "error",
694
+ requireDnsValidation = false
694
695
  }) {
695
696
  const urlText = url.toString();
696
697
  const isTrusted = trustedOrigin !== void 0 && isSameOrigin(urlText, trustedOrigin);
697
698
  if (!isTrusted) {
698
699
  validateDownloadUrl(urlText);
700
+ if (requireDnsValidation && (customFetch == null || customFetch === globalThis.fetch) && !isNodeRuntime() && // A window alias alone does not distinguish older Deno from a browser.
701
+ !(isBrowserRuntime() && typeof document !== "undefined")) {
702
+ throw new DownloadError({
703
+ url: urlText,
704
+ message: "This server runtime requires a custom fetch with connect-time DNS validation for untrusted URLs"
705
+ });
706
+ }
699
707
  }
700
708
  const fetch = isTrusted && customFetch != null ? customFetch : isTrusted ? globalThis.fetch : await getValidatedFetch(customFetch);
701
709
  return await fetch(url, {
@@ -1049,7 +1057,7 @@ function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
1049
1057
  }
1050
1058
 
1051
1059
  // src/version.ts
1052
- var VERSION = true ? "4.0.65" : "0.0.0-test";
1060
+ var VERSION = true ? "4.0.66" : "0.0.0-test";
1053
1061
 
1054
1062
  // src/get-from-api.ts
1055
1063
  var getOriginalFetch = () => globalThis.fetch;