@antzsoft/chat-core 1.1.4 → 1.1.6
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/README.md +17 -0
- package/dist/chunk-3ISWHKXI.js +429 -0
- package/dist/chunk-3ISWHKXI.js.map +1 -0
- package/dist/index.cjs +72 -36
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -619
- package/dist/index.d.ts +4 -619
- package/dist/index.js +54 -409
- package/dist/index.js.map +1 -1
- package/dist/internal.cjs +224 -0
- package/dist/internal.cjs.map +1 -0
- package/dist/internal.d.cts +5 -0
- package/dist/internal.d.ts +5 -0
- package/dist/internal.js +9 -0
- package/dist/internal.js.map +1 -0
- package/dist/storage-Dc0__sXE.d.cts +635 -0
- package/dist/storage-Dc0__sXE.d.ts +635 -0
- package/docs/integration-guide.html +174 -5
- package/package.json +6 -1
package/README.md
CHANGED
|
@@ -2451,6 +2451,23 @@ document.querySelectorAll('[data-conv-id]').forEach((el) => {
|
|
|
2451
2451
|
|
|
2452
2452
|
## Changelog
|
|
2453
2453
|
|
|
2454
|
+
### v1.1.6
|
|
2455
|
+
- **Fix: Messages arrive out of order when typing and sending rapidly** — When a user sent 10–15+ messages in quick succession, the SDK fired all `send_message` socket emits concurrently. Each emit raced independently against the 5-second ACK timeout, and the server received them in an unpredictable order, causing messages to appear jumbled in the recipient's view. The SDK now serialises sends through a per-conversation FIFO queue — the next message is only emitted after the previous ACK is received, ensuring the server always processes them in the order the user sent them. Queue limits: max 100 pending entries (overflow rejects immediately) and a 30-second per-entry TTL (stale entries are dropped before reaching the socket). **No integration changes required.**
|
|
2456
|
+
- **New: POST mirrors for all PUT and DELETE endpoints** — Every `PUT` and `DELETE` route on the server now has an equivalent `POST` endpoint running alongside it. The SDK calls the POST mirrors exclusively. This allows the SDK to work through black-box proxies and infrastructure that blocks non-POST/GET methods (a common requirement in enterprise and carrier-grade deployments). Original PUT/DELETE routes remain fully operational for direct REST clients and legacy integrations — nothing is removed. The complete mirror map is documented in `POST-MIRRORS.md` in the server repo. **No integration changes required.**
|
|
2457
|
+
- **New: `lastReaction` on `lastMessage` in conversation responses** — `Conversation.lastMessage` now includes a `lastReaction` field (`{ emoji, userId, displayName } | null`) reflecting the most recent reaction added to the last message. Conversation list UIs can surface reaction activity (e.g. "👍 Alice") without fetching the full message. The field is `null` when the last message has no reactions or when the conversation has no messages. The `Message` type already carries this field on individual message responses; it is now also propagated to the `lastMessage` snapshot on the `Conversation` object.
|
|
2458
|
+
- **Improvement: Query optimisations across conversation and message APIs** — Several high-traffic database queries have been rewritten with targeted compound indexes. Conversation list load times are significantly reduced for tenants with large numbers of conversations or participants. Message pagination and unread-count aggregations are also faster. No API surface changes.
|
|
2459
|
+
|
|
2460
|
+
### v1.1.5
|
|
2461
|
+
- **Fix: Hermes crash on image upload — `crypto.randomUUID()` not available on React Native** — Hermes (React Native's JS engine) does not expose `globalThis.crypto.randomUUID`, causing a hard crash when `uploadBatch` was called on iOS or Android. A new `generateUUID()` helper is included in `@antzsoft/chat-core` that falls back to a `Math.random`-based RFC 4122 v4 UUID when the Web Crypto API is unavailable. Used in `uploadBatch`, the RN `useChat` hook, and the web `useChat` hook. **No action required** — handled automatically.
|
|
2462
|
+
- **Fix: Batch upload slot misalignment when one or more files fail presigned-URL generation** — The previous slot-mapping logic assumed failed presigned-URL entries appear at the end of the server's `errors` array, which is incorrect. If file at position 1 failed, the SDK mapped position 2's presigned URL to the wrong file slot, corrupting upload-to-slot tracking. The fix: the SDK now sends a `clientIndex` (0-based position) with each file in the batch request. The server echoes it back in both `urls` and `errors` entries. The SDK uses the echoed `clientIndex` for all slot resolution — no positional assumptions, works correctly for same-named files and any failure pattern. A filename-based fallback is retained for older server versions.
|
|
2463
|
+
- **Improvement: `conversation_updated` fan-out batch-optimised — eliminates N×3 DB round trips** — When a conversation update was broadcast to all participants (e.g. on message, reaction, role change, member add/remove), the server performed 3 sequential DB queries per participant to build each recipient's response DTO. For a 100-member group this was 300 round trips per event. The fan-out now runs a single batch: 1 participants query, 1 batch user lookup, 1 batch read-receipt query, then parallel unread counts — building one shared DTO emitted to all recipients. **No API or SDK changes.**
|
|
2464
|
+
- **Improvement: Conversation list reaction counts update live without a refetch** — `SocketProvider` (web and RN) now handles `reaction_updated` socket events by patching the affected conversation's `lastMessage.reactions` in the local cache. Previously, the emoji counts on the conversation list were stale until the next full list refresh. **No integration changes required.**
|
|
2465
|
+
- **Improvement: Create conversation no longer blocks on socket broadcast for large groups** — `POST /conversations` previously awaited the full `conversation_created` socket fan-out before returning the API response. For 300 participants this triggered ~900 DB queries before the caller received an HTTP response. The emit is now fire-and-forget with a single batched DTO built once and shared across all recipients. **No API changes.**
|
|
2466
|
+
|
|
2467
|
+
### v1.1.4
|
|
2468
|
+
- **Fix: Socket ack timeout eliminated for rapid or large messages** — Sending many messages quickly in group chats could trigger a `Socket ack timeout: send_message` error even though messages were delivered. The server was performing delivery tracking, room broadcasts, and push notifications synchronously before returning the ack, exceeding the 5-second window. The server now returns the ack immediately after writing to the database; all subsequent work runs in the background. No client impact.
|
|
2469
|
+
- **Fix: Per-conversation send queue — parallel sends across conversations** — The SDK's internal send queue was previously global. Messages in Conversation A blocked Conversation B until each ack completed. The queue is now keyed per `conversationId` so independent conversations send in parallel. Messages within the same conversation remain serialised. The 100-message `QUEUE_MAX_SIZE` cap also now applies per conversation. **No integration changes required.**
|
|
2470
|
+
|
|
2454
2471
|
### v1.1.3
|
|
2455
2472
|
- **New: `conversationsApi.leave(conversationId, andDelete?)` — `andDelete` param** — Pass `andDelete: true` to exit a group and hide it from the caller's list in a single atomic server call ("Exit and Delete"). Previously required two separate calls.
|
|
2456
2473
|
- **New: Auto-promote on last-admin exit** — When the only admin leaves a group, the server now automatically promotes the longest-standing active member to admin before completing the exit. Previously the server returned `400 Bad Request` requiring the admin to manually promote someone first.
|
|
@@ -0,0 +1,429 @@
|
|
|
1
|
+
// src/compression/compress.ts
|
|
2
|
+
var GZIP_MIME_TYPES = /* @__PURE__ */ new Set([
|
|
3
|
+
"text/plain",
|
|
4
|
+
"text/csv",
|
|
5
|
+
"text/markdown",
|
|
6
|
+
"text/x-markdown",
|
|
7
|
+
"text/xml",
|
|
8
|
+
"application/xml",
|
|
9
|
+
"text/yaml",
|
|
10
|
+
"text/x-yaml",
|
|
11
|
+
"application/x-yaml",
|
|
12
|
+
"application/rtf",
|
|
13
|
+
"text/rtf",
|
|
14
|
+
"application/json",
|
|
15
|
+
"image/svg+xml"
|
|
16
|
+
]);
|
|
17
|
+
var IMAGE_MIME_TYPES = /* @__PURE__ */ new Set([
|
|
18
|
+
"image/jpeg",
|
|
19
|
+
"image/png",
|
|
20
|
+
"image/gif",
|
|
21
|
+
"image/webp",
|
|
22
|
+
"image/bmp",
|
|
23
|
+
"image/tiff"
|
|
24
|
+
]);
|
|
25
|
+
var SKIP_MIME_TYPES = /* @__PURE__ */ new Set([
|
|
26
|
+
"video/mp4",
|
|
27
|
+
"video/webm",
|
|
28
|
+
"video/quicktime",
|
|
29
|
+
"audio/mpeg",
|
|
30
|
+
"audio/wav",
|
|
31
|
+
"audio/ogg",
|
|
32
|
+
"audio/webm",
|
|
33
|
+
"audio/mp4",
|
|
34
|
+
"application/zip",
|
|
35
|
+
"application/pdf",
|
|
36
|
+
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
37
|
+
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
38
|
+
"application/vnd.openxmlformats-officedocument.presentationml.presentation"
|
|
39
|
+
]);
|
|
40
|
+
function getCompressionStrategy(mimeType, config) {
|
|
41
|
+
if (SKIP_MIME_TYPES.has(mimeType)) return "skip";
|
|
42
|
+
if (IMAGE_MIME_TYPES.has(mimeType)) return "image";
|
|
43
|
+
if (config.compressDocuments && GZIP_MIME_TYPES.has(mimeType)) return "gzip";
|
|
44
|
+
return "skip";
|
|
45
|
+
}
|
|
46
|
+
async function compressFile(file, platformCompressFn, config) {
|
|
47
|
+
const noop = {
|
|
48
|
+
...file,
|
|
49
|
+
originalSize: file.size,
|
|
50
|
+
compressed: false,
|
|
51
|
+
compressionAlgorithm: "none"
|
|
52
|
+
};
|
|
53
|
+
if (!config.enabled || !platformCompressFn) return noop;
|
|
54
|
+
const strategy = getCompressionStrategy(file.type, config);
|
|
55
|
+
if (strategy === "skip") return noop;
|
|
56
|
+
try {
|
|
57
|
+
return await platformCompressFn(file, config);
|
|
58
|
+
} catch {
|
|
59
|
+
return noop;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// src/crypto/session.ts
|
|
64
|
+
var _KEY = /* @__PURE__ */ Symbol.for("__antz_chat_transit__");
|
|
65
|
+
function getState() {
|
|
66
|
+
const g = globalThis;
|
|
67
|
+
if (!g[_KEY]) {
|
|
68
|
+
g[_KEY] = {
|
|
69
|
+
session: null,
|
|
70
|
+
sessionEverEstablished: false,
|
|
71
|
+
readyResolve: null,
|
|
72
|
+
readyPromise: null,
|
|
73
|
+
transitConfigured: null
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
return g[_KEY];
|
|
77
|
+
}
|
|
78
|
+
function configureTransit(enabled) {
|
|
79
|
+
const s = getState();
|
|
80
|
+
s.transitConfigured = enabled;
|
|
81
|
+
if (!enabled) {
|
|
82
|
+
s.readyResolve?.();
|
|
83
|
+
s.readyResolve = null;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function waitForTransitReady() {
|
|
87
|
+
const s = getState();
|
|
88
|
+
if (!s.transitConfigured) return Promise.resolve();
|
|
89
|
+
if (s.session) return Promise.resolve();
|
|
90
|
+
if (s.sessionEverEstablished) return Promise.resolve();
|
|
91
|
+
if (!s.readyPromise) {
|
|
92
|
+
s.readyPromise = new Promise((resolve) => {
|
|
93
|
+
s.readyResolve = resolve;
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
return s.readyPromise;
|
|
97
|
+
}
|
|
98
|
+
function setTransitSession(session) {
|
|
99
|
+
const s = getState();
|
|
100
|
+
s.session = session;
|
|
101
|
+
s.sessionEverEstablished = true;
|
|
102
|
+
s.readyResolve?.();
|
|
103
|
+
s.readyResolve = null;
|
|
104
|
+
}
|
|
105
|
+
function clearTransitSession() {
|
|
106
|
+
const s = getState();
|
|
107
|
+
s.session = null;
|
|
108
|
+
s.readyPromise = null;
|
|
109
|
+
s.readyResolve = null;
|
|
110
|
+
}
|
|
111
|
+
function isTransitEnabled() {
|
|
112
|
+
return getState().session?.enabled === true;
|
|
113
|
+
}
|
|
114
|
+
function getSessionKey() {
|
|
115
|
+
return getState().session?.sessionKey ?? null;
|
|
116
|
+
}
|
|
117
|
+
function getSessionId() {
|
|
118
|
+
return getState().session?.sessionId ?? null;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// src/api/client.ts
|
|
122
|
+
import axios from "axios";
|
|
123
|
+
|
|
124
|
+
// src/crypto/transit.ts
|
|
125
|
+
async function encryptPayload(data, sessionKey) {
|
|
126
|
+
const iv = globalThis.crypto.getRandomValues(new Uint8Array(12));
|
|
127
|
+
const plaintext = new TextEncoder().encode(JSON.stringify(data));
|
|
128
|
+
const encrypted = await globalThis.crypto.subtle.encrypt(
|
|
129
|
+
{ name: "AES-GCM", iv },
|
|
130
|
+
sessionKey,
|
|
131
|
+
plaintext
|
|
132
|
+
);
|
|
133
|
+
const ct = encrypted.slice(0, encrypted.byteLength - 16);
|
|
134
|
+
const tag = encrypted.slice(encrypted.byteLength - 16);
|
|
135
|
+
return {
|
|
136
|
+
v: 1,
|
|
137
|
+
iv: bufToB64(iv),
|
|
138
|
+
tag: bufToB64(tag),
|
|
139
|
+
ct: bufToB64(ct)
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
async function decryptPayload(envelope, sessionKey) {
|
|
143
|
+
const iv = b64ToBuf(envelope.iv);
|
|
144
|
+
const tag = b64ToBuf(envelope.tag);
|
|
145
|
+
const ct = b64ToBuf(envelope.ct);
|
|
146
|
+
const combined = new Uint8Array(ct.byteLength + tag.byteLength);
|
|
147
|
+
combined.set(new Uint8Array(ct), 0);
|
|
148
|
+
combined.set(new Uint8Array(tag), ct.byteLength);
|
|
149
|
+
const decrypted = await globalThis.crypto.subtle.decrypt(
|
|
150
|
+
{ name: "AES-GCM", iv: new Uint8Array(iv) },
|
|
151
|
+
sessionKey,
|
|
152
|
+
combined
|
|
153
|
+
);
|
|
154
|
+
return JSON.parse(new TextDecoder().decode(decrypted));
|
|
155
|
+
}
|
|
156
|
+
function isTransitEnvelope(v) {
|
|
157
|
+
return typeof v === "object" && v !== null && v.v === 1 && typeof v.iv === "string" && typeof v.tag === "string" && typeof v.ct === "string";
|
|
158
|
+
}
|
|
159
|
+
function bufToB64(buf) {
|
|
160
|
+
const bytes = buf instanceof Uint8Array ? buf : new Uint8Array(buf);
|
|
161
|
+
let str = "";
|
|
162
|
+
bytes.forEach((b) => {
|
|
163
|
+
str += String.fromCharCode(b);
|
|
164
|
+
});
|
|
165
|
+
return btoa(str);
|
|
166
|
+
}
|
|
167
|
+
function b64ToBuf(b64) {
|
|
168
|
+
const bin = atob(b64);
|
|
169
|
+
const buf = new Uint8Array(bin.length);
|
|
170
|
+
for (let i = 0; i < bin.length; i++) buf[i] = bin.charCodeAt(i);
|
|
171
|
+
return buf.buffer;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// src/api/client.ts
|
|
175
|
+
var _tokenStore = null;
|
|
176
|
+
var _config = null;
|
|
177
|
+
var _avatarSent = false;
|
|
178
|
+
function initApiClient(config, tokenStore) {
|
|
179
|
+
_config = config;
|
|
180
|
+
_tokenStore = tokenStore;
|
|
181
|
+
_avatarSent = false;
|
|
182
|
+
const client = axios.create({
|
|
183
|
+
baseURL: config.apiUrl,
|
|
184
|
+
headers: { "Content-Type": "application/json" }
|
|
185
|
+
});
|
|
186
|
+
configureTransit(config.transitEncryption);
|
|
187
|
+
client.interceptors.request.use(async (req) => {
|
|
188
|
+
const token = _tokenStore?.getAccessToken();
|
|
189
|
+
if (token) req.headers["Authorization"] = `Bearer ${token}`;
|
|
190
|
+
if (_config?.userId) req.headers["x-user-id"] = _config.userId;
|
|
191
|
+
if (_config?.tenantId) req.headers["X-Tenant-ID"] = _config.tenantId;
|
|
192
|
+
if (token && !_avatarSent && _config?.avatar) {
|
|
193
|
+
if (_config.avatar.base64) req.headers["x-avatar-base64"] = _config.avatar.base64;
|
|
194
|
+
else if (_config.avatar.url) req.headers["x-avatar-url"] = _config.avatar.url;
|
|
195
|
+
_avatarSent = true;
|
|
196
|
+
}
|
|
197
|
+
await waitForTransitReady();
|
|
198
|
+
if (isTransitEnabled()) {
|
|
199
|
+
const sessionId = getSessionId();
|
|
200
|
+
const key = getSessionKey();
|
|
201
|
+
if (sessionId && key) {
|
|
202
|
+
req.headers["x-transit-session"] = sessionId;
|
|
203
|
+
if (req.data !== void 0 && req.data !== null) {
|
|
204
|
+
const envelope = await encryptPayload(req.data, key);
|
|
205
|
+
req.data = envelope;
|
|
206
|
+
req.headers["x-transit-encrypted"] = "1";
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
return req;
|
|
211
|
+
});
|
|
212
|
+
let isRefreshing = false;
|
|
213
|
+
let refreshQueue = [];
|
|
214
|
+
client.interceptors.response.use(
|
|
215
|
+
async (response) => {
|
|
216
|
+
if (isTransitEnabled()) {
|
|
217
|
+
const key = getSessionKey();
|
|
218
|
+
if (key) {
|
|
219
|
+
if (isTransitEnvelope(response.data)) {
|
|
220
|
+
response.data = await decryptPayload(response.data, key);
|
|
221
|
+
} else if (response.data?.data && isTransitEnvelope(response.data.data)) {
|
|
222
|
+
response.data.data = await decryptPayload(response.data.data, key);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
if (response.data && typeof response.data === "object" && "success" in response.data && "data" in response.data) {
|
|
227
|
+
response.data = response.data.data;
|
|
228
|
+
}
|
|
229
|
+
return response;
|
|
230
|
+
},
|
|
231
|
+
async (error) => {
|
|
232
|
+
if (isTransitEnabled() && error.response?.data) {
|
|
233
|
+
const key = getSessionKey();
|
|
234
|
+
if (key) {
|
|
235
|
+
try {
|
|
236
|
+
if (isTransitEnvelope(error.response.data)) {
|
|
237
|
+
error.response.data = await decryptPayload(error.response.data, key);
|
|
238
|
+
} else if (error.response.data?.data && isTransitEnvelope(error.response.data.data)) {
|
|
239
|
+
error.response.data.data = await decryptPayload(error.response.data.data, key);
|
|
240
|
+
}
|
|
241
|
+
} catch {
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
const original = error.config;
|
|
246
|
+
if (error.response?.status === 401 && !original._retry) {
|
|
247
|
+
const refreshToken = _tokenStore?.getRefreshToken();
|
|
248
|
+
if (!refreshToken) {
|
|
249
|
+
_tokenStore?.clearTokens();
|
|
250
|
+
return Promise.reject(error);
|
|
251
|
+
}
|
|
252
|
+
if (isRefreshing) {
|
|
253
|
+
return new Promise((resolve) => {
|
|
254
|
+
refreshQueue.push((newToken) => {
|
|
255
|
+
original.headers["Authorization"] = `Bearer ${newToken}`;
|
|
256
|
+
resolve(client(original));
|
|
257
|
+
});
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
original._retry = true;
|
|
261
|
+
isRefreshing = true;
|
|
262
|
+
try {
|
|
263
|
+
const { data } = await axios.post(
|
|
264
|
+
`${_config.apiUrl}/auth/refresh`,
|
|
265
|
+
{ refreshToken }
|
|
266
|
+
);
|
|
267
|
+
const tokens = data.data ?? data;
|
|
268
|
+
_tokenStore?.setTokens(tokens);
|
|
269
|
+
refreshQueue.forEach((cb) => cb(tokens.accessToken));
|
|
270
|
+
refreshQueue = [];
|
|
271
|
+
original.headers["Authorization"] = `Bearer ${tokens.accessToken}`;
|
|
272
|
+
return client(original);
|
|
273
|
+
} catch {
|
|
274
|
+
_tokenStore?.clearTokens();
|
|
275
|
+
return Promise.reject(error);
|
|
276
|
+
} finally {
|
|
277
|
+
isRefreshing = false;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
return Promise.reject(error);
|
|
281
|
+
}
|
|
282
|
+
);
|
|
283
|
+
return client;
|
|
284
|
+
}
|
|
285
|
+
var _instance = null;
|
|
286
|
+
function setApiClientInstance(instance) {
|
|
287
|
+
_instance = instance;
|
|
288
|
+
}
|
|
289
|
+
function getApiClient() {
|
|
290
|
+
if (!_instance) throw new Error("[AntzChat] API client not initialized. Call initApiClient first.");
|
|
291
|
+
return _instance;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
// src/crypto/uuid.ts
|
|
295
|
+
function generateUUID() {
|
|
296
|
+
if (typeof globalThis.crypto?.randomUUID === "function") {
|
|
297
|
+
return globalThis.crypto.randomUUID();
|
|
298
|
+
}
|
|
299
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
|
|
300
|
+
const r = Math.random() * 16 | 0;
|
|
301
|
+
return (c === "x" ? r : r & 3 | 8).toString(16);
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
// src/api/storage.ts
|
|
306
|
+
var storageApi = {
|
|
307
|
+
async requestPresignedUrl(payload) {
|
|
308
|
+
const { data } = await getApiClient().post("/storage/presigned-url", payload);
|
|
309
|
+
return data;
|
|
310
|
+
},
|
|
311
|
+
async requestPresignedUrlBatch(files) {
|
|
312
|
+
const { data } = await getApiClient().post("/storage/presigned-url/batch", { files });
|
|
313
|
+
return data;
|
|
314
|
+
},
|
|
315
|
+
async confirmUpload(fileId) {
|
|
316
|
+
const { data } = await getApiClient().post(`/storage/confirm/${fileId}`);
|
|
317
|
+
return data;
|
|
318
|
+
},
|
|
319
|
+
async getFile(fileId) {
|
|
320
|
+
const { data } = await getApiClient().get(`/storage/files/${fileId}`);
|
|
321
|
+
return data;
|
|
322
|
+
},
|
|
323
|
+
async getFileUrl(fileId, expiresIn) {
|
|
324
|
+
const { data } = await getApiClient().get(`/storage/files/${fileId}/url`, {
|
|
325
|
+
params: expiresIn ? { expiresIn } : {}
|
|
326
|
+
});
|
|
327
|
+
return data;
|
|
328
|
+
},
|
|
329
|
+
async deleteFile(fileId) {
|
|
330
|
+
await getApiClient().post(`/storage/files/${fileId}/delete`);
|
|
331
|
+
},
|
|
332
|
+
async getConversationFiles(conversationId, params = {}) {
|
|
333
|
+
const { data } = await getApiClient().get(
|
|
334
|
+
`/storage/conversations/${conversationId}/files`,
|
|
335
|
+
{ params }
|
|
336
|
+
);
|
|
337
|
+
return data;
|
|
338
|
+
},
|
|
339
|
+
async getMyFiles(params = {}) {
|
|
340
|
+
const { data } = await getApiClient().get("/storage/my-files", { params });
|
|
341
|
+
return data;
|
|
342
|
+
}
|
|
343
|
+
};
|
|
344
|
+
async function runUploadBatch(files, platformUploadFn, slotIds, conversationId, onProgress, platformCompressFn, compressionConfig) {
|
|
345
|
+
const compressedFiles = await Promise.all(
|
|
346
|
+
files.map((f) => compressFile(f, platformCompressFn, compressionConfig ?? { enabled: false, imageQuality: 0.85, imageMaxDimension: 1920, compressDocuments: true }))
|
|
347
|
+
);
|
|
348
|
+
const slotted = compressedFiles.map((f, i) => ({ file: f, slotId: slotIds[i], clientIndex: i }));
|
|
349
|
+
const requests = slotted.map(({ file: f, clientIndex }) => ({
|
|
350
|
+
filename: f.name,
|
|
351
|
+
mimeType: f.type,
|
|
352
|
+
size: f.size,
|
|
353
|
+
conversationId,
|
|
354
|
+
clientIndex,
|
|
355
|
+
...f.compressed && {
|
|
356
|
+
metadata: {
|
|
357
|
+
compressed: f.compressed,
|
|
358
|
+
originalSize: f.originalSize,
|
|
359
|
+
compressionAlgorithm: f.compressionAlgorithm
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
}));
|
|
363
|
+
const { urls, errors: requestErrors } = await storageApi.requestPresignedUrlBatch(requests);
|
|
364
|
+
const failedSlotIds = /* @__PURE__ */ new Set();
|
|
365
|
+
const failed = requestErrors.map((e) => {
|
|
366
|
+
const idx = e.clientIndex ?? slotted.findIndex((s) => s.file.name === e.filename);
|
|
367
|
+
const slotId = slotted[idx]?.slotId;
|
|
368
|
+
if (slotId) failedSlotIds.add(slotId);
|
|
369
|
+
return { filename: e.filename, error: e.error };
|
|
370
|
+
});
|
|
371
|
+
const progressMap = {};
|
|
372
|
+
const reportProgress = () => {
|
|
373
|
+
if (!onProgress) return;
|
|
374
|
+
const vals = Object.values(progressMap);
|
|
375
|
+
const avg = vals.reduce((s, v) => s + v, 0) / Math.max(vals.length, 1);
|
|
376
|
+
onProgress(Math.round(avg));
|
|
377
|
+
};
|
|
378
|
+
const successful = [];
|
|
379
|
+
const slotToFile = /* @__PURE__ */ new Map();
|
|
380
|
+
await Promise.all(
|
|
381
|
+
urls.map(async (presigned, idx) => {
|
|
382
|
+
const originalIdx = presigned.clientIndex ?? idx;
|
|
383
|
+
const { file, slotId } = slotted[originalIdx];
|
|
384
|
+
progressMap[originalIdx] = 0;
|
|
385
|
+
try {
|
|
386
|
+
await platformUploadFn(presigned, file, (pct) => {
|
|
387
|
+
progressMap[originalIdx] = Math.round(pct * 0.9);
|
|
388
|
+
reportProgress();
|
|
389
|
+
});
|
|
390
|
+
const fileResponse = await storageApi.confirmUpload(presigned.fileId);
|
|
391
|
+
progressMap[originalIdx] = 100;
|
|
392
|
+
reportProgress();
|
|
393
|
+
successful.push(fileResponse);
|
|
394
|
+
slotToFile.set(slotId, fileResponse);
|
|
395
|
+
} catch (err) {
|
|
396
|
+
failed.push({ filename: file.name, error: err.message });
|
|
397
|
+
}
|
|
398
|
+
})
|
|
399
|
+
);
|
|
400
|
+
return { result: { successful, failed }, slotToFile };
|
|
401
|
+
}
|
|
402
|
+
async function uploadBatch(files, platformUploadFn, conversationId, onProgress, platformCompressFn, compressionConfig) {
|
|
403
|
+
const slotIds = files.map(() => generateUUID());
|
|
404
|
+
const { result } = await runUploadBatch(files, platformUploadFn, slotIds, conversationId, onProgress, platformCompressFn, compressionConfig);
|
|
405
|
+
return result;
|
|
406
|
+
}
|
|
407
|
+
async function uploadBatchWithSlots(files, platformUploadFn, slotIds, conversationId, onProgress, platformCompressFn, compressionConfig) {
|
|
408
|
+
return runUploadBatch(files, platformUploadFn, slotIds, conversationId, onProgress, platformCompressFn, compressionConfig);
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
export {
|
|
412
|
+
getCompressionStrategy,
|
|
413
|
+
encryptPayload,
|
|
414
|
+
decryptPayload,
|
|
415
|
+
isTransitEnvelope,
|
|
416
|
+
configureTransit,
|
|
417
|
+
setTransitSession,
|
|
418
|
+
clearTransitSession,
|
|
419
|
+
isTransitEnabled,
|
|
420
|
+
getSessionKey,
|
|
421
|
+
initApiClient,
|
|
422
|
+
setApiClientInstance,
|
|
423
|
+
getApiClient,
|
|
424
|
+
generateUUID,
|
|
425
|
+
storageApi,
|
|
426
|
+
uploadBatch,
|
|
427
|
+
uploadBatchWithSlots
|
|
428
|
+
};
|
|
429
|
+
//# sourceMappingURL=chunk-3ISWHKXI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/compression/compress.ts","../src/crypto/session.ts","../src/api/client.ts","../src/crypto/transit.ts","../src/crypto/uuid.ts","../src/api/storage.ts"],"sourcesContent":["import type { UploadableFile, CompressedFile, CompressionAlgorithm } from '../types/index.js';\nimport type { PlatformCompressFn, ResolvedCompressionConfig } from '../config/types.js';\n\n// MIME types that benefit from gzip (text-based, not already compressed)\nconst GZIP_MIME_TYPES = new Set([\n 'text/plain', 'text/csv', 'text/markdown', 'text/x-markdown',\n 'text/xml', 'application/xml', 'text/yaml', 'text/x-yaml',\n 'application/x-yaml', 'application/rtf', 'text/rtf',\n 'application/json', 'image/svg+xml',\n]);\n\nconst IMAGE_MIME_TYPES = new Set([\n 'image/jpeg', 'image/png', 'image/gif', 'image/webp', 'image/bmp', 'image/tiff',\n]);\n\n// Already-compressed formats — no gain from recompressing\nconst SKIP_MIME_TYPES = new Set([\n 'video/mp4', 'video/webm', 'video/quicktime',\n 'audio/mpeg', 'audio/wav', 'audio/ogg', 'audio/webm', 'audio/mp4',\n 'application/zip', 'application/pdf',\n 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',\n 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',\n 'application/vnd.openxmlformats-officedocument.presentationml.presentation',\n]);\n\nexport type CompressionStrategy = 'image' | 'gzip' | 'skip';\n\nexport function getCompressionStrategy(\n mimeType: string,\n config: ResolvedCompressionConfig,\n): CompressionStrategy {\n if (SKIP_MIME_TYPES.has(mimeType)) return 'skip';\n if (IMAGE_MIME_TYPES.has(mimeType)) return 'image';\n if (config.compressDocuments && GZIP_MIME_TYPES.has(mimeType)) return 'gzip';\n return 'skip';\n}\n\n/**\n * Attempt to compress a file using the platform-provided compressor.\n * Returns the original file unchanged (as a CompressedFile with compressed=false)\n * if compression is disabled, no compressor is provided, or the strategy is 'skip'.\n */\nexport async function compressFile(\n file: UploadableFile,\n platformCompressFn: PlatformCompressFn | undefined,\n config: ResolvedCompressionConfig,\n): Promise<CompressedFile> {\n const noop: CompressedFile = {\n ...file,\n originalSize: file.size,\n compressed: false,\n compressionAlgorithm: 'none' as CompressionAlgorithm,\n };\n\n if (!config.enabled || !platformCompressFn) return noop;\n\n const strategy = getCompressionStrategy(file.type, config);\n if (strategy === 'skip') return noop;\n\n try {\n return await platformCompressFn(file, config);\n } catch {\n // Compression failure is non-fatal — fall back to original\n return noop;\n }\n}\n","import type { TransitAlgo } from './detect.js';\n\ninterface TransitSession {\n sessionKey: CryptoKey;\n algo: TransitAlgo;\n sessionId: string;\n enabled: boolean;\n}\n\n// All state lives on globalThis so Turbopack <locals> module splits and any\n// other bundler that creates multiple instances of this module still share a\n// single source of truth. The symbol key prevents accidental collisions.\nconst _KEY = Symbol.for('__antz_chat_transit__');\n\ninterface TransitState {\n session: TransitSession | null;\n sessionEverEstablished: boolean;\n readyResolve: (() => void) | null;\n readyPromise: Promise<void> | null;\n transitConfigured: boolean | null;\n}\n\nfunction getState(): TransitState {\n const g = globalThis as any;\n if (!g[_KEY]) {\n g[_KEY] = {\n session: null,\n sessionEverEstablished: false,\n readyResolve: null,\n readyPromise: null,\n transitConfigured: null,\n } satisfies TransitState;\n }\n return g[_KEY] as TransitState;\n}\n\nexport function configureTransit(enabled: boolean): void {\n const s = getState();\n s.transitConfigured = enabled;\n if (!enabled) {\n // Transit disabled — resolve immediately so HTTP requests don't block\n s.readyResolve?.();\n s.readyResolve = null;\n }\n}\n\nexport function waitForTransitReady(): Promise<void> {\n const s = getState();\n // Not configured yet or disabled — resolve immediately\n if (!s.transitConfigured) return Promise.resolve();\n // Already have an active session — resolve immediately\n if (s.session) return Promise.resolve();\n // Session was previously established but is now cleared (socket dropped/reconnecting).\n // The encryption block in the interceptor is guarded by isTransitEnabled() and will\n // skip itself with no session, so there is no point blocking here.\n if (s.sessionEverEstablished) return Promise.resolve();\n // First startup — block until the initial ECDH handshake completes.\n if (!s.readyPromise) {\n s.readyPromise = new Promise<void>((resolve) => {\n s.readyResolve = resolve;\n });\n }\n return s.readyPromise;\n}\n\nexport function setTransitSession(session: TransitSession): void {\n const s = getState();\n s.session = session;\n s.sessionEverEstablished = true;\n // Resolve any pending HTTP requests waiting for the session key\n s.readyResolve?.();\n s.readyResolve = null;\n}\n\nexport function getTransitSession(): TransitSession | null {\n return getState().session;\n}\n\nexport function clearTransitSession(): void {\n const s = getState();\n s.session = null;\n // Reset the ready promise so it can be recreated on next waitForTransitReady call.\n // sessionEverEstablished intentionally left true — HTTP requests fired while\n // reconnecting should not block (isTransitEnabled() guards encryption anyway).\n s.readyPromise = null;\n s.readyResolve = null;\n}\n\nexport function isTransitEnabled(): boolean {\n return getState().session?.enabled === true;\n}\n\nexport function getSessionKey(): CryptoKey | null {\n return getState().session?.sessionKey ?? null;\n}\n\n// Returns sessionId for the x-transit-session header sent with HTTP requests.\nexport function getSessionId(): string | null {\n return getState().session?.sessionId ?? null;\n}\n","import axios, {\n AxiosInstance,\n InternalAxiosRequestConfig,\n} from 'axios';\nimport type { ResolvedConfig } from '../config/types.js';\nimport type { AuthTokens } from '../types/index.js';\nimport { encryptPayload, decryptPayload, isTransitEnvelope } from '../crypto/transit.js';\nimport { getSessionKey, getSessionId, isTransitEnabled, waitForTransitReady, configureTransit } from '../crypto/session.js';\n\nexport type TokenStore = {\n getAccessToken: () => string | null | undefined;\n getRefreshToken: () => string | null | undefined;\n setTokens: (tokens: AuthTokens) => void;\n clearTokens: () => void;\n};\n\nlet _tokenStore: TokenStore | null = null;\nlet _config: ResolvedConfig | null = null;\n// Avatar headers are sent only on the first authenticated request after init.\n// The server hashes on receive and deduplicates — subsequent requests don't need them.\nlet _avatarSent = false;\n\nexport function initApiClient(config: ResolvedConfig, tokenStore: TokenStore): AxiosInstance {\n _config = config;\n _tokenStore = tokenStore;\n _avatarSent = false; // reset on re-init (new session / authToken change)\n\n const client = axios.create({\n baseURL: config.apiUrl,\n headers: { 'Content-Type': 'application/json' },\n });\n\n // Configure transit as early as possible — before any requests fire —\n // so waitForTransitReady() in the interceptor knows whether to block or not.\n configureTransit(config.transitEncryption);\n\n // ── Request interceptor ──────────────────────────────────────────────────\n client.interceptors.request.use(async (req: InternalAxiosRequestConfig) => {\n const token = _tokenStore?.getAccessToken();\n if (token) req.headers['Authorization'] = `Bearer ${token}`;\n if (_config?.userId) req.headers['x-user-id'] = _config.userId;\n if (_config?.tenantId) req.headers['X-Tenant-ID'] = _config.tenantId;\n // Send avatar on the first request only — server hashes and deduplicates\n if (token && !_avatarSent && _config?.avatar) {\n if (_config.avatar.base64) req.headers['x-avatar-base64'] = _config.avatar.base64;\n else if (_config.avatar.url) req.headers['x-avatar-url'] = _config.avatar.url;\n _avatarSent = true;\n }\n\n // Wait for the transit session key to be established before sending.\n // HTTP requests that fire before connectSocket completes (e.g. getMe, getConfig)\n // are held here until the ECDH handshake finishes. Resolves immediately when\n // transit is disabled or already established.\n await waitForTransitReady();\n\n // Transit encryption — attach session ID on every request so the server\n // can look up the session key. Encrypt body when present.\n if (isTransitEnabled()) {\n const sessionId = getSessionId();\n const key = getSessionKey();\n if (sessionId && key) {\n req.headers['x-transit-session'] = sessionId;\n if (req.data !== undefined && req.data !== null) {\n const envelope = await encryptPayload(req.data, key);\n req.data = envelope;\n req.headers['x-transit-encrypted'] = '1';\n }\n }\n }\n\n return req;\n });\n\n let isRefreshing = false;\n let refreshQueue: Array<(token: string) => void> = [];\n\n // ── Response interceptor ─────────────────────────────────────────────────\n client.interceptors.response.use(\n async (response) => {\n // Transit decryption — server wraps encrypted payload inside { success, data: <envelope> }.\n // Decrypt the inner envelope, then let the standard unwrap below handle { success, data }.\n if (isTransitEnabled()) {\n const key = getSessionKey();\n if (key) {\n // Case 1: entire response is the envelope (unlikely but handle it)\n if (isTransitEnvelope(response.data)) {\n response.data = await decryptPayload(response.data, key);\n }\n // Case 2: envelope is nested inside { success, data: <envelope> }\n else if (response.data?.data && isTransitEnvelope(response.data.data)) {\n response.data.data = await decryptPayload(response.data.data, key);\n }\n }\n }\n\n // Standard { success, data } unwrap\n if (\n response.data &&\n typeof response.data === 'object' &&\n 'success' in response.data &&\n 'data' in response.data\n ) {\n response.data = response.data.data;\n }\n return response;\n },\n async (error) => {\n // Decrypt error response body — error filter encrypts it too\n if (isTransitEnabled() && error.response?.data) {\n const key = getSessionKey();\n if (key) {\n try {\n if (isTransitEnvelope(error.response.data)) {\n error.response.data = await decryptPayload(error.response.data, key);\n } else if (error.response.data?.data && isTransitEnvelope(error.response.data.data)) {\n error.response.data.data = await decryptPayload(error.response.data.data, key);\n }\n } catch { /* decryption failed — leave as-is */ }\n }\n }\n\n const original = error.config as InternalAxiosRequestConfig & { _retry?: boolean };\n\n if (error.response?.status === 401 && !original._retry) {\n const refreshToken = _tokenStore?.getRefreshToken();\n if (!refreshToken) {\n _tokenStore?.clearTokens();\n return Promise.reject(error);\n }\n\n if (isRefreshing) {\n return new Promise((resolve) => {\n refreshQueue.push((newToken) => {\n original.headers['Authorization'] = `Bearer ${newToken}`;\n resolve(client(original));\n });\n });\n }\n\n original._retry = true;\n isRefreshing = true;\n\n try {\n const { data } = await axios.post<{ data: AuthTokens }>(\n `${_config!.apiUrl}/auth/refresh`,\n { refreshToken },\n );\n const tokens: AuthTokens = (data as any).data ?? data;\n _tokenStore?.setTokens(tokens);\n refreshQueue.forEach((cb) => cb(tokens.accessToken));\n refreshQueue = [];\n original.headers['Authorization'] = `Bearer ${tokens.accessToken}`;\n return client(original);\n } catch {\n _tokenStore?.clearTokens();\n return Promise.reject(error);\n } finally {\n isRefreshing = false;\n }\n }\n\n return Promise.reject(error);\n },\n );\n\n return client;\n}\n\nlet _instance: AxiosInstance | null = null;\n\nexport function setApiClientInstance(instance: AxiosInstance) {\n _instance = instance;\n}\n\nexport function getApiClient(): AxiosInstance {\n if (!_instance) throw new Error('[AntzChat] API client not initialized. Call initApiClient first.');\n return _instance;\n}\n","export interface TransitEnvelope {\n v: 1;\n iv: string; // base64, 12 bytes\n tag: string; // base64, 16 bytes\n ct: string; // base64, ciphertext\n}\n\n// ─── Encrypt ─────────────────────────────────────────────────────────────────\n\nexport async function encryptPayload(\n data: unknown,\n sessionKey: CryptoKey,\n): Promise<TransitEnvelope> {\n const iv = globalThis.crypto.getRandomValues(new Uint8Array(12));\n const plaintext = new TextEncoder().encode(JSON.stringify(data));\n\n const encrypted = await globalThis.crypto.subtle.encrypt(\n { name: 'AES-GCM', iv },\n sessionKey,\n plaintext,\n );\n\n // AES-GCM appends the 16-byte auth tag to the ciphertext buffer\n const ct = encrypted.slice(0, encrypted.byteLength - 16);\n const tag = encrypted.slice(encrypted.byteLength - 16);\n\n return {\n v: 1,\n iv: bufToB64(iv),\n tag: bufToB64(tag),\n ct: bufToB64(ct),\n };\n}\n\n// ─── Decrypt ─────────────────────────────────────────────────────────────────\n\nexport async function decryptPayload(\n envelope: TransitEnvelope,\n sessionKey: CryptoKey,\n): Promise<unknown> {\n const iv = b64ToBuf(envelope.iv);\n const tag = b64ToBuf(envelope.tag);\n const ct = b64ToBuf(envelope.ct);\n\n // Reassemble ct + tag as SubtleCrypto expects them concatenated\n const combined = new Uint8Array(ct.byteLength + tag.byteLength);\n combined.set(new Uint8Array(ct), 0);\n combined.set(new Uint8Array(tag), ct.byteLength);\n\n const decrypted = await globalThis.crypto.subtle.decrypt(\n { name: 'AES-GCM', iv: new Uint8Array(iv) },\n sessionKey,\n combined,\n );\n\n return JSON.parse(new TextDecoder().decode(decrypted));\n}\n\nexport function isTransitEnvelope(v: unknown): v is TransitEnvelope {\n return (\n typeof v === 'object' &&\n v !== null &&\n (v as any).v === 1 &&\n typeof (v as any).iv === 'string' &&\n typeof (v as any).tag === 'string' &&\n typeof (v as any).ct === 'string'\n );\n}\n\n// ─── Helpers ─────────────────────────────────────────────────────────────────\n\nfunction bufToB64(buf: ArrayBuffer | Uint8Array): string {\n const bytes = buf instanceof Uint8Array ? buf : new Uint8Array(buf);\n let str = '';\n bytes.forEach(b => { str += String.fromCharCode(b); });\n return btoa(str);\n}\n\nfunction b64ToBuf(b64: string): ArrayBuffer {\n const bin = atob(b64);\n const buf = new Uint8Array(bin.length);\n for (let i = 0; i < bin.length; i++) buf[i] = bin.charCodeAt(i);\n return buf.buffer;\n}\n","// crypto.randomUUID() doesn't exist in React Native's Hermes engine.\n// Fall back to a RFC 4122 v4 UUID built from Math.random() when unavailable.\nexport function generateUUID(): string {\n if (typeof globalThis.crypto?.randomUUID === 'function') {\n return globalThis.crypto.randomUUID();\n }\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {\n const r = (Math.random() * 16) | 0;\n return (c === 'x' ? r : (r & 0x3) | 0x8).toString(16);\n });\n}\n","import type {\n BatchUploadResult,\n FileResponse,\n PaginatedResponse,\n PresignedUrlRequest,\n PresignedUrlResponse,\n FileType,\n UploadableFile,\n} from '../types/index.js';\nimport type { PlatformUploadFn, PlatformCompressFn, ResolvedCompressionConfig } from '../config/types.js';\nimport { compressFile } from '../compression/compress.js';\nimport { getApiClient } from './client.js';\nimport { generateUUID } from '../crypto/uuid.js';\n\nexport const storageApi = {\n async requestPresignedUrl(payload: PresignedUrlRequest): Promise<PresignedUrlResponse> {\n const { data } = await getApiClient().post<PresignedUrlResponse>('/storage/presigned-url', payload);\n return data;\n },\n\n async requestPresignedUrlBatch(files: PresignedUrlRequest[]): Promise<{\n urls: PresignedUrlResponse[];\n errors: Array<{ filename: string; error: string; clientIndex?: number }>;\n }> {\n const { data } = await getApiClient().post('/storage/presigned-url/batch', { files });\n return data;\n },\n\n async confirmUpload(fileId: string): Promise<FileResponse> {\n const { data } = await getApiClient().post<FileResponse>(`/storage/confirm/${fileId}`);\n return data;\n },\n\n async getFile(fileId: string): Promise<FileResponse> {\n const { data } = await getApiClient().get<FileResponse>(`/storage/files/${fileId}`);\n return data;\n },\n\n async getFileUrl(fileId: string, expiresIn?: number): Promise<{ url: string; expiresAt: string }> {\n const { data } = await getApiClient().get(`/storage/files/${fileId}/url`, {\n params: expiresIn ? { expiresIn } : {},\n });\n return data;\n },\n\n async deleteFile(fileId: string): Promise<void> {\n await getApiClient().post(`/storage/files/${fileId}/delete`);\n },\n\n async getConversationFiles(\n conversationId: string,\n params: { page?: number; limit?: number; type?: FileType } = {},\n ): Promise<PaginatedResponse<FileResponse>> {\n const { data } = await getApiClient().get(\n `/storage/conversations/${conversationId}/files`,\n { params },\n );\n return data;\n },\n\n async getMyFiles(params: { page?: number; limit?: number } = {}): Promise<PaginatedResponse<FileResponse>> {\n const { data } = await getApiClient().get('/storage/my-files', { params });\n return data;\n },\n};\n\n/**\n * High-level batch upload.\n * The actual binary transfer is delegated to platformUploadFn so this\n * function is platform-agnostic (works on web and React Native).\n * If platformCompressFn + compressionConfig are provided, each file is\n * compressed before the presigned URL is requested (so the server receives\n * the correct compressed size and MIME type).\n */\n/**\n * Core upload implementation. Returns the public BatchUploadResult plus a\n * slotId → FileResponse map that useChat hooks use internally to match\n * confirmed uploads back to optimistic UI slots by position rather than\n * filename. The slotToFile map is never part of the public API.\n */\nasync function runUploadBatch(\n files: UploadableFile[],\n platformUploadFn: PlatformUploadFn,\n slotIds: string[],\n conversationId?: string,\n onProgress?: (pct: number) => void,\n platformCompressFn?: PlatformCompressFn,\n compressionConfig?: ResolvedCompressionConfig,\n): Promise<{ result: BatchUploadResult; slotToFile: Map<string, FileResponse> }> {\n // Compress all files first (no-ops for unsupported types or when disabled)\n const compressedFiles = await Promise.all(\n files.map((f) => compressFile(f, platformCompressFn, compressionConfig ?? { enabled: false, imageQuality: 0.85, imageMaxDimension: 1920, compressDocuments: true })),\n );\n\n // Pair each compressed file with its slot ID and a clientIndex.\n // clientIndex is sent to the server and echoed back in both urls and errors,\n // giving us a reliable position mapping regardless of which files fail.\n const slotted = compressedFiles.map((f, i) => ({ file: f, slotId: slotIds[i], clientIndex: i }));\n\n const requests: PresignedUrlRequest[] = slotted.map(({ file: f, clientIndex }) => ({\n filename: f.name,\n mimeType: f.type,\n size: f.size,\n conversationId,\n clientIndex,\n ...(f.compressed && {\n metadata: {\n compressed: f.compressed,\n originalSize: f.originalSize,\n compressionAlgorithm: f.compressionAlgorithm,\n },\n }),\n }));\n\n const { urls, errors: requestErrors } = await storageApi.requestPresignedUrlBatch(requests);\n\n // Use the echoed clientIndex to identify which original slots failed.\n // This is reliable even for same-named files and any failure pattern.\n const failedSlotIds = new Set<string>();\n const failed: Array<{ filename: string; error: string }> = requestErrors.map((e) => {\n const idx = e.clientIndex ?? slotted.findIndex((s) => s.file.name === e.filename);\n const slotId = slotted[idx]?.slotId;\n if (slotId) failedSlotIds.add(slotId);\n return { filename: e.filename, error: e.error };\n });\n\n // Map each presigned URL back to its original slot via clientIndex.\n const progressMap: Record<number, number> = {};\n const reportProgress = () => {\n if (!onProgress) return;\n const vals = Object.values(progressMap);\n const avg = vals.reduce((s, v) => s + v, 0) / Math.max(vals.length, 1);\n onProgress(Math.round(avg));\n };\n\n const successful: FileResponse[] = [];\n const slotToFile = new Map<string, FileResponse>();\n\n await Promise.all(\n urls.map(async (presigned, idx) => {\n // Resolve the original slot via echoed clientIndex; fall back to position\n // in urls[] only if the server didn't echo it (older server version).\n const originalIdx = presigned.clientIndex ?? idx;\n const { file, slotId } = slotted[originalIdx];\n progressMap[originalIdx] = 0;\n try {\n await platformUploadFn(presigned, file, (pct) => {\n progressMap[originalIdx] = Math.round(pct * 0.9);\n reportProgress();\n });\n\n const fileResponse = await storageApi.confirmUpload(presigned.fileId);\n progressMap[originalIdx] = 100;\n reportProgress();\n successful.push(fileResponse);\n slotToFile.set(slotId, fileResponse);\n } catch (err) {\n failed.push({ filename: file.name, error: (err as Error).message });\n }\n }),\n );\n\n return { result: { successful, failed }, slotToFile };\n}\n\n/** Public API — returns standard BatchUploadResult, slot tracking is internal. */\nexport async function uploadBatch(\n files: UploadableFile[],\n platformUploadFn: PlatformUploadFn,\n conversationId?: string,\n onProgress?: (pct: number) => void,\n platformCompressFn?: PlatformCompressFn,\n compressionConfig?: ResolvedCompressionConfig,\n): Promise<BatchUploadResult> {\n const slotIds = files.map(() => generateUUID());\n const { result } = await runUploadBatch(files, platformUploadFn, slotIds, conversationId, onProgress, platformCompressFn, compressionConfig);\n return result;\n}\n\n/**\n * Used only by useChat hooks (web + RN) to get the slotId → FileResponse map\n * for matching confirmed uploads back to optimistic UI slots.\n * Not exported from the package index — internal SDK use only.\n */\nexport async function uploadBatchWithSlots(\n files: UploadableFile[],\n platformUploadFn: PlatformUploadFn,\n slotIds: string[],\n conversationId?: string,\n onProgress?: (pct: number) => void,\n platformCompressFn?: PlatformCompressFn,\n compressionConfig?: ResolvedCompressionConfig,\n): Promise<{ result: BatchUploadResult; slotToFile: Map<string, FileResponse> }> {\n return runUploadBatch(files, platformUploadFn, slotIds, conversationId, onProgress, platformCompressFn, compressionConfig);\n}\n"],"mappings":";AAIA,IAAM,kBAAkB,oBAAI,IAAI;AAAA,EAC9B;AAAA,EAAc;AAAA,EAAY;AAAA,EAAiB;AAAA,EAC3C;AAAA,EAAY;AAAA,EAAmB;AAAA,EAAa;AAAA,EAC5C;AAAA,EAAsB;AAAA,EA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