@ai-sdk/provider-utils 4.0.64 → 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 +12 -0
- package/dist/index.d.mts +9 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.js +16 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +16 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/fetch-with-validated-redirects.ts +34 -1
package/dist/index.mjs
CHANGED
|
@@ -580,12 +580,20 @@ async function fetchWithValidatedEndpoint({
|
|
|
580
580
|
init,
|
|
581
581
|
fetch: customFetch,
|
|
582
582
|
trustedOrigin,
|
|
583
|
-
redirect = "error"
|
|
583
|
+
redirect = "error",
|
|
584
|
+
requireDnsValidation = false
|
|
584
585
|
}) {
|
|
585
586
|
const urlText = url.toString();
|
|
586
587
|
const isTrusted = trustedOrigin !== void 0 && isSameOrigin(urlText, trustedOrigin);
|
|
587
588
|
if (!isTrusted) {
|
|
588
589
|
validateDownloadUrl(urlText);
|
|
590
|
+
if (requireDnsValidation && (customFetch == null || customFetch === globalThis.fetch) && !isNodeRuntime() && // A window alias alone does not distinguish older Deno from a browser.
|
|
591
|
+
!(isBrowserRuntime() && typeof document !== "undefined")) {
|
|
592
|
+
throw new DownloadError({
|
|
593
|
+
url: urlText,
|
|
594
|
+
message: "This server runtime requires a custom fetch with connect-time DNS validation for untrusted URLs"
|
|
595
|
+
});
|
|
596
|
+
}
|
|
589
597
|
}
|
|
590
598
|
const fetch = isTrusted && customFetch != null ? customFetch : isTrusted ? globalThis.fetch : await getValidatedFetch(customFetch);
|
|
591
599
|
return await fetch(url, {
|
|
@@ -631,6 +639,12 @@ async function fetchWithValidatedRedirects({
|
|
|
631
639
|
if (REDIRECT_STATUS_CODES.has(response.status) && location) {
|
|
632
640
|
void cancelResponseBody(response);
|
|
633
641
|
const nextUrl = new URL(location, currentUrl).toString();
|
|
642
|
+
if (new URL(currentUrl).protocol === "https:" && new URL(nextUrl).protocol === "http:") {
|
|
643
|
+
throw new DownloadError({
|
|
644
|
+
url,
|
|
645
|
+
message: "Redirect from HTTPS to HTTP was blocked"
|
|
646
|
+
});
|
|
647
|
+
}
|
|
634
648
|
if (currentHeaders !== void 0 && !isSameOrigin(nextUrl, currentUrl)) {
|
|
635
649
|
const userAgent = currentHeaders.get("user-agent");
|
|
636
650
|
currentHeaders = new Headers(
|
|
@@ -933,7 +947,7 @@ function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
|
|
|
933
947
|
}
|
|
934
948
|
|
|
935
949
|
// src/version.ts
|
|
936
|
-
var VERSION = true ? "4.0.
|
|
950
|
+
var VERSION = true ? "4.0.66" : "0.0.0-test";
|
|
937
951
|
|
|
938
952
|
// src/get-from-api.ts
|
|
939
953
|
var getOriginalFetch = () => globalThis.fetch;
|