@ai-sdk/provider-utils 5.0.43 → 5.0.45
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 +14 -0
- package/dist/index.js +29 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/detect-media-type.ts +40 -2
- package/src/fetch-with-validated-redirects.ts +5 -4
- package/src/safe-node-fetch.ts +9 -6
package/package.json
CHANGED
package/src/detect-media-type.ts
CHANGED
|
@@ -49,13 +49,35 @@ const imageMediaTypeSignatures = [
|
|
|
49
49
|
{
|
|
50
50
|
mediaType: 'image/avif' as const,
|
|
51
51
|
bytesPrefix: [
|
|
52
|
-
0x00,
|
|
52
|
+
0x00,
|
|
53
|
+
0x00,
|
|
54
|
+
0x00,
|
|
55
|
+
null, // box size (variable)
|
|
56
|
+
0x66,
|
|
57
|
+
0x74,
|
|
58
|
+
0x79,
|
|
59
|
+
0x70,
|
|
60
|
+
0x61,
|
|
61
|
+
0x76,
|
|
62
|
+
0x69,
|
|
63
|
+
0x66,
|
|
53
64
|
],
|
|
54
65
|
},
|
|
55
66
|
{
|
|
56
67
|
mediaType: 'image/heic' as const,
|
|
57
68
|
bytesPrefix: [
|
|
58
|
-
0x00,
|
|
69
|
+
0x00,
|
|
70
|
+
0x00,
|
|
71
|
+
0x00,
|
|
72
|
+
null, // box size (variable)
|
|
73
|
+
0x66,
|
|
74
|
+
0x74,
|
|
75
|
+
0x79,
|
|
76
|
+
0x70,
|
|
77
|
+
0x68,
|
|
78
|
+
0x65,
|
|
79
|
+
0x69,
|
|
80
|
+
0x63,
|
|
59
81
|
],
|
|
60
82
|
},
|
|
61
83
|
] as const;
|
|
@@ -68,6 +90,22 @@ const documentMediaTypeSignatures = [
|
|
|
68
90
|
] as const;
|
|
69
91
|
|
|
70
92
|
const audioMediaTypeSignaturesWithoutMp4 = [
|
|
93
|
+
{
|
|
94
|
+
mediaType: 'audio/aac' as const,
|
|
95
|
+
bytesPrefix: [0xff, 0xf0], // MPEG-4 ADTS with CRC
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
mediaType: 'audio/aac' as const,
|
|
99
|
+
bytesPrefix: [0xff, 0xf1], // MPEG-4 ADTS without CRC
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
mediaType: 'audio/aac' as const,
|
|
103
|
+
bytesPrefix: [0xff, 0xf8], // MPEG-2 ADTS with CRC
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
mediaType: 'audio/aac' as const,
|
|
107
|
+
bytesPrefix: [0xff, 0xf9], // MPEG-2 ADTS without CRC
|
|
108
|
+
},
|
|
71
109
|
{
|
|
72
110
|
mediaType: 'audio/mpeg' as const,
|
|
73
111
|
bytesPrefix: [0xff, 0xfb],
|
|
@@ -183,10 +183,11 @@ export async function fetchWithValidatedRedirects({
|
|
|
183
183
|
|
|
184
184
|
const location = response.headers?.get('location');
|
|
185
185
|
if (REDIRECT_STATUS_CODES.has(response.status) && location) {
|
|
186
|
-
//
|
|
187
|
-
// hop.
|
|
188
|
-
//
|
|
189
|
-
|
|
186
|
+
// Start releasing the redirect response's connection before moving to
|
|
187
|
+
// the next hop. Do not wait for cancellation: when a fetch wrapper keeps
|
|
188
|
+
// an unread response clone, tee cancellation can remain pending until
|
|
189
|
+
// the cloned branch is consumed.
|
|
190
|
+
void cancelResponseBody(response);
|
|
190
191
|
const nextUrl = new URL(location, currentUrl).toString();
|
|
191
192
|
|
|
192
193
|
// Drop all caller headers except the user-agent before following a
|
package/src/safe-node-fetch.ts
CHANGED
|
@@ -134,13 +134,16 @@ export async function getDefaultDownloadFetch(): Promise<FetchFunction> {
|
|
|
134
134
|
}
|
|
135
135
|
|
|
136
136
|
function createSafeNodeFetch(): FetchFunction {
|
|
137
|
-
//
|
|
138
|
-
//
|
|
139
|
-
|
|
137
|
+
// @vercel/nft (node file trace) only recognizes an indirectly loaded createRequire when its receiver
|
|
138
|
+
// is named `module` and the returned require function is assigned.
|
|
139
|
+
// eslint-disable-next-line @next/next/no-assign-module-variable
|
|
140
|
+
const module = loadBuiltinModule<NodeModule>('node:module');
|
|
140
141
|
const { lookup } = loadBuiltinModule<NodeDns>('node:dns');
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
142
|
+
|
|
143
|
+
// Assign the created require function so deployment tracers can recognize
|
|
144
|
+
// the static dependency without bundlers inlining undici.
|
|
145
|
+
const nodeRequire = module.createRequire(getCurrentModulePath());
|
|
146
|
+
const { Agent, fetch } = nodeRequire('undici') as Undici;
|
|
144
147
|
|
|
145
148
|
const dispatcher = new Agent({
|
|
146
149
|
connect: {
|