@tangle-network/agent-app 0.60.194 → 0.60.196
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/dist/assistant/index.js +2 -2
- package/dist/chat-react/index.js +2 -2
- package/dist/chat-routes/attachment-store.d.ts +18 -0
- package/dist/chat-routes/attachment-upload.d.ts +20 -2
- package/dist/chat-routes/attachment-validation.d.ts +3 -0
- package/dist/chat-routes/binary-sniff.d.ts +28 -0
- package/dist/chat-routes/index.js +279 -15
- package/dist/chat-routes/index.js.map +1 -1
- package/dist/{chunk-6RFNLZCK.js → chunk-2XUIWCRW.js} +26 -5
- package/dist/{chunk-6RFNLZCK.js.map → chunk-2XUIWCRW.js.map} +1 -1
- package/dist/{chunk-PBQYVAB6.js → chunk-2ZRXJ3NO.js} +138 -34
- package/dist/chunk-2ZRXJ3NO.js.map +1 -0
- package/dist/operator/chat-adapter.d.ts +2 -0
- package/dist/operator/client.d.ts +10 -0
- package/dist/operator/contract.d.ts +12 -4
- package/dist/operator/index.js +41 -14
- package/dist/operator/index.js.map +1 -1
- package/dist/operator/server.d.ts +18 -0
- package/dist/web-react/index.js +7 -3
- package/dist/web-react/use-composer-attachments.d.ts +13 -1
- package/package.json +1 -1
- package/dist/chunk-PBQYVAB6.js.map +0 -1
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
PopoverSurface
|
|
18
18
|
} from "./chunk-XG6FODYO.js";
|
|
19
19
|
import {
|
|
20
|
+
ALLOWED_ATTACHMENT_SNIFFED_MIMES,
|
|
20
21
|
ATTACHMENT_ACCEPT,
|
|
21
22
|
ATTACHMENT_MAX_COUNT,
|
|
22
23
|
MAX_ATTACHMENT_TOTAL_BYTES,
|
|
@@ -27,7 +28,7 @@ import {
|
|
|
27
28
|
checkAttachmentType,
|
|
28
29
|
sanitizeAttachmentFileName,
|
|
29
30
|
sniffBinary
|
|
30
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-2ZRXJ3NO.js";
|
|
31
32
|
|
|
32
33
|
// src/web-react/use-dictation.ts
|
|
33
34
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
@@ -1188,6 +1189,17 @@ async function parseUploadError(res) {
|
|
|
1188
1189
|
return `Upload failed (${res.status})`;
|
|
1189
1190
|
}
|
|
1190
1191
|
var NO_UPLOAD_TARGET_MESSAGE = "No upload destination configured (pass uploadUrl or buildUploadRequest)";
|
|
1192
|
+
function withFilename(url, name) {
|
|
1193
|
+
const [base, hash] = url.split("#", 2);
|
|
1194
|
+
const separator = base.includes("?") ? "&" : "?";
|
|
1195
|
+
return `${base}${separator}filename=${encodeURIComponent(name)}${hash === void 0 ? "" : `#${hash}`}`;
|
|
1196
|
+
}
|
|
1197
|
+
function rawUploadHeaders(init, size) {
|
|
1198
|
+
const headers = new Headers(init);
|
|
1199
|
+
headers.set("Content-Type", "application/octet-stream");
|
|
1200
|
+
headers.set("X-Upload-Length", String(size));
|
|
1201
|
+
return headers;
|
|
1202
|
+
}
|
|
1191
1203
|
function useComposerAttachments(options) {
|
|
1192
1204
|
const optionsRef = useRef3(options);
|
|
1193
1205
|
optionsRef.current = options;
|
|
@@ -1224,7 +1236,14 @@ function useComposerAttachments(options) {
|
|
|
1224
1236
|
return;
|
|
1225
1237
|
}
|
|
1226
1238
|
try {
|
|
1227
|
-
const res = await fetch(request.url, {
|
|
1239
|
+
const res = opts.uploadBody === "raw" ? await fetch(withFilename(request.url, name), {
|
|
1240
|
+
method: "POST",
|
|
1241
|
+
credentials: "same-origin",
|
|
1242
|
+
...request.init,
|
|
1243
|
+
headers: rawUploadHeaders(request.init?.headers, file.size),
|
|
1244
|
+
body: file,
|
|
1245
|
+
signal: controller.signal
|
|
1246
|
+
}) : await fetch(request.url, {
|
|
1228
1247
|
method: "POST",
|
|
1229
1248
|
credentials: "same-origin",
|
|
1230
1249
|
...request.init,
|
|
@@ -1278,6 +1297,8 @@ function useComposerAttachments(options) {
|
|
|
1278
1297
|
const maxBinaryBytes = opts.limits?.maxBinaryBytes ?? MAX_BINARY_ATTACHMENT_BYTES;
|
|
1279
1298
|
const maxTextBytes = opts.limits?.maxTextBytes ?? MAX_TEXT_ATTACHMENT_BYTES;
|
|
1280
1299
|
const maxTotalBytes = opts.limits?.maxTotalBytes ?? MAX_ATTACHMENT_TOTAL_BYTES;
|
|
1300
|
+
const maxBytesBySniffedMime = opts.limits?.maxBytesBySniffedMime;
|
|
1301
|
+
const allowedSniffedMimes = opts.allowedSniffedMimes ?? ALLOWED_ATTACHMENT_SNIFFED_MIMES;
|
|
1281
1302
|
const allowedKinds = opts.allowedKinds ?? ["image", "file"];
|
|
1282
1303
|
const list = Array.isArray(files) ? files : Array.from(files);
|
|
1283
1304
|
const currentCount = stagedRef.current.length;
|
|
@@ -1297,12 +1318,12 @@ function useComposerAttachments(options) {
|
|
|
1297
1318
|
for (const file of countAccepted) {
|
|
1298
1319
|
const bytes = new Uint8Array(await file.arrayBuffer());
|
|
1299
1320
|
const sniff = sniffBinary(bytes);
|
|
1300
|
-
const typeCheck = checkAttachmentType(file.name, sniff);
|
|
1321
|
+
const typeCheck = checkAttachmentType(file.name, sniff, allowedSniffedMimes);
|
|
1301
1322
|
if (!typeCheck.succeeded) {
|
|
1302
1323
|
opts.onReject?.(typeCheck.message, file);
|
|
1303
1324
|
continue;
|
|
1304
1325
|
}
|
|
1305
|
-
const limit = sniff.binary ?
|
|
1326
|
+
const limit = !sniff.binary ? maxTextBytes : (sniff.mime ? maxBytesBySniffedMime?.get(sniff.mime) : void 0) ?? maxBinaryBytes;
|
|
1306
1327
|
if (file.size > limit) {
|
|
1307
1328
|
opts.onReject?.(attachmentSizeErrorMessage(file.name, file.size, limit), file);
|
|
1308
1329
|
continue;
|
|
@@ -1552,4 +1573,4 @@ export {
|
|
|
1552
1573
|
ComposerModeControls,
|
|
1553
1574
|
EntryComposer
|
|
1554
1575
|
};
|
|
1555
|
-
//# sourceMappingURL=chunk-
|
|
1576
|
+
//# sourceMappingURL=chunk-2XUIWCRW.js.map
|