@ai-sdk/provider-utils 4.0.64 → 4.0.65

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.65
4
+
5
+ ### Patch Changes
6
+
7
+ - f0dee4b: Reject HTTPS-to-HTTP redirects in validated downloads before requesting the insecure target, including when it matches a configured trusted origin.
8
+
3
9
  ## 4.0.64
4
10
 
5
11
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -258,6 +258,9 @@ declare function fetchWithValidatedEndpoint({ url, init, fetch: customFetch, tru
258
258
  * target (e.g. an internal address) before we ever see its URL, defeating the
259
259
  * guard.
260
260
  *
261
+ * Manually followed redirects from HTTPS to HTTP are rejected before requesting
262
+ * the target.
263
+ *
261
264
  * Request headers are also protected: {@link sanitizeRequestHeaders} strips
262
265
  * proxy/metadata/cookie/hop-by-hop headers before the first request, and all
263
266
  * caller headers except `User-Agent` are dropped on a cross-origin redirect.
package/dist/index.d.ts CHANGED
@@ -258,6 +258,9 @@ declare function fetchWithValidatedEndpoint({ url, init, fetch: customFetch, tru
258
258
  * target (e.g. an internal address) before we ever see its URL, defeating the
259
259
  * guard.
260
260
  *
261
+ * Manually followed redirects from HTTPS to HTTP are rejected before requesting
262
+ * the target.
263
+ *
261
264
  * Request headers are also protected: {@link sanitizeRequestHeaders} strips
262
265
  * proxy/metadata/cookie/hop-by-hop headers before the first request, and all
263
266
  * caller headers except `User-Agent` are dropped on a cross-origin redirect.
package/dist/index.js CHANGED
@@ -741,6 +741,12 @@ async function fetchWithValidatedRedirects({
741
741
  if (REDIRECT_STATUS_CODES.has(response.status) && location) {
742
742
  void cancelResponseBody(response);
743
743
  const nextUrl = new URL(location, currentUrl).toString();
744
+ if (new URL(currentUrl).protocol === "https:" && new URL(nextUrl).protocol === "http:") {
745
+ throw new DownloadError({
746
+ url,
747
+ message: "Redirect from HTTPS to HTTP was blocked"
748
+ });
749
+ }
744
750
  if (currentHeaders !== void 0 && !isSameOrigin(nextUrl, currentUrl)) {
745
751
  const userAgent = currentHeaders.get("user-agent");
746
752
  currentHeaders = new Headers(
@@ -1043,7 +1049,7 @@ function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
1043
1049
  }
1044
1050
 
1045
1051
  // src/version.ts
1046
- var VERSION = true ? "4.0.64" : "0.0.0-test";
1052
+ var VERSION = true ? "4.0.65" : "0.0.0-test";
1047
1053
 
1048
1054
  // src/get-from-api.ts
1049
1055
  var getOriginalFetch = () => globalThis.fetch;