@ai-sdk/provider-utils 4.0.16 → 4.0.18
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 +12 -0
- package/dist/index.d.mts +11 -1
- package/dist/index.d.ts +11 -1
- package/dist/index.js +12 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +11 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +1 -0
- package/src/secure-json-parse.ts +6 -2
- package/src/strip-file-extension.ts +13 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @ai-sdk/provider-utils
|
|
2
2
|
|
|
3
|
+
## 4.0.18
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 824b295: fix(provider-utils): prevent unicode escape bypass in secureJsonParse
|
|
8
|
+
|
|
9
|
+
## 4.0.17
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 08336f1: fix(bedrock): strip file extensions from filename
|
|
14
|
+
|
|
3
15
|
## 4.0.16
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -1276,6 +1276,16 @@ type Resolvable<T> = MaybePromiseLike<T> | (() => MaybePromiseLike<T>);
|
|
|
1276
1276
|
*/
|
|
1277
1277
|
declare function resolve<T>(value: Resolvable<T>): Promise<T>;
|
|
1278
1278
|
|
|
1279
|
+
/**
|
|
1280
|
+
* Strips file extension segments from a filename.
|
|
1281
|
+
*
|
|
1282
|
+
* Examples:
|
|
1283
|
+
* - "report.pdf" -> "report"
|
|
1284
|
+
* - "archive.tar.gz" -> "archive"
|
|
1285
|
+
* - "filename" -> "filename"
|
|
1286
|
+
*/
|
|
1287
|
+
declare function stripFileExtension(filename: string): string;
|
|
1288
|
+
|
|
1279
1289
|
declare function convertBase64ToUint8Array(base64String: string): Uint8Array<ArrayBuffer>;
|
|
1280
1290
|
declare function convertUint8ArrayToBase64(array: Uint8Array): string;
|
|
1281
1291
|
declare function convertToBase64(value: string | Uint8Array): string;
|
|
@@ -1411,4 +1421,4 @@ interface ToolResult<NAME extends string, INPUT, OUTPUT> {
|
|
|
1411
1421
|
*/
|
|
1412
1422
|
type ToolCallOptions = ToolExecutionOptions;
|
|
1413
1423
|
|
|
1414
|
-
export { type AssistantContent, type AssistantModelMessage, DEFAULT_MAX_DOWNLOAD_SIZE, type DataContent, DelayedPromise, DownloadError, type FetchFunction, type FilePart, type FlexibleSchema, type IdGenerator, type ImagePart, type InferSchema, type InferToolInput, type InferToolOutput, type LazySchema, type MaybePromiseLike, type ModelMessage, type ParseResult, type ProviderOptions, type ProviderToolFactory, type ProviderToolFactoryWithOutputSchema, type ReasoningPart, type Resolvable, type ResponseHandler, type Schema, type SystemModelMessage, type TextPart, type Tool, type ToolApprovalRequest, type ToolApprovalResponse, type ToolCall, type ToolCallOptions, type ToolCallPart, type ToolContent, type ToolExecuteFunction, type ToolExecutionOptions, type ToolModelMessage, type ToolNameMapping, type ToolNeedsApprovalFunction, type ToolResult, type ToolResultOutput, type ToolResultPart, type UserContent, type UserModelMessage, VERSION, type ValidationResult, asSchema, combineHeaders, convertAsyncIteratorToReadableStream, convertBase64ToUint8Array, convertImageModelFileToDataUri, convertToBase64, convertToFormData, convertUint8ArrayToBase64, createBinaryResponseHandler, createEventSourceResponseHandler, createIdGenerator, createJsonErrorResponseHandler, createJsonResponseHandler, createProviderToolFactory, createProviderToolFactoryWithOutputSchema, createStatusCodeErrorResponseHandler, createToolNameMapping, delay, downloadBlob, dynamicTool, executeTool, extractResponseHeaders, generateId, getErrorMessage, getFromApi, getRuntimeEnvironmentUserAgent, injectJsonInstructionIntoMessages, isAbortError, isNonNullable, isParsableJson, isUrlSupported, jsonSchema, lazySchema, loadApiKey, loadOptionalSetting, loadSetting, mediaTypeToExtension, normalizeHeaders, parseJSON, parseJsonEventStream, parseProviderOptions, postFormDataToApi, postJsonToApi, postToApi, readResponseWithSizeLimit, removeUndefinedEntries, resolve, safeParseJSON, safeValidateTypes, tool, validateTypes, withUserAgentSuffix, withoutTrailingSlash, zodSchema };
|
|
1424
|
+
export { type AssistantContent, type AssistantModelMessage, DEFAULT_MAX_DOWNLOAD_SIZE, type DataContent, DelayedPromise, DownloadError, type FetchFunction, type FilePart, type FlexibleSchema, type IdGenerator, type ImagePart, type InferSchema, type InferToolInput, type InferToolOutput, type LazySchema, type MaybePromiseLike, type ModelMessage, type ParseResult, type ProviderOptions, type ProviderToolFactory, type ProviderToolFactoryWithOutputSchema, type ReasoningPart, type Resolvable, type ResponseHandler, type Schema, type SystemModelMessage, type TextPart, type Tool, type ToolApprovalRequest, type ToolApprovalResponse, type ToolCall, type ToolCallOptions, type ToolCallPart, type ToolContent, type ToolExecuteFunction, type ToolExecutionOptions, type ToolModelMessage, type ToolNameMapping, type ToolNeedsApprovalFunction, type ToolResult, type ToolResultOutput, type ToolResultPart, type UserContent, type UserModelMessage, VERSION, type ValidationResult, asSchema, combineHeaders, convertAsyncIteratorToReadableStream, convertBase64ToUint8Array, convertImageModelFileToDataUri, convertToBase64, convertToFormData, convertUint8ArrayToBase64, createBinaryResponseHandler, createEventSourceResponseHandler, createIdGenerator, createJsonErrorResponseHandler, createJsonResponseHandler, createProviderToolFactory, createProviderToolFactoryWithOutputSchema, createStatusCodeErrorResponseHandler, createToolNameMapping, delay, downloadBlob, dynamicTool, executeTool, extractResponseHeaders, generateId, getErrorMessage, getFromApi, getRuntimeEnvironmentUserAgent, injectJsonInstructionIntoMessages, isAbortError, isNonNullable, isParsableJson, isUrlSupported, jsonSchema, lazySchema, loadApiKey, loadOptionalSetting, loadSetting, mediaTypeToExtension, normalizeHeaders, parseJSON, parseJsonEventStream, parseProviderOptions, postFormDataToApi, postJsonToApi, postToApi, readResponseWithSizeLimit, removeUndefinedEntries, resolve, safeParseJSON, safeValidateTypes, stripFileExtension, tool, validateTypes, withUserAgentSuffix, withoutTrailingSlash, zodSchema };
|
package/dist/index.d.ts
CHANGED
|
@@ -1276,6 +1276,16 @@ type Resolvable<T> = MaybePromiseLike<T> | (() => MaybePromiseLike<T>);
|
|
|
1276
1276
|
*/
|
|
1277
1277
|
declare function resolve<T>(value: Resolvable<T>): Promise<T>;
|
|
1278
1278
|
|
|
1279
|
+
/**
|
|
1280
|
+
* Strips file extension segments from a filename.
|
|
1281
|
+
*
|
|
1282
|
+
* Examples:
|
|
1283
|
+
* - "report.pdf" -> "report"
|
|
1284
|
+
* - "archive.tar.gz" -> "archive"
|
|
1285
|
+
* - "filename" -> "filename"
|
|
1286
|
+
*/
|
|
1287
|
+
declare function stripFileExtension(filename: string): string;
|
|
1288
|
+
|
|
1279
1289
|
declare function convertBase64ToUint8Array(base64String: string): Uint8Array<ArrayBuffer>;
|
|
1280
1290
|
declare function convertUint8ArrayToBase64(array: Uint8Array): string;
|
|
1281
1291
|
declare function convertToBase64(value: string | Uint8Array): string;
|
|
@@ -1411,4 +1421,4 @@ interface ToolResult<NAME extends string, INPUT, OUTPUT> {
|
|
|
1411
1421
|
*/
|
|
1412
1422
|
type ToolCallOptions = ToolExecutionOptions;
|
|
1413
1423
|
|
|
1414
|
-
export { type AssistantContent, type AssistantModelMessage, DEFAULT_MAX_DOWNLOAD_SIZE, type DataContent, DelayedPromise, DownloadError, type FetchFunction, type FilePart, type FlexibleSchema, type IdGenerator, type ImagePart, type InferSchema, type InferToolInput, type InferToolOutput, type LazySchema, type MaybePromiseLike, type ModelMessage, type ParseResult, type ProviderOptions, type ProviderToolFactory, type ProviderToolFactoryWithOutputSchema, type ReasoningPart, type Resolvable, type ResponseHandler, type Schema, type SystemModelMessage, type TextPart, type Tool, type ToolApprovalRequest, type ToolApprovalResponse, type ToolCall, type ToolCallOptions, type ToolCallPart, type ToolContent, type ToolExecuteFunction, type ToolExecutionOptions, type ToolModelMessage, type ToolNameMapping, type ToolNeedsApprovalFunction, type ToolResult, type ToolResultOutput, type ToolResultPart, type UserContent, type UserModelMessage, VERSION, type ValidationResult, asSchema, combineHeaders, convertAsyncIteratorToReadableStream, convertBase64ToUint8Array, convertImageModelFileToDataUri, convertToBase64, convertToFormData, convertUint8ArrayToBase64, createBinaryResponseHandler, createEventSourceResponseHandler, createIdGenerator, createJsonErrorResponseHandler, createJsonResponseHandler, createProviderToolFactory, createProviderToolFactoryWithOutputSchema, createStatusCodeErrorResponseHandler, createToolNameMapping, delay, downloadBlob, dynamicTool, executeTool, extractResponseHeaders, generateId, getErrorMessage, getFromApi, getRuntimeEnvironmentUserAgent, injectJsonInstructionIntoMessages, isAbortError, isNonNullable, isParsableJson, isUrlSupported, jsonSchema, lazySchema, loadApiKey, loadOptionalSetting, loadSetting, mediaTypeToExtension, normalizeHeaders, parseJSON, parseJsonEventStream, parseProviderOptions, postFormDataToApi, postJsonToApi, postToApi, readResponseWithSizeLimit, removeUndefinedEntries, resolve, safeParseJSON, safeValidateTypes, tool, validateTypes, withUserAgentSuffix, withoutTrailingSlash, zodSchema };
|
|
1424
|
+
export { type AssistantContent, type AssistantModelMessage, DEFAULT_MAX_DOWNLOAD_SIZE, type DataContent, DelayedPromise, DownloadError, type FetchFunction, type FilePart, type FlexibleSchema, type IdGenerator, type ImagePart, type InferSchema, type InferToolInput, type InferToolOutput, type LazySchema, type MaybePromiseLike, type ModelMessage, type ParseResult, type ProviderOptions, type ProviderToolFactory, type ProviderToolFactoryWithOutputSchema, type ReasoningPart, type Resolvable, type ResponseHandler, type Schema, type SystemModelMessage, type TextPart, type Tool, type ToolApprovalRequest, type ToolApprovalResponse, type ToolCall, type ToolCallOptions, type ToolCallPart, type ToolContent, type ToolExecuteFunction, type ToolExecutionOptions, type ToolModelMessage, type ToolNameMapping, type ToolNeedsApprovalFunction, type ToolResult, type ToolResultOutput, type ToolResultPart, type UserContent, type UserModelMessage, VERSION, type ValidationResult, asSchema, combineHeaders, convertAsyncIteratorToReadableStream, convertBase64ToUint8Array, convertImageModelFileToDataUri, convertToBase64, convertToFormData, convertUint8ArrayToBase64, createBinaryResponseHandler, createEventSourceResponseHandler, createIdGenerator, createJsonErrorResponseHandler, createJsonResponseHandler, createProviderToolFactory, createProviderToolFactoryWithOutputSchema, createStatusCodeErrorResponseHandler, createToolNameMapping, delay, downloadBlob, dynamicTool, executeTool, extractResponseHeaders, generateId, getErrorMessage, getFromApi, getRuntimeEnvironmentUserAgent, injectJsonInstructionIntoMessages, isAbortError, isNonNullable, isParsableJson, isUrlSupported, jsonSchema, lazySchema, loadApiKey, loadOptionalSetting, loadSetting, mediaTypeToExtension, normalizeHeaders, parseJSON, parseJsonEventStream, parseProviderOptions, postFormDataToApi, postJsonToApi, postToApi, readResponseWithSizeLimit, removeUndefinedEntries, resolve, safeParseJSON, safeValidateTypes, stripFileExtension, tool, validateTypes, withUserAgentSuffix, withoutTrailingSlash, zodSchema };
|
package/dist/index.js
CHANGED
|
@@ -84,6 +84,7 @@ __export(src_exports, {
|
|
|
84
84
|
resolve: () => resolve,
|
|
85
85
|
safeParseJSON: () => safeParseJSON,
|
|
86
86
|
safeValidateTypes: () => safeValidateTypes,
|
|
87
|
+
stripFileExtension: () => stripFileExtension,
|
|
87
88
|
tool: () => tool,
|
|
88
89
|
validateTypes: () => validateTypes,
|
|
89
90
|
withUserAgentSuffix: () => withUserAgentSuffix,
|
|
@@ -573,7 +574,7 @@ function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
|
|
|
573
574
|
}
|
|
574
575
|
|
|
575
576
|
// src/version.ts
|
|
576
|
-
var VERSION = true ? "4.0.
|
|
577
|
+
var VERSION = true ? "4.0.18" : "0.0.0-test";
|
|
577
578
|
|
|
578
579
|
// src/get-from-api.ts
|
|
579
580
|
var getOriginalFetch = () => globalThis.fetch;
|
|
@@ -808,8 +809,8 @@ function mediaTypeToExtension(mediaType) {
|
|
|
808
809
|
var import_provider9 = require("@ai-sdk/provider");
|
|
809
810
|
|
|
810
811
|
// src/secure-json-parse.ts
|
|
811
|
-
var suspectProtoRx = /"
|
|
812
|
-
var suspectConstructorRx = /"
|
|
812
|
+
var suspectProtoRx = /"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/;
|
|
813
|
+
var suspectConstructorRx = /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;
|
|
813
814
|
function _parse(text) {
|
|
814
815
|
const obj = JSON.parse(text);
|
|
815
816
|
if (obj === null || typeof obj !== "object") {
|
|
@@ -829,7 +830,7 @@ function filter(obj) {
|
|
|
829
830
|
if (Object.prototype.hasOwnProperty.call(node, "__proto__")) {
|
|
830
831
|
throw new SyntaxError("Object contains forbidden prototype property");
|
|
831
832
|
}
|
|
832
|
-
if (Object.prototype.hasOwnProperty.call(node, "constructor") && Object.prototype.hasOwnProperty.call(node.constructor, "prototype")) {
|
|
833
|
+
if (Object.prototype.hasOwnProperty.call(node, "constructor") && node.constructor !== null && typeof node.constructor === "object" && Object.prototype.hasOwnProperty.call(node.constructor, "prototype")) {
|
|
833
834
|
throw new SyntaxError("Object contains forbidden prototype property");
|
|
834
835
|
}
|
|
835
836
|
for (const key in node) {
|
|
@@ -2641,6 +2642,12 @@ var createStatusCodeErrorResponseHandler = () => async ({ response, url, request
|
|
|
2641
2642
|
};
|
|
2642
2643
|
};
|
|
2643
2644
|
|
|
2645
|
+
// src/strip-file-extension.ts
|
|
2646
|
+
function stripFileExtension(filename) {
|
|
2647
|
+
const firstDotIndex = filename.indexOf(".");
|
|
2648
|
+
return firstDotIndex === -1 ? filename : filename.slice(0, firstDotIndex);
|
|
2649
|
+
}
|
|
2650
|
+
|
|
2644
2651
|
// src/without-trailing-slash.ts
|
|
2645
2652
|
function withoutTrailingSlash(url) {
|
|
2646
2653
|
return url == null ? void 0 : url.replace(/\/$/, "");
|
|
@@ -2728,6 +2735,7 @@ var import_stream2 = require("eventsource-parser/stream");
|
|
|
2728
2735
|
resolve,
|
|
2729
2736
|
safeParseJSON,
|
|
2730
2737
|
safeValidateTypes,
|
|
2738
|
+
stripFileExtension,
|
|
2731
2739
|
tool,
|
|
2732
2740
|
validateTypes,
|
|
2733
2741
|
withUserAgentSuffix,
|