@ai-sdk/provider-utils 3.0.45 → 3.0.46

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
+ ## 3.0.46
4
+
5
+ ### Patch Changes
6
+
7
+ - c31e0a2: 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
  ## 3.0.45
4
10
 
5
11
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -93,7 +93,7 @@ type FetchFunction = typeof globalThis.fetch;
93
93
  * Redirects are rejected by default. Callers using `redirect: 'manual'` must
94
94
  * validate the Location target before issuing another request.
95
95
  */
96
- declare function fetchWithValidatedEndpoint({ url, init, fetch: customFetch, trustedOrigin, redirect, }: {
96
+ declare function fetchWithValidatedEndpoint({ url, init, fetch: customFetch, trustedOrigin, redirect, requireDnsValidation, }: {
97
97
  url: string | URL;
98
98
  init?: RequestInit;
99
99
  fetch?: FetchFunction;
@@ -103,6 +103,11 @@ declare function fetchWithValidatedEndpoint({ url, init, fetch: customFetch, tru
103
103
  */
104
104
  trustedOrigin?: string;
105
105
  redirect?: 'error' | 'manual';
106
+ /**
107
+ * Reject untrusted URLs on server runtimes without a DNS-pinned default
108
+ * transport unless an explicit custom fetch provides equivalent validation.
109
+ */
110
+ requireDnsValidation?: boolean;
106
111
  }): Promise<Response>;
107
112
  /**
108
113
  * Fetches a URL while enforcing the SSRF download guard on every hop.
package/dist/index.d.ts CHANGED
@@ -93,7 +93,7 @@ type FetchFunction = typeof globalThis.fetch;
93
93
  * Redirects are rejected by default. Callers using `redirect: 'manual'` must
94
94
  * validate the Location target before issuing another request.
95
95
  */
96
- declare function fetchWithValidatedEndpoint({ url, init, fetch: customFetch, trustedOrigin, redirect, }: {
96
+ declare function fetchWithValidatedEndpoint({ url, init, fetch: customFetch, trustedOrigin, redirect, requireDnsValidation, }: {
97
97
  url: string | URL;
98
98
  init?: RequestInit;
99
99
  fetch?: FetchFunction;
@@ -103,6 +103,11 @@ declare function fetchWithValidatedEndpoint({ url, init, fetch: customFetch, tru
103
103
  */
104
104
  trustedOrigin?: string;
105
105
  redirect?: 'error' | 'manual';
106
+ /**
107
+ * Reject untrusted URLs on server runtimes without a DNS-pinned default
108
+ * transport unless an explicit custom fetch provides equivalent validation.
109
+ */
110
+ requireDnsValidation?: boolean;
106
111
  }): Promise<Response>;
107
112
  /**
108
113
  * Fetches a URL while enforcing the SSRF download guard on every hop.
package/dist/index.js CHANGED
@@ -543,12 +543,20 @@ async function fetchWithValidatedEndpoint({
543
543
  init,
544
544
  fetch: customFetch,
545
545
  trustedOrigin,
546
- redirect = "error"
546
+ redirect = "error",
547
+ requireDnsValidation = false
547
548
  }) {
548
549
  const urlText = url.toString();
549
550
  const isTrusted = trustedOrigin !== void 0 && isSameOrigin(urlText, trustedOrigin);
550
551
  if (!isTrusted) {
551
552
  validateDownloadUrl(urlText);
553
+ if (requireDnsValidation && (customFetch == null || customFetch === globalThis.fetch) && !isNodeRuntime() && // A window alias alone does not distinguish older Deno from a browser.
554
+ !(isBrowserRuntime() && typeof document !== "undefined")) {
555
+ throw new DownloadError({
556
+ url: urlText,
557
+ message: "This server runtime requires a custom fetch with connect-time DNS validation for untrusted URLs"
558
+ });
559
+ }
552
560
  }
553
561
  const fetch = isTrusted && customFetch != null ? customFetch : isTrusted ? globalThis.fetch : await getValidatedFetch(customFetch);
554
562
  return await fetch(url, {
@@ -861,7 +869,7 @@ function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
861
869
  }
862
870
 
863
871
  // src/version.ts
864
- var VERSION = true ? "3.0.45" : "0.0.0-test";
872
+ var VERSION = true ? "3.0.46" : "0.0.0-test";
865
873
 
866
874
  // src/get-from-api.ts
867
875
  var getOriginalFetch = () => globalThis.fetch;