@ai-sdk/google 4.0.12 → 4.0.14
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 +26 -0
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/internal/index.js +2 -0
- package/dist/internal/index.js.map +1 -1
- package/package.json +2 -2
- package/src/google-files.ts +1 -0
- package/src/google-video-model.ts +1 -0
- package/src/interactions/poll-google-interactions.ts +1 -0
- package/src/interactions/stream-google-interactions.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# @ai-sdk/google
|
|
2
2
|
|
|
3
|
+
## 4.0.14
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 4be62c1: fix(provider-utils): validate provider-response URLs in `getFromApi`
|
|
8
|
+
|
|
9
|
+
`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.
|
|
10
|
+
|
|
11
|
+
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.
|
|
12
|
+
|
|
13
|
+
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.
|
|
14
|
+
|
|
15
|
+
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`.
|
|
16
|
+
|
|
17
|
+
- Updated dependencies [4be62c1]
|
|
18
|
+
- Updated dependencies [7805e4a]
|
|
19
|
+
- Updated dependencies [cd12954]
|
|
20
|
+
- @ai-sdk/provider-utils@5.0.9
|
|
21
|
+
|
|
22
|
+
## 4.0.13
|
|
23
|
+
|
|
24
|
+
### Patch Changes
|
|
25
|
+
|
|
26
|
+
- Updated dependencies [e193290]
|
|
27
|
+
- @ai-sdk/provider-utils@5.0.8
|
|
28
|
+
|
|
3
29
|
## 4.0.12
|
|
4
30
|
|
|
5
31
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from "@ai-sdk/provider-utils";
|
|
8
8
|
|
|
9
9
|
// src/version.ts
|
|
10
|
-
var VERSION = true ? "4.0.
|
|
10
|
+
var VERSION = true ? "4.0.14" : "0.0.0-test";
|
|
11
11
|
|
|
12
12
|
// src/google-embedding-model.ts
|
|
13
13
|
import {
|
|
@@ -3273,6 +3273,7 @@ var GoogleFiles = class {
|
|
|
3273
3273
|
await delay(pollIntervalMs);
|
|
3274
3274
|
const { value: fileStatus } = await getFromApi({
|
|
3275
3275
|
url: `${this.config.baseURL}/${file.name}`,
|
|
3276
|
+
validateUrl: false,
|
|
3276
3277
|
headers: combineHeaders4(resolvedHeaders),
|
|
3277
3278
|
successfulResponseHandler: createJsonResponseHandler4(
|
|
3278
3279
|
googleFileResponseSchema
|
|
@@ -3573,6 +3574,7 @@ var GoogleVideoModel = class {
|
|
|
3573
3574
|
}
|
|
3574
3575
|
const { value: statusOperation, responseHeaders: pollHeaders } = await getFromApi2({
|
|
3575
3576
|
url: `${this.config.baseURL}/${operationName}`,
|
|
3577
|
+
validateUrl: false,
|
|
3576
3578
|
headers: combineHeaders5(
|
|
3577
3579
|
await resolve4(this.config.headers),
|
|
3578
3580
|
options.headers
|
|
@@ -5871,6 +5873,7 @@ async function pollGoogleInteractionUntilTerminal({
|
|
|
5871
5873
|
responseHeaders
|
|
5872
5874
|
} = await getFromApi3({
|
|
5873
5875
|
url,
|
|
5876
|
+
validateUrl: false,
|
|
5874
5877
|
headers,
|
|
5875
5878
|
failedResponseHandler: googleFailedResponseHandler,
|
|
5876
5879
|
successfulResponseHandler: createJsonResponseHandler7(
|
|
@@ -6095,6 +6098,7 @@ function streamGoogleInteractionEvents({
|
|
|
6095
6098
|
async function openReader() {
|
|
6096
6099
|
const { value: stream } = await getFromApi4({
|
|
6097
6100
|
url: buildUrl(),
|
|
6101
|
+
validateUrl: false,
|
|
6098
6102
|
headers: eventSourceHeaders,
|
|
6099
6103
|
failedResponseHandler: googleFailedResponseHandler,
|
|
6100
6104
|
successfulResponseHandler: createEventSourceResponseHandler2(
|