@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/provider-utils",
3
- "version": "4.0.64",
3
+ "version": "4.0.65",
4
4
  "license": "Apache-2.0",
5
5
  "sideEffects": false,
6
6
  "main": "./dist/index.js",
@@ -80,6 +80,9 @@ export async function fetchWithValidatedEndpoint({
80
80
  * target (e.g. an internal address) before we ever see its URL, defeating the
81
81
  * guard.
82
82
  *
83
+ * Manually followed redirects from HTTPS to HTTP are rejected before requesting
84
+ * the target.
85
+ *
83
86
  * Request headers are also protected: {@link sanitizeRequestHeaders} strips
84
87
  * proxy/metadata/cookie/hop-by-hop headers before the first request, and all
85
88
  * caller headers except `User-Agent` are dropped on a cross-origin redirect.
@@ -192,6 +195,16 @@ export async function fetchWithValidatedRedirects({
192
195
  void cancelResponseBody(response);
193
196
  const nextUrl = new URL(location, currentUrl).toString();
194
197
 
198
+ if (
199
+ new URL(currentUrl).protocol === 'https:' &&
200
+ new URL(nextUrl).protocol === 'http:'
201
+ ) {
202
+ throw new DownloadError({
203
+ url,
204
+ message: 'Redirect from HTTPS to HTTP was blocked',
205
+ });
206
+ }
207
+
195
208
  // Drop all caller headers except the user-agent before following a
196
209
  // redirect that crosses origin. Only stripping Authorization (as the
197
210
  // fetch spec does) is not enough on the server: providers authenticate