@ai-sdk/provider-utils 4.0.65 → 4.0.67
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 +6 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +11 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +11 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/fetch-with-validated-redirects.ts +21 -1
- package/src/schema.ts +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @ai-sdk/provider-utils
|
|
2
2
|
|
|
3
|
+
## 4.0.67
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- d59eee0: Fix validation of non-Zod Standard Schema results: a result that contains `issues` is now always treated as a failure, even when it also carries a `value`. Previously a failing schema such as Valibot's through `toStandardJsonSchema()` could be reported as valid, so rejected input, including tool input, was accepted.
|
|
8
|
+
|
|
9
|
+
## 4.0.66
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 88bb257: 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.
|
|
14
|
+
|
|
3
15
|
## 4.0.65
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -238,7 +238,7 @@ type FetchFunction = typeof globalThis.fetch;
|
|
|
238
238
|
* Redirects are rejected by default. Callers using `redirect: 'manual'` must
|
|
239
239
|
* validate the Location target before issuing another request.
|
|
240
240
|
*/
|
|
241
|
-
declare function fetchWithValidatedEndpoint({ url, init, fetch: customFetch, trustedOrigin, redirect, }: {
|
|
241
|
+
declare function fetchWithValidatedEndpoint({ url, init, fetch: customFetch, trustedOrigin, redirect, requireDnsValidation, }: {
|
|
242
242
|
url: string | URL;
|
|
243
243
|
init?: RequestInit;
|
|
244
244
|
fetch?: FetchFunction;
|
|
@@ -248,6 +248,11 @@ declare function fetchWithValidatedEndpoint({ url, init, fetch: customFetch, tru
|
|
|
248
248
|
*/
|
|
249
249
|
trustedOrigin?: string;
|
|
250
250
|
redirect?: 'error' | 'manual';
|
|
251
|
+
/**
|
|
252
|
+
* Reject untrusted URLs on server runtimes without a DNS-pinned default
|
|
253
|
+
* transport unless an explicit custom fetch provides equivalent validation.
|
|
254
|
+
*/
|
|
255
|
+
requireDnsValidation?: boolean;
|
|
251
256
|
}): Promise<Response>;
|
|
252
257
|
/**
|
|
253
258
|
* Fetches a URL while enforcing the download guard on every hop.
|
package/dist/index.d.ts
CHANGED
|
@@ -238,7 +238,7 @@ type FetchFunction = typeof globalThis.fetch;
|
|
|
238
238
|
* Redirects are rejected by default. Callers using `redirect: 'manual'` must
|
|
239
239
|
* validate the Location target before issuing another request.
|
|
240
240
|
*/
|
|
241
|
-
declare function fetchWithValidatedEndpoint({ url, init, fetch: customFetch, trustedOrigin, redirect, }: {
|
|
241
|
+
declare function fetchWithValidatedEndpoint({ url, init, fetch: customFetch, trustedOrigin, redirect, requireDnsValidation, }: {
|
|
242
242
|
url: string | URL;
|
|
243
243
|
init?: RequestInit;
|
|
244
244
|
fetch?: FetchFunction;
|
|
@@ -248,6 +248,11 @@ declare function fetchWithValidatedEndpoint({ url, init, fetch: customFetch, tru
|
|
|
248
248
|
*/
|
|
249
249
|
trustedOrigin?: string;
|
|
250
250
|
redirect?: 'error' | 'manual';
|
|
251
|
+
/**
|
|
252
|
+
* Reject untrusted URLs on server runtimes without a DNS-pinned default
|
|
253
|
+
* transport unless an explicit custom fetch provides equivalent validation.
|
|
254
|
+
*/
|
|
255
|
+
requireDnsValidation?: boolean;
|
|
251
256
|
}): Promise<Response>;
|
|
252
257
|
/**
|
|
253
258
|
* Fetches a URL while enforcing the download guard on every hop.
|
package/dist/index.js
CHANGED
|
@@ -690,12 +690,20 @@ async function fetchWithValidatedEndpoint({
|
|
|
690
690
|
init,
|
|
691
691
|
fetch: customFetch,
|
|
692
692
|
trustedOrigin,
|
|
693
|
-
redirect = "error"
|
|
693
|
+
redirect = "error",
|
|
694
|
+
requireDnsValidation = false
|
|
694
695
|
}) {
|
|
695
696
|
const urlText = url.toString();
|
|
696
697
|
const isTrusted = trustedOrigin !== void 0 && isSameOrigin(urlText, trustedOrigin);
|
|
697
698
|
if (!isTrusted) {
|
|
698
699
|
validateDownloadUrl(urlText);
|
|
700
|
+
if (requireDnsValidation && (customFetch == null || customFetch === globalThis.fetch) && !isNodeRuntime() && // A window alias alone does not distinguish older Deno from a browser.
|
|
701
|
+
!(isBrowserRuntime() && typeof document !== "undefined")) {
|
|
702
|
+
throw new DownloadError({
|
|
703
|
+
url: urlText,
|
|
704
|
+
message: "This server runtime requires a custom fetch with connect-time DNS validation for untrusted URLs"
|
|
705
|
+
});
|
|
706
|
+
}
|
|
699
707
|
}
|
|
700
708
|
const fetch = isTrusted && customFetch != null ? customFetch : isTrusted ? globalThis.fetch : await getValidatedFetch(customFetch);
|
|
701
709
|
return await fetch(url, {
|
|
@@ -1049,7 +1057,7 @@ function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
|
|
|
1049
1057
|
}
|
|
1050
1058
|
|
|
1051
1059
|
// src/version.ts
|
|
1052
|
-
var VERSION = true ? "4.0.
|
|
1060
|
+
var VERSION = true ? "4.0.67" : "0.0.0-test";
|
|
1053
1061
|
|
|
1054
1062
|
// src/get-from-api.ts
|
|
1055
1063
|
var getOriginalFetch = () => globalThis.fetch;
|
|
@@ -2621,7 +2629,7 @@ function standardSchema(standardSchema2) {
|
|
|
2621
2629
|
{
|
|
2622
2630
|
validate: async (value) => {
|
|
2623
2631
|
const result = await standardSchema2["~standard"].validate(value);
|
|
2624
|
-
return "value" in result ? { success: true, value: result.value } : {
|
|
2632
|
+
return result.issues === void 0 && "value" in result ? { success: true, value: result.value } : {
|
|
2625
2633
|
success: false,
|
|
2626
2634
|
error: new import_provider7.TypeValidationError({
|
|
2627
2635
|
value,
|