ai 6.0.202 → 6.0.203

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.
@@ -2,7 +2,7 @@ import {
2
2
  DownloadError,
3
3
  readResponseWithSizeLimit,
4
4
  DEFAULT_MAX_DOWNLOAD_SIZE,
5
- validateDownloadUrl,
5
+ fetchWithValidatedRedirects,
6
6
  withUserAgentSuffix,
7
7
  getRuntimeEnvironmentUserAgent,
8
8
  } from '@ai-sdk/provider-utils';
@@ -28,21 +28,18 @@ export const download = async ({
28
28
  abortSignal?: AbortSignal;
29
29
  }) => {
30
30
  const urlText = url.toString();
31
- validateDownloadUrl(urlText);
32
31
  try {
33
- const response = await fetch(urlText, {
34
- headers: withUserAgentSuffix(
35
- {},
36
- `ai-sdk/${VERSION}`,
37
- getRuntimeEnvironmentUserAgent(),
38
- ),
39
- signal: abortSignal,
40
- });
32
+ const headers = withUserAgentSuffix(
33
+ {},
34
+ `ai-sdk/${VERSION}`,
35
+ getRuntimeEnvironmentUserAgent(),
36
+ );
41
37
 
42
- // Validate final URL after redirects to prevent SSRF via open redirect
43
- if (response.redirected) {
44
- validateDownloadUrl(response.url);
45
- }
38
+ const response = await fetchWithValidatedRedirects({
39
+ url: urlText,
40
+ headers,
41
+ abortSignal,
42
+ });
46
43
 
47
44
  if (!response.ok) {
48
45
  throw new DownloadError({