@ai-sdk/provider-utils 5.0.0-beta.30 → 5.0.0-beta.49
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 +153 -0
- package/dist/index.d.ts +419 -41
- package/dist/index.js +222 -93
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/src/cancel-response-body.ts +19 -0
- package/src/download-blob.ts +8 -9
- package/src/extract-lines.ts +31 -0
- package/src/fetch-with-validated-redirects.ts +87 -0
- package/src/index.ts +5 -0
- package/src/is-browser-runtime.ts +13 -0
- package/src/is-same-origin.ts +19 -0
- package/src/read-response-with-size-limit.ts +4 -0
- package/src/schema.ts +5 -1
- package/src/to-json-schema/zod3-to-json-schema/parsers/pipeline.ts +6 -4
- package/src/types/content-part.ts +67 -6
- package/src/types/index.ts +10 -7
- package/src/types/infer-tool-context.ts +33 -4
- package/src/types/infer-tool-set-context.ts +36 -7
- package/src/types/sandbox.ts +217 -0
- package/src/types/tool-approval-request.ts +6 -0
- package/src/types/tool-execute-function.ts +6 -0
- package/src/types/tool.ts +44 -18
- package/src/validate-download-url.ts +113 -31
- package/src/types/sensitive-context.ts +0 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,158 @@
|
|
|
1
1
|
# @ai-sdk/provider-utils
|
|
2
2
|
|
|
3
|
+
## 5.0.0-beta.49
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- b8396f0: trigger initial beta release
|
|
8
|
+
- Updated dependencies [b8396f0]
|
|
9
|
+
- @ai-sdk/provider@4.0.0-beta.19
|
|
10
|
+
|
|
11
|
+
## 5.0.0-canary.48
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- aeda373: fix: only send provider credentials to same-origin response-supplied URLs
|
|
16
|
+
|
|
17
|
+
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.
|
|
18
|
+
|
|
19
|
+
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.
|
|
20
|
+
|
|
21
|
+
- 375fdd7: fix: harden download URL SSRF guard against hostname and redirect bypasses
|
|
22
|
+
|
|
23
|
+
`validateDownloadUrl` and the file download helpers (`downloadBlob`, `download`) could be bypassed in several ways when handling untrusted URLs:
|
|
24
|
+
|
|
25
|
+
- A fully-qualified hostname with a trailing dot (e.g. `localhost.`, `myhost.local.`) skipped the localhost/`.local` blocklist.
|
|
26
|
+
- IPv6 addresses that embed an IPv4 address in their last 32 bits — IPv4-compatible (`::127.0.0.1`), IPv4-translated (`::ffff:0:127.0.0.1`), and NAT64 (`64:ff9b::127.0.0.1`, including the `64:ff9b:1::/48` local-use prefix) — were not decoded and checked against the private IPv4 ranges.
|
|
27
|
+
- Redirects were validated only _after_ `fetch` had already followed them, so the request to a redirect target (e.g. an internal/metadata address) had already been issued before the check ran.
|
|
28
|
+
- Several reserved/internal address ranges were not blocked: CGNAT (`100.64.0.0/10`, used by some cloud providers for internal traffic), benchmarking (`198.18.0.0/15`), IETF protocol assignments (`192.0.0.0/24`), the reserved `240.0.0.0/4` block (including the `255.255.255.255` broadcast address), and IPv6 site-local (`fec0::/10`) and multicast (`ff00::/8`).
|
|
29
|
+
|
|
30
|
+
The validator now strips trailing dots before the hostname checks and fully expands IPv6 addresses to detect embedded private IPv4 targets. The download helpers now follow redirects manually (`redirect: 'manual'`), re-validating each hop before requesting it, so an unsafe redirect target is never fetched. When a redirect cannot be inspected because the runtime returns an opaque response, the helpers fail closed (reject the redirect) on the server; only in a real browser — where SSRF is not reachable (fetch is constrained by CORS and cannot reach a server's internal network or cloud-metadata endpoints) — is the redirect followed natively so legitimate redirected downloads keep working.
|
|
31
|
+
|
|
32
|
+
- b4507d5: fix(provider-utils): cancel response body on download rejection to prevent socket leak
|
|
33
|
+
|
|
34
|
+
When a download was rejected early — because the `Content-Length` header exceeded the size limit, the response status was not ok, or a redirect resolved to a blocked URL — the fetch response body was left unconsumed and uncancelled. With WHATWG Fetch/undici this leaves the underlying TCP socket open instead of returning it to the connection pool, allowing an attacker-controlled origin to exhaust file descriptors and cause a denial of service. The body is now cancelled on all early-rejection paths in `readResponseWithSizeLimit`, `download`, and `downloadBlob`, and `fetchWithValidatedRedirects` cancels each redirect hop's body before following or rejecting the next hop.
|
|
35
|
+
|
|
36
|
+
## 5.0.0-canary.47
|
|
37
|
+
|
|
38
|
+
### Patch Changes
|
|
39
|
+
|
|
40
|
+
- bae5e2b: fix(security): re-validate tool approvals from client message history before execution
|
|
41
|
+
|
|
42
|
+
The approval-replay path in `generateText`/`streamText` (and `WorkflowAgent.stream`) reconstructed approved tool calls from the client-supplied messages array and executed them without re-validating input against the tool's schema or re-applying the approval policy. A client could forge an assistant message with a pre-approved tool-call part and have the server execute a tool with attacker-chosen arguments.
|
|
43
|
+
|
|
44
|
+
The replay path now validates HMAC signature (when `experimental_toolApprovalSecret` is configured), re-validates tool-call input against the tool's input schema, and re-resolves the approval policy before execution.
|
|
45
|
+
|
|
46
|
+
## 5.0.0-canary.46
|
|
47
|
+
|
|
48
|
+
### Patch Changes
|
|
49
|
+
|
|
50
|
+
- Updated dependencies [ce769dd]
|
|
51
|
+
- @ai-sdk/provider@4.0.0-canary.18
|
|
52
|
+
|
|
53
|
+
## 5.0.0-canary.45
|
|
54
|
+
|
|
55
|
+
### Patch Changes
|
|
56
|
+
|
|
57
|
+
- ee798eb: chore(provider-utils): rename `Experimental_Sandbox` to `Experimental_SandboxSession`
|
|
58
|
+
- daf6637: feat(provider-utils): add `env` option to `spawn` and `run` methods of `Experimental_SandboxSession`
|
|
59
|
+
|
|
60
|
+
## 5.0.0-canary.44
|
|
61
|
+
|
|
62
|
+
### Patch Changes
|
|
63
|
+
|
|
64
|
+
- 6c93e36: feat(provider-utils): add `spawnCommand` method to `Experimental_Sandbox` to allow for detached command execution
|
|
65
|
+
- f617ac2: feat(provider-utils): narrow `tool()` return type to `ExecutableTool<...>` when `execute` is provided
|
|
66
|
+
|
|
67
|
+
## 5.0.0-canary.43
|
|
68
|
+
|
|
69
|
+
### Patch Changes
|
|
70
|
+
|
|
71
|
+
- 7fc6bd6: Raise minimum supported Node.js version to 22. Supported versions: 22, 24, and 26.
|
|
72
|
+
- Updated dependencies [7fc6bd6]
|
|
73
|
+
- @ai-sdk/provider@4.0.0-canary.17
|
|
74
|
+
|
|
75
|
+
## 5.0.0-canary.42
|
|
76
|
+
|
|
77
|
+
### Patch Changes
|
|
78
|
+
|
|
79
|
+
- a6617c5: feat(provider-utils): add `readFile` and `writeFile` plus convenience wrappers to `Experimental_Sandbox` abstraction
|
|
80
|
+
|
|
81
|
+
## 5.0.0-canary.41
|
|
82
|
+
|
|
83
|
+
### Patch Changes
|
|
84
|
+
|
|
85
|
+
- 28dfa06: fix: support tools with optional context
|
|
86
|
+
- e93fa91: rename Sandbox.executeCommand to Sandbox.runCommand
|
|
87
|
+
|
|
88
|
+
## 5.0.0-canary.40
|
|
89
|
+
|
|
90
|
+
### Patch Changes
|
|
91
|
+
|
|
92
|
+
- a7de9c9: fix: make sandbox experimental
|
|
93
|
+
|
|
94
|
+
## 5.0.0-canary.39
|
|
95
|
+
|
|
96
|
+
### Patch Changes
|
|
97
|
+
|
|
98
|
+
- 105f95b: Ensure the default empty tool input schema includes `type: "object"` for OpenAI-compatible providers that require object schemas.
|
|
99
|
+
|
|
100
|
+
## 5.0.0-canary.38
|
|
101
|
+
|
|
102
|
+
### Patch Changes
|
|
103
|
+
|
|
104
|
+
- ca446f8: feat: flexible tool descriptions
|
|
105
|
+
|
|
106
|
+
## 5.0.0-canary.37
|
|
107
|
+
|
|
108
|
+
### Patch Changes
|
|
109
|
+
|
|
110
|
+
- d848405: feat: add optional `abortSignal` parameters to sandbox command execution
|
|
111
|
+
|
|
112
|
+
## 5.0.0-canary.36
|
|
113
|
+
|
|
114
|
+
### Patch Changes
|
|
115
|
+
|
|
116
|
+
- ca39020: Add an optional `workingDirectory` parameter to sandbox command execution.
|
|
117
|
+
|
|
118
|
+
## 5.0.0-canary.35
|
|
119
|
+
|
|
120
|
+
### Patch Changes
|
|
121
|
+
|
|
122
|
+
- f634bac: feat(mcp): add new McpProviderMetadata type
|
|
123
|
+
|
|
124
|
+
## 5.0.0-canary.34
|
|
125
|
+
|
|
126
|
+
### Patch Changes
|
|
127
|
+
|
|
128
|
+
- 69254e0: feat(ai): add toolMetadata for tool specific metdata
|
|
129
|
+
- 3015fc3: feat: sandbox shell execution abstraction
|
|
130
|
+
|
|
131
|
+
## 5.0.0-canary.33
|
|
132
|
+
|
|
133
|
+
### Patch Changes
|
|
134
|
+
|
|
135
|
+
- 2427d88: feat(ai): change Tool.sensitiveContext to telemetry.includeToolsContext and make it opt-in
|
|
136
|
+
|
|
137
|
+
## 5.0.0-canary.32
|
|
138
|
+
|
|
139
|
+
### Major Changes
|
|
140
|
+
|
|
141
|
+
- 5463d0d: feat(provider): align tool result output content file part types with top-level message file part types
|
|
142
|
+
|
|
143
|
+
### Patch Changes
|
|
144
|
+
|
|
145
|
+
- Updated dependencies [5463d0d]
|
|
146
|
+
- @ai-sdk/provider@4.0.0-canary.16
|
|
147
|
+
|
|
148
|
+
## 5.0.0-canary.31
|
|
149
|
+
|
|
150
|
+
### Patch Changes
|
|
151
|
+
|
|
152
|
+
- 0c4c275: trigger initial canary release
|
|
153
|
+
- Updated dependencies [0c4c275]
|
|
154
|
+
- @ai-sdk/provider@4.0.0-canary.15
|
|
155
|
+
|
|
3
156
|
## 5.0.0-beta.30
|
|
4
157
|
|
|
5
158
|
### Patch Changes
|