@ai-sdk/anthropic 4.0.12 → 4.0.15
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 +35 -0
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/dist/internal/index.js +1 -0
- package/dist/internal/index.js.map +1 -1
- package/package.json +2 -2
- package/src/anthropic-provider.ts +4 -1
- package/src/skills/anthropic-skills.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,40 @@
|
|
|
1
1
|
# @ai-sdk/anthropic
|
|
2
2
|
|
|
3
|
+
## 4.0.15
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [31c7be8]
|
|
8
|
+
- @ai-sdk/provider-utils@5.0.10
|
|
9
|
+
|
|
10
|
+
## 4.0.14
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- 4be62c1: fix(provider-utils): validate provider-response URLs in `getFromApi`
|
|
15
|
+
|
|
16
|
+
`getFromApi` now has a `validateUrl` flag. It is optional so existing callers keep compiling (omitting it behaves like `false`, i.e. no validation), but all AI SDK provider packages set it explicitly at every call site so each one makes a visible trust decision. When `true`, the URL is routed through `fetchWithValidatedRedirects` — the same guard used by `downloadBlob` — which rejects private/loopback/link-local targets, re-validates every redirect hop, strips proxy/metadata/cookie request headers, and drops all caller headers except the user-agent on cross-origin redirects (custom API-key headers must not follow a redirect off-origin any more than `Authorization` may); blocked URLs throw `DownloadError`. It is enabled at the image/video/audio download and polling call sites where the URL comes from a provider response body; URLs built from developer-configured endpoints pass `validateUrl: false` and are unaffected.
|
|
17
|
+
|
|
18
|
+
A new optional `credentialedOrigin` withholds caller headers unless the URL is same-origin with it, so the API key is not sent to a response-supplied host on a different origin.
|
|
19
|
+
|
|
20
|
+
A new optional `trustedOrigin` exempts URLs (and redirect hops) that are same-origin with the developer-configured provider endpoint from target validation, so self-hosted and localhost deployments whose response URLs point back at the configured host keep working; all other hops are still validated.
|
|
21
|
+
|
|
22
|
+
Also closes range gaps in `validateDownloadUrl` (IPv4 `224.0.0.0/4` multicast and the TEST-NET documentation ranges `192.0.2.0/24`, `198.51.100.0/24`, `203.0.113.0/24`; IPv6 documentation ranges `2001:db8::/32` and `3fff::/20`), and follows only the fetch-spec redirect status codes (301/302/303/307/308) — a `Location` header on any other status is not followed. This guard performs string/literal checks only and does not resolve DNS; hostnames that resolve to private addresses and DNS rebinding remain out of scope and must be constrained at the network layer (or by injecting a Node `fetch` that pins the resolved IP at connect time) for server deployments handling untrusted URLs. See `contributing/secure-url-handling.md`.
|
|
23
|
+
|
|
24
|
+
- cd12954: Reject empty OpenAI, Anthropic, and Replicate base URLs with a helpful AI SDK
|
|
25
|
+
invalid argument error.
|
|
26
|
+
- Updated dependencies [4be62c1]
|
|
27
|
+
- Updated dependencies [7805e4a]
|
|
28
|
+
- Updated dependencies [cd12954]
|
|
29
|
+
- @ai-sdk/provider-utils@5.0.9
|
|
30
|
+
|
|
31
|
+
## 4.0.13
|
|
32
|
+
|
|
33
|
+
### Patch Changes
|
|
34
|
+
|
|
35
|
+
- Updated dependencies [e193290]
|
|
36
|
+
- @ai-sdk/provider-utils@5.0.8
|
|
37
|
+
|
|
3
38
|
## 4.0.12
|
|
4
39
|
|
|
5
40
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
generateId as generateId2,
|
|
8
8
|
loadApiKey,
|
|
9
9
|
loadOptionalSetting,
|
|
10
|
+
validateBaseURL,
|
|
10
11
|
withoutTrailingSlash,
|
|
11
12
|
withUserAgentSuffix
|
|
12
13
|
} from "@ai-sdk/provider-utils";
|
|
@@ -6235,6 +6236,7 @@ var AnthropicSkills = class {
|
|
|
6235
6236
|
}) {
|
|
6236
6237
|
const { value: versionResponse } = await getFromApi({
|
|
6237
6238
|
url: `${this.config.baseURL}/skills/${skillId}/versions/${version}`,
|
|
6239
|
+
validateUrl: false,
|
|
6238
6240
|
headers,
|
|
6239
6241
|
failedResponseHandler: anthropicFailedResponseHandler,
|
|
6240
6242
|
successfulResponseHandler: createJsonResponseHandler3(
|
|
@@ -6295,13 +6297,15 @@ var AnthropicSkills = class {
|
|
|
6295
6297
|
};
|
|
6296
6298
|
|
|
6297
6299
|
// src/version.ts
|
|
6298
|
-
var VERSION = true ? "4.0.
|
|
6300
|
+
var VERSION = true ? "4.0.15" : "0.0.0-test";
|
|
6299
6301
|
|
|
6300
6302
|
// src/anthropic-provider.ts
|
|
6301
6303
|
var ANTHROPIC_API_URL = "https://api.anthropic.com";
|
|
6302
6304
|
var ANTHROPIC_API_VERSIONED_URL = `${ANTHROPIC_API_URL}/v1`;
|
|
6303
6305
|
function normalizeBaseURL(baseURL) {
|
|
6304
|
-
const baseURLWithoutTrailingSlash = withoutTrailingSlash(
|
|
6306
|
+
const baseURLWithoutTrailingSlash = withoutTrailingSlash(
|
|
6307
|
+
validateBaseURL(baseURL)
|
|
6308
|
+
);
|
|
6305
6309
|
return baseURLWithoutTrailingSlash === ANTHROPIC_API_URL ? ANTHROPIC_API_VERSIONED_URL : baseURLWithoutTrailingSlash;
|
|
6306
6310
|
}
|
|
6307
6311
|
function createAnthropic(options = {}) {
|