@ai-sdk/google 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 CHANGED
@@ -1,5 +1,38 @@
1
1
  # @ai-sdk/google
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
+ - Updated dependencies [4be62c1]
25
+ - Updated dependencies [7805e4a]
26
+ - Updated dependencies [cd12954]
27
+ - @ai-sdk/provider-utils@5.0.9
28
+
29
+ ## 4.0.13
30
+
31
+ ### Patch Changes
32
+
33
+ - Updated dependencies [e193290]
34
+ - @ai-sdk/provider-utils@5.0.8
35
+
3
36
  ## 4.0.12
4
37
 
5
38
  ### 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.12" : "0.0.0-test";
10
+ var VERSION = true ? "4.0.15" : "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(