@ai-sdk/google 3.0.81 → 3.0.82
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 +15 -0
- package/dist/index.js +20 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +21 -6
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +18 -4
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +18 -4
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/google-generative-ai-video-model.ts +8 -4
- package/src/google-json-accumulator.ts +35 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @ai-sdk/google
|
|
2
2
|
|
|
3
|
+
## 3.0.82
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 3258f22: fix(google): prevent prototype pollution when streaming tool args
|
|
8
|
+
- bfa5864: fix: only send provider credentials to same-origin response-supplied URLs
|
|
9
|
+
|
|
10
|
+
Several provider clients followed a URL taken from the provider's API response (a polling/status URL or a final media URL such as `polling_url`, `urls.get`, `result_url`, `result.sample`, or `video.uri`) and reused the authenticated headers — or appended `?key=<API_KEY>` — on that request. Because the host of the response-supplied URL was never validated, the long-lived API key was sent to whatever host the response named (a CDN in the benign case, or an attacker-chosen host if the provider response was tampered with), allowing credential exfiltration.
|
|
11
|
+
|
|
12
|
+
A new `isSameOrigin` helper is added to `@ai-sdk/provider-utils`, and the affected fetches in `@ai-sdk/black-forest-labs`, `@ai-sdk/fireworks`, `@ai-sdk/replicate`, `@ai-sdk/gladia`, `@ai-sdk/fal`, and `@ai-sdk/google` now attach credentials only when the followed URL is same-origin with the provider's configured API origin. Requests to a foreign origin are made without the credential.
|
|
13
|
+
|
|
14
|
+
- Updated dependencies [bfa5864]
|
|
15
|
+
- Updated dependencies [f42aa79]
|
|
16
|
+
- @ai-sdk/provider-utils@4.0.29
|
|
17
|
+
|
|
3
18
|
## 3.0.81
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -30,7 +30,7 @@ module.exports = __toCommonJS(index_exports);
|
|
|
30
30
|
var import_provider_utils23 = require("@ai-sdk/provider-utils");
|
|
31
31
|
|
|
32
32
|
// src/version.ts
|
|
33
|
-
var VERSION = true ? "3.0.
|
|
33
|
+
var VERSION = true ? "3.0.82" : "0.0.0-test";
|
|
34
34
|
|
|
35
35
|
// src/google-generative-ai-embedding-model.ts
|
|
36
36
|
var import_provider = require("@ai-sdk/provider");
|
|
@@ -1365,11 +1365,25 @@ function parsePath(rawPath) {
|
|
|
1365
1365
|
}
|
|
1366
1366
|
return segments;
|
|
1367
1367
|
}
|
|
1368
|
+
var hasOwn = Object.prototype.hasOwnProperty;
|
|
1369
|
+
function hasOwnProperty(obj, key) {
|
|
1370
|
+
return hasOwn.call(obj, key);
|
|
1371
|
+
}
|
|
1372
|
+
function defineOwnProperty(obj, key, value) {
|
|
1373
|
+
Object.defineProperty(obj, key, {
|
|
1374
|
+
value,
|
|
1375
|
+
enumerable: true,
|
|
1376
|
+
configurable: true,
|
|
1377
|
+
writable: true
|
|
1378
|
+
});
|
|
1379
|
+
}
|
|
1368
1380
|
function getNestedValue(obj, segments) {
|
|
1369
1381
|
let current = obj;
|
|
1370
1382
|
for (const seg of segments) {
|
|
1371
1383
|
if (current == null || typeof current !== "object") return void 0;
|
|
1372
|
-
|
|
1384
|
+
const currentRecord = current;
|
|
1385
|
+
if (!hasOwnProperty(currentRecord, seg)) return void 0;
|
|
1386
|
+
current = currentRecord[seg];
|
|
1373
1387
|
}
|
|
1374
1388
|
return current;
|
|
1375
1389
|
}
|
|
@@ -1378,12 +1392,12 @@ function setNestedValue(obj, segments, value) {
|
|
|
1378
1392
|
for (let i = 0; i < segments.length - 1; i++) {
|
|
1379
1393
|
const seg = segments[i];
|
|
1380
1394
|
const nextSeg = segments[i + 1];
|
|
1381
|
-
if (current[seg] == null) {
|
|
1382
|
-
current
|
|
1395
|
+
if (!hasOwnProperty(current, seg) || current[seg] == null) {
|
|
1396
|
+
defineOwnProperty(current, seg, typeof nextSeg === "number" ? [] : {});
|
|
1383
1397
|
}
|
|
1384
1398
|
current = current[seg];
|
|
1385
1399
|
}
|
|
1386
|
-
current
|
|
1400
|
+
defineOwnProperty(current, segments[segments.length - 1], value);
|
|
1387
1401
|
}
|
|
1388
1402
|
function resolvePartialArgValue(arg) {
|
|
1389
1403
|
var _a, _b;
|
|
@@ -3086,7 +3100,7 @@ var GoogleGenerativeAIVideoModel = class {
|
|
|
3086
3100
|
const apiKey = resolvedHeaders == null ? void 0 : resolvedHeaders["x-goog-api-key"];
|
|
3087
3101
|
for (const generatedSample of response.generateVideoResponse.generatedSamples) {
|
|
3088
3102
|
if ((_h = generatedSample.video) == null ? void 0 : _h.uri) {
|
|
3089
|
-
const urlWithAuth = apiKey ? `${generatedSample.video.uri}${generatedSample.video.uri.includes("?") ? "&" : "?"}key=${apiKey}` : generatedSample.video.uri;
|
|
3103
|
+
const urlWithAuth = apiKey && (0, import_provider_utils15.isSameOrigin)(generatedSample.video.uri, this.config.baseURL) ? `${generatedSample.video.uri}${generatedSample.video.uri.includes("?") ? "&" : "?"}key=${apiKey}` : generatedSample.video.uri;
|
|
3090
3104
|
videos.push({
|
|
3091
3105
|
type: "url",
|
|
3092
3106
|
url: urlWithAuth,
|