@antzsoft/chat-core 1.4.4 → 1.4.5
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/{chunk-XTQYF5HU.js → chunk-WUNH3UTE.js} +92 -22
- package/dist/chunk-WUNH3UTE.js.map +1 -0
- package/dist/index.cjs +189 -63
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -3
- package/dist/index.d.ts +9 -3
- package/dist/index.js +110 -45
- package/dist/index.js.map +1 -1
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.d.cts +1 -1
- package/dist/internal.d.ts +1 -1
- package/dist/internal.js +1 -1
- package/dist/{storage-C8V7aVum.d.cts → storage-DlxfLVqx.d.cts} +21 -1
- package/dist/{storage-C8V7aVum.d.ts → storage-DlxfLVqx.d.ts} +21 -1
- package/package.json +1 -1
- package/dist/chunk-XTQYF5HU.js.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { R as ResolvedCompressionConfig, L as LoginCredentials, A as AuthResponse, a as RegisterData, b as AuthTokens, U as User, C as CrossConversationSyncResponse, c as ConversationSyncResponse, d as AppConfig, S as SendMessagePayload, M as Message, e as CursorPaginatedResponse, f as MessageReactionsResponse, P as PaginatedResponse, g as MessageReceiptsResponse, h as ConversationListParams, i as Conversation, j as Participant, k as ConversationUnreadCount, l as UnreadSummary, m as UserPreferences, n as ResolvedConfig, F as ForwardMessagePayload, o as ForwardAckPayload, p as PersistStorage, q as PresignedUrlRequest, r as PresignedUrlResponse, s as FileResponse, t as CompletedPart, u as FileType, v as AntzChatConfig, w as UploadableFile, B as BatchUploadResult } from './storage-
|
|
2
|
-
export { x as Attachment, y as CompressedFile, z as CompressionAlgorithm, D as CompressionConfig, E as ConversationType, G as ConversationUpdatedEvent, H as FileSizeLimits, I as ForwardResultPayload, J as LastReaction, K as MENTION_ALL_ID, N as MessageAckEvent, O as MessageContent, Q as MessageDeletedEvent, T as MessageDeletedForMeEvent, V as MessageDeliveredEvent, W as MessageForwardReference, X as MessageMetadata, Y as MessageReaction, Z as MessageReceiptEntry, _ as MessageReplyReference, $ as MessageStarUpdatedEvent, a0 as MessageUpdatedEvent, a1 as MessagesDeliveredEvent, a2 as MultipartPartUrl, a3 as MultipartUploadInfo, a4 as NewMessageEvent, a5 as OptimisticAttachment, a6 as PlatformCompressFn, a7 as PlatformUploadFn, a8 as PlatformUploadPartFn, a9 as QuietHours, aa as ReactionGroup, ab as ReactionUpdatedEvent, ac as ReactionUser, ad as ReadReceiptEvent, ae as ReplyAttachmentSnapshot, af as ResolvedFileSizeLimits, ag as
|
|
1
|
+
import { R as ResolvedCompressionConfig, L as LoginCredentials, A as AuthResponse, a as RegisterData, b as AuthTokens, U as User, C as CrossConversationSyncResponse, c as ConversationSyncResponse, d as AppConfig, S as SendMessagePayload, M as Message, e as CursorPaginatedResponse, f as MessageReactionsResponse, P as PaginatedResponse, g as MessageReceiptsResponse, h as ConversationListParams, i as Conversation, j as Participant, k as ConversationUnreadCount, l as UnreadSummary, m as UserPreferences, n as ResolvedConfig, F as ForwardMessagePayload, o as ForwardAckPayload, p as PersistStorage, q as PresignedUrlRequest, r as PresignedUrlResponse, s as FileResponse, t as CompletedPart, u as FileType, v as AntzChatConfig, w as UploadableFile, B as BatchUploadResult } from './storage-DlxfLVqx.cjs';
|
|
2
|
+
export { x as Attachment, y as CompressedFile, z as CompressionAlgorithm, D as CompressionConfig, E as ConversationType, G as ConversationUpdatedEvent, H as FileSizeLimits, I as ForwardResultPayload, J as LastReaction, K as MENTION_ALL_ID, N as MessageAckEvent, O as MessageContent, Q as MessageDeletedEvent, T as MessageDeletedForMeEvent, V as MessageDeliveredEvent, W as MessageForwardReference, X as MessageMetadata, Y as MessageReaction, Z as MessageReceiptEntry, _ as MessageReplyReference, $ as MessageStarUpdatedEvent, a0 as MessageUpdatedEvent, a1 as MessagesDeliveredEvent, a2 as MultipartPartUrl, a3 as MultipartUploadInfo, a4 as NewMessageEvent, a5 as OptimisticAttachment, a6 as PlatformCompressFn, a7 as PlatformUploadFn, a8 as PlatformUploadPartFn, a9 as QuietHours, aa as ReactionGroup, ab as ReactionUpdatedEvent, ac as ReactionUser, ad as ReadReceiptEvent, ae as ReplyAttachmentSnapshot, af as ResolvedFileSizeLimits, ag as SendErrorContext, ah as SendMessageAttachment, ai as SyncDeletedForMe, aj as SyncDeliveredReceipt, ak as SyncParticipantChange, al as SyncReactionEntry, am as SyncReactions, an as SyncReadReceipt, ao as SyncStarEntry, ap as SystemMessageMetadata, aq as TypingIndicatorEvent, ar as UploadConfig, as as UploadProgress, at as UserStatusEvent, au as resolveConfig, av as storageApi, aw as uploadBatch } from './storage-DlxfLVqx.cjs';
|
|
3
3
|
import { AxiosInstance } from 'axios';
|
|
4
4
|
import { Socket } from 'socket.io-client';
|
|
5
5
|
import * as zustand_middleware from 'zustand/middleware';
|
|
@@ -325,6 +325,8 @@ type TokenStore = {
|
|
|
325
325
|
setTokens: (tokens: AuthTokens) => void;
|
|
326
326
|
clearTokens: () => void;
|
|
327
327
|
};
|
|
328
|
+
declare function setAuthReadyPromise(promise: Promise<unknown> | null): void;
|
|
329
|
+
declare function isApiClientConfigured(): boolean;
|
|
328
330
|
declare function initApiClient(config: ResolvedConfig, tokenStore: TokenStore): AxiosInstance;
|
|
329
331
|
declare function setApiClientInstance(instance: AxiosInstance): void;
|
|
330
332
|
declare function getApiClient(): AxiosInstance;
|
|
@@ -337,6 +339,10 @@ declare function getSocket(): Socket;
|
|
|
337
339
|
declare function tryGetSocket(): Socket | null;
|
|
338
340
|
declare function getSocketStatus(): SocketStatus;
|
|
339
341
|
declare function onSocketStatus(listener: StatusListener): () => void;
|
|
342
|
+
/** Drop all tracked rooms. Call on a genuine identity change (user/tenant
|
|
343
|
+
* switch) so the reconnect re-flush can't re-join the previous user's rooms.
|
|
344
|
+
* NOT called from disconnectSocket() — a token refresh is not an intent change. */
|
|
345
|
+
declare function resetTrackedRooms(): void;
|
|
340
346
|
declare function connectSocket(config: ResolvedConfig, getToken: () => string | null | undefined): Promise<Socket>;
|
|
341
347
|
declare function disconnectSocket(): void;
|
|
342
348
|
declare function reconnectSocket(token: string, userId?: string, tenantId?: string): void;
|
|
@@ -793,4 +799,4 @@ declare class AntzChatClient {
|
|
|
793
799
|
uploadIcon(conversationId: string, file: UploadableFile): Promise<Conversation>;
|
|
794
800
|
}
|
|
795
801
|
|
|
796
|
-
export { AntzChatAuthError, AntzChatClient, AntzChatConfig, AntzChatError, AntzChatNetworkError, AntzChatPermissionError, AntzChatServerError, AntzChatValidationError, AppConfig, AuthResponse, AuthTokens, BatchUploadResult, CompletedPart, Conversation, ConversationListParams, ConversationSyncResponse, ConversationUnreadCount, type CreateDirectData, type CreateGroupData, CrossConversationSyncResponse, CursorPaginatedResponse, FileResponse, FileType, ForwardAckPayload, ForwardMessagePayload, type ForwardResult, HIGHLY_FORWARDED_DEPTH_THRESHOLD, type LastReadEntry, type ListMessagesParams, LoginCredentials, MAX_FORWARD_TARGETS, type MentionPart, type MentionSegment, Message, MessageReactionsResponse, MessageReceiptsResponse, type MobileDeviceToken, PaginatedResponse, type ParsedMention, Participant, PersistStorage, PresignedUrlRequest, PresignedUrlResponse, RegisterData, type RegisterDeviceTokenPayload, ResolvedCompressionConfig, ResolvedConfig, type SearchParams, type SendData, SendMessagePayload, type SocketStatus, type StatusListener, type TokenStore, UnreadSummary, type UpdateConversationData, type UpdateProfilePayload, UploadableFile, User, UserPreferences, type WebPushDeviceToken, appConfigApi, authApi, buildMentionText, connectSocket, conversationsApi, createAuthStore, createRestTransitSession, decryptPayload, devicesApi, disconnectSocket, encryptPayload, extractMentionIds, fetchServerKeys, generateEphemeralKey, getApiClient, getAuthStore, getCompressionStrategy, getSessionId, getSessionKey, getSocket, getSocketStatus, initApiClient, initAuthStore, isMentionAll, isTransitEnvelope, messagesApi, normalizeAxiosError, normalizeConversation, onSocketStatus, parseMentions, performHandshake, reconnectSocket, refreshSocketAuth, renderMentionParts, resetAuthStore, resolveSystemMessageText, setApiClientInstance, setTransitSession, socketEmit, syncApi, tryGetSocket, useChatStore, usersApi };
|
|
802
|
+
export { AntzChatAuthError, AntzChatClient, AntzChatConfig, AntzChatError, AntzChatNetworkError, AntzChatPermissionError, AntzChatServerError, AntzChatValidationError, AppConfig, AuthResponse, AuthTokens, BatchUploadResult, CompletedPart, Conversation, ConversationListParams, ConversationSyncResponse, ConversationUnreadCount, type CreateDirectData, type CreateGroupData, CrossConversationSyncResponse, CursorPaginatedResponse, FileResponse, FileType, ForwardAckPayload, ForwardMessagePayload, type ForwardResult, HIGHLY_FORWARDED_DEPTH_THRESHOLD, type LastReadEntry, type ListMessagesParams, LoginCredentials, MAX_FORWARD_TARGETS, type MentionPart, type MentionSegment, Message, MessageReactionsResponse, MessageReceiptsResponse, type MobileDeviceToken, PaginatedResponse, type ParsedMention, Participant, PersistStorage, PresignedUrlRequest, PresignedUrlResponse, RegisterData, type RegisterDeviceTokenPayload, ResolvedCompressionConfig, ResolvedConfig, type SearchParams, type SendData, SendMessagePayload, type SocketStatus, type StatusListener, type TokenStore, UnreadSummary, type UpdateConversationData, type UpdateProfilePayload, UploadableFile, User, UserPreferences, type WebPushDeviceToken, appConfigApi, authApi, buildMentionText, connectSocket, conversationsApi, createAuthStore, createRestTransitSession, decryptPayload, devicesApi, disconnectSocket, encryptPayload, extractMentionIds, fetchServerKeys, generateEphemeralKey, getApiClient, getAuthStore, getCompressionStrategy, getSessionId, getSessionKey, getSocket, getSocketStatus, initApiClient, initAuthStore, isApiClientConfigured, isMentionAll, isTransitEnvelope, messagesApi, normalizeAxiosError, normalizeConversation, onSocketStatus, parseMentions, performHandshake, reconnectSocket, refreshSocketAuth, renderMentionParts, resetAuthStore, resetTrackedRooms, resolveSystemMessageText, setApiClientInstance, setAuthReadyPromise, setTransitSession, socketEmit, syncApi, tryGetSocket, useChatStore, usersApi };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { R as ResolvedCompressionConfig, L as LoginCredentials, A as AuthResponse, a as RegisterData, b as AuthTokens, U as User, C as CrossConversationSyncResponse, c as ConversationSyncResponse, d as AppConfig, S as SendMessagePayload, M as Message, e as CursorPaginatedResponse, f as MessageReactionsResponse, P as PaginatedResponse, g as MessageReceiptsResponse, h as ConversationListParams, i as Conversation, j as Participant, k as ConversationUnreadCount, l as UnreadSummary, m as UserPreferences, n as ResolvedConfig, F as ForwardMessagePayload, o as ForwardAckPayload, p as PersistStorage, q as PresignedUrlRequest, r as PresignedUrlResponse, s as FileResponse, t as CompletedPart, u as FileType, v as AntzChatConfig, w as UploadableFile, B as BatchUploadResult } from './storage-
|
|
2
|
-
export { x as Attachment, y as CompressedFile, z as CompressionAlgorithm, D as CompressionConfig, E as ConversationType, G as ConversationUpdatedEvent, H as FileSizeLimits, I as ForwardResultPayload, J as LastReaction, K as MENTION_ALL_ID, N as MessageAckEvent, O as MessageContent, Q as MessageDeletedEvent, T as MessageDeletedForMeEvent, V as MessageDeliveredEvent, W as MessageForwardReference, X as MessageMetadata, Y as MessageReaction, Z as MessageReceiptEntry, _ as MessageReplyReference, $ as MessageStarUpdatedEvent, a0 as MessageUpdatedEvent, a1 as MessagesDeliveredEvent, a2 as MultipartPartUrl, a3 as MultipartUploadInfo, a4 as NewMessageEvent, a5 as OptimisticAttachment, a6 as PlatformCompressFn, a7 as PlatformUploadFn, a8 as PlatformUploadPartFn, a9 as QuietHours, aa as ReactionGroup, ab as ReactionUpdatedEvent, ac as ReactionUser, ad as ReadReceiptEvent, ae as ReplyAttachmentSnapshot, af as ResolvedFileSizeLimits, ag as
|
|
1
|
+
import { R as ResolvedCompressionConfig, L as LoginCredentials, A as AuthResponse, a as RegisterData, b as AuthTokens, U as User, C as CrossConversationSyncResponse, c as ConversationSyncResponse, d as AppConfig, S as SendMessagePayload, M as Message, e as CursorPaginatedResponse, f as MessageReactionsResponse, P as PaginatedResponse, g as MessageReceiptsResponse, h as ConversationListParams, i as Conversation, j as Participant, k as ConversationUnreadCount, l as UnreadSummary, m as UserPreferences, n as ResolvedConfig, F as ForwardMessagePayload, o as ForwardAckPayload, p as PersistStorage, q as PresignedUrlRequest, r as PresignedUrlResponse, s as FileResponse, t as CompletedPart, u as FileType, v as AntzChatConfig, w as UploadableFile, B as BatchUploadResult } from './storage-DlxfLVqx.js';
|
|
2
|
+
export { x as Attachment, y as CompressedFile, z as CompressionAlgorithm, D as CompressionConfig, E as ConversationType, G as ConversationUpdatedEvent, H as FileSizeLimits, I as ForwardResultPayload, J as LastReaction, K as MENTION_ALL_ID, N as MessageAckEvent, O as MessageContent, Q as MessageDeletedEvent, T as MessageDeletedForMeEvent, V as MessageDeliveredEvent, W as MessageForwardReference, X as MessageMetadata, Y as MessageReaction, Z as MessageReceiptEntry, _ as MessageReplyReference, $ as MessageStarUpdatedEvent, a0 as MessageUpdatedEvent, a1 as MessagesDeliveredEvent, a2 as MultipartPartUrl, a3 as MultipartUploadInfo, a4 as NewMessageEvent, a5 as OptimisticAttachment, a6 as PlatformCompressFn, a7 as PlatformUploadFn, a8 as PlatformUploadPartFn, a9 as QuietHours, aa as ReactionGroup, ab as ReactionUpdatedEvent, ac as ReactionUser, ad as ReadReceiptEvent, ae as ReplyAttachmentSnapshot, af as ResolvedFileSizeLimits, ag as SendErrorContext, ah as SendMessageAttachment, ai as SyncDeletedForMe, aj as SyncDeliveredReceipt, ak as SyncParticipantChange, al as SyncReactionEntry, am as SyncReactions, an as SyncReadReceipt, ao as SyncStarEntry, ap as SystemMessageMetadata, aq as TypingIndicatorEvent, ar as UploadConfig, as as UploadProgress, at as UserStatusEvent, au as resolveConfig, av as storageApi, aw as uploadBatch } from './storage-DlxfLVqx.js';
|
|
3
3
|
import { AxiosInstance } from 'axios';
|
|
4
4
|
import { Socket } from 'socket.io-client';
|
|
5
5
|
import * as zustand_middleware from 'zustand/middleware';
|
|
@@ -325,6 +325,8 @@ type TokenStore = {
|
|
|
325
325
|
setTokens: (tokens: AuthTokens) => void;
|
|
326
326
|
clearTokens: () => void;
|
|
327
327
|
};
|
|
328
|
+
declare function setAuthReadyPromise(promise: Promise<unknown> | null): void;
|
|
329
|
+
declare function isApiClientConfigured(): boolean;
|
|
328
330
|
declare function initApiClient(config: ResolvedConfig, tokenStore: TokenStore): AxiosInstance;
|
|
329
331
|
declare function setApiClientInstance(instance: AxiosInstance): void;
|
|
330
332
|
declare function getApiClient(): AxiosInstance;
|
|
@@ -337,6 +339,10 @@ declare function getSocket(): Socket;
|
|
|
337
339
|
declare function tryGetSocket(): Socket | null;
|
|
338
340
|
declare function getSocketStatus(): SocketStatus;
|
|
339
341
|
declare function onSocketStatus(listener: StatusListener): () => void;
|
|
342
|
+
/** Drop all tracked rooms. Call on a genuine identity change (user/tenant
|
|
343
|
+
* switch) so the reconnect re-flush can't re-join the previous user's rooms.
|
|
344
|
+
* NOT called from disconnectSocket() — a token refresh is not an intent change. */
|
|
345
|
+
declare function resetTrackedRooms(): void;
|
|
340
346
|
declare function connectSocket(config: ResolvedConfig, getToken: () => string | null | undefined): Promise<Socket>;
|
|
341
347
|
declare function disconnectSocket(): void;
|
|
342
348
|
declare function reconnectSocket(token: string, userId?: string, tenantId?: string): void;
|
|
@@ -793,4 +799,4 @@ declare class AntzChatClient {
|
|
|
793
799
|
uploadIcon(conversationId: string, file: UploadableFile): Promise<Conversation>;
|
|
794
800
|
}
|
|
795
801
|
|
|
796
|
-
export { AntzChatAuthError, AntzChatClient, AntzChatConfig, AntzChatError, AntzChatNetworkError, AntzChatPermissionError, AntzChatServerError, AntzChatValidationError, AppConfig, AuthResponse, AuthTokens, BatchUploadResult, CompletedPart, Conversation, ConversationListParams, ConversationSyncResponse, ConversationUnreadCount, type CreateDirectData, type CreateGroupData, CrossConversationSyncResponse, CursorPaginatedResponse, FileResponse, FileType, ForwardAckPayload, ForwardMessagePayload, type ForwardResult, HIGHLY_FORWARDED_DEPTH_THRESHOLD, type LastReadEntry, type ListMessagesParams, LoginCredentials, MAX_FORWARD_TARGETS, type MentionPart, type MentionSegment, Message, MessageReactionsResponse, MessageReceiptsResponse, type MobileDeviceToken, PaginatedResponse, type ParsedMention, Participant, PersistStorage, PresignedUrlRequest, PresignedUrlResponse, RegisterData, type RegisterDeviceTokenPayload, ResolvedCompressionConfig, ResolvedConfig, type SearchParams, type SendData, SendMessagePayload, type SocketStatus, type StatusListener, type TokenStore, UnreadSummary, type UpdateConversationData, type UpdateProfilePayload, UploadableFile, User, UserPreferences, type WebPushDeviceToken, appConfigApi, authApi, buildMentionText, connectSocket, conversationsApi, createAuthStore, createRestTransitSession, decryptPayload, devicesApi, disconnectSocket, encryptPayload, extractMentionIds, fetchServerKeys, generateEphemeralKey, getApiClient, getAuthStore, getCompressionStrategy, getSessionId, getSessionKey, getSocket, getSocketStatus, initApiClient, initAuthStore, isMentionAll, isTransitEnvelope, messagesApi, normalizeAxiosError, normalizeConversation, onSocketStatus, parseMentions, performHandshake, reconnectSocket, refreshSocketAuth, renderMentionParts, resetAuthStore, resolveSystemMessageText, setApiClientInstance, setTransitSession, socketEmit, syncApi, tryGetSocket, useChatStore, usersApi };
|
|
802
|
+
export { AntzChatAuthError, AntzChatClient, AntzChatConfig, AntzChatError, AntzChatNetworkError, AntzChatPermissionError, AntzChatServerError, AntzChatValidationError, AppConfig, AuthResponse, AuthTokens, BatchUploadResult, CompletedPart, Conversation, ConversationListParams, ConversationSyncResponse, ConversationUnreadCount, type CreateDirectData, type CreateGroupData, CrossConversationSyncResponse, CursorPaginatedResponse, FileResponse, FileType, ForwardAckPayload, ForwardMessagePayload, type ForwardResult, HIGHLY_FORWARDED_DEPTH_THRESHOLD, type LastReadEntry, type ListMessagesParams, LoginCredentials, MAX_FORWARD_TARGETS, type MentionPart, type MentionSegment, Message, MessageReactionsResponse, MessageReceiptsResponse, type MobileDeviceToken, PaginatedResponse, type ParsedMention, Participant, PersistStorage, PresignedUrlRequest, PresignedUrlResponse, RegisterData, type RegisterDeviceTokenPayload, ResolvedCompressionConfig, ResolvedConfig, type SearchParams, type SendData, SendMessagePayload, type SocketStatus, type StatusListener, type TokenStore, UnreadSummary, type UpdateConversationData, type UpdateProfilePayload, UploadableFile, User, UserPreferences, type WebPushDeviceToken, appConfigApi, authApi, buildMentionText, connectSocket, conversationsApi, createAuthStore, createRestTransitSession, decryptPayload, devicesApi, disconnectSocket, encryptPayload, extractMentionIds, fetchServerKeys, generateEphemeralKey, getApiClient, getAuthStore, getCompressionStrategy, getSessionId, getSessionKey, getSocket, getSocketStatus, initApiClient, initAuthStore, isApiClientConfigured, isMentionAll, isTransitEnvelope, messagesApi, normalizeAxiosError, normalizeConversation, onSocketStatus, parseMentions, performHandshake, reconnectSocket, refreshSocketAuth, renderMentionParts, resetAuthStore, resetTrackedRooms, resolveSystemMessageText, setApiClientInstance, setAuthReadyPromise, setTransitSession, socketEmit, syncApi, tryGetSocket, useChatStore, usersApi };
|
package/dist/index.js
CHANGED
|
@@ -5,12 +5,14 @@ import {
|
|
|
5
5
|
AntzChatPermissionError,
|
|
6
6
|
AntzChatServerError,
|
|
7
7
|
AntzChatValidationError,
|
|
8
|
+
awaitTransitReadyOr,
|
|
8
9
|
clearTransitSession,
|
|
9
|
-
|
|
10
|
+
configureTransitIfUnset,
|
|
10
11
|
createRestTransitSession,
|
|
11
12
|
decryptPayload,
|
|
12
13
|
detectTransitAlgo,
|
|
13
14
|
encryptPayload,
|
|
15
|
+
ensureRestTransitHandshake,
|
|
14
16
|
fetchServerKeys,
|
|
15
17
|
generateEphemeralKey,
|
|
16
18
|
generateUUID,
|
|
@@ -21,16 +23,20 @@ import {
|
|
|
21
23
|
getTransitHandshakePromise,
|
|
22
24
|
getTransitSession,
|
|
23
25
|
initApiClient,
|
|
26
|
+
isApiClientConfigured,
|
|
24
27
|
isTransitEnabled,
|
|
25
28
|
isTransitEnvelope,
|
|
29
|
+
isTransitRequired,
|
|
26
30
|
normalizeAxiosError,
|
|
31
|
+
onTransitReady,
|
|
27
32
|
performHandshake,
|
|
28
33
|
resetAlgoCache,
|
|
29
34
|
setApiClientInstance,
|
|
35
|
+
setAuthReadyPromise,
|
|
30
36
|
setTransitSession,
|
|
31
37
|
storageApi,
|
|
32
38
|
uploadBatch
|
|
33
|
-
} from "./chunk-
|
|
39
|
+
} from "./chunk-WUNH3UTE.js";
|
|
34
40
|
import {
|
|
35
41
|
useChatStore
|
|
36
42
|
} from "./chunk-UIYJAOGL.js";
|
|
@@ -89,6 +95,7 @@ function resolveConfig(config) {
|
|
|
89
95
|
compressDocuments: config.compression?.compressDocuments ?? true
|
|
90
96
|
},
|
|
91
97
|
persistStorage: config.persistStorage,
|
|
98
|
+
onSendError: config.onSendError,
|
|
92
99
|
messagePageSize: config.messagePageSize ?? 40,
|
|
93
100
|
starredMessagePageSize: config.starredMessagePageSize ?? 30,
|
|
94
101
|
searchPageSize: config.searchPageSize ?? 50
|
|
@@ -311,7 +318,6 @@ var _getToken = null;
|
|
|
311
318
|
var _userId;
|
|
312
319
|
var _tenantId;
|
|
313
320
|
var _config = null;
|
|
314
|
-
var _preservingSession = false;
|
|
315
321
|
function setStatus(s) {
|
|
316
322
|
_status = s;
|
|
317
323
|
_statusListeners.forEach((l) => l(s));
|
|
@@ -330,29 +336,48 @@ function onSocketStatus(listener) {
|
|
|
330
336
|
_statusListeners.add(listener);
|
|
331
337
|
return () => _statusListeners.delete(listener);
|
|
332
338
|
}
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
ack(decrypted);
|
|
344
|
-
} catch {
|
|
345
|
-
ack(encryptedResponse);
|
|
346
|
-
}
|
|
347
|
-
} else {
|
|
348
|
-
ack(encryptedResponse);
|
|
349
|
-
}
|
|
350
|
-
});
|
|
339
|
+
var SECURE_EMIT_WAIT_MS = 4e3;
|
|
340
|
+
function emitEncrypted(socket, event, envelope, key, ack) {
|
|
341
|
+
if (ack) {
|
|
342
|
+
socket.emit(event, envelope, async (encryptedResponse) => {
|
|
343
|
+
if (isTransitEnvelope(encryptedResponse)) {
|
|
344
|
+
try {
|
|
345
|
+
ack(await decryptPayload(encryptedResponse, key));
|
|
346
|
+
} catch {
|
|
347
|
+
ack(encryptedResponse);
|
|
348
|
+
}
|
|
351
349
|
} else {
|
|
352
|
-
|
|
350
|
+
ack(encryptedResponse);
|
|
353
351
|
}
|
|
352
|
+
});
|
|
353
|
+
} else {
|
|
354
|
+
socket.emit(event, envelope);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
async function secureEmit(socket, event, payload, ack) {
|
|
358
|
+
let key = getSessionKey();
|
|
359
|
+
if (key && isTransitEnabled()) {
|
|
360
|
+
emitEncrypted(socket, event, await encryptPayload(payload, key), key, ack);
|
|
361
|
+
return;
|
|
362
|
+
}
|
|
363
|
+
if (isTransitRequired()) {
|
|
364
|
+
try {
|
|
365
|
+
ensureRestTransitHandshake();
|
|
366
|
+
} catch {
|
|
367
|
+
}
|
|
368
|
+
const ok = await awaitTransitReadyOr(SECURE_EMIT_WAIT_MS);
|
|
369
|
+
key = getSessionKey();
|
|
370
|
+
if (ok && key && isTransitEnabled()) {
|
|
371
|
+
emitEncrypted(socket, event, await encryptPayload(payload, key), key, ack);
|
|
354
372
|
return;
|
|
355
373
|
}
|
|
374
|
+
if (isTransitRequired()) {
|
|
375
|
+
throw new AntzChatNetworkError(
|
|
376
|
+
`Transit encryption required but no session established \u2014 "${event}" not sent`,
|
|
377
|
+
"TRANSIT_NOT_READY",
|
|
378
|
+
{ event }
|
|
379
|
+
);
|
|
380
|
+
}
|
|
356
381
|
}
|
|
357
382
|
if (ack) {
|
|
358
383
|
socket.emit(event, payload, ack);
|
|
@@ -378,6 +403,28 @@ function secureOn(socket, event, handler) {
|
|
|
378
403
|
handler(raw);
|
|
379
404
|
});
|
|
380
405
|
}
|
|
406
|
+
var _joinedRooms = /* @__PURE__ */ new Set();
|
|
407
|
+
function trackRoomJoin(conversationId) {
|
|
408
|
+
_joinedRooms.add(conversationId);
|
|
409
|
+
}
|
|
410
|
+
function trackRoomLeave(conversationId) {
|
|
411
|
+
_joinedRooms.delete(conversationId);
|
|
412
|
+
}
|
|
413
|
+
function resetTrackedRooms() {
|
|
414
|
+
_joinedRooms.clear();
|
|
415
|
+
}
|
|
416
|
+
function flushJoinedRooms() {
|
|
417
|
+
const socket = tryGetSocket();
|
|
418
|
+
if (!socket || _joinedRooms.size === 0) return;
|
|
419
|
+
for (const conversationId of _joinedRooms) {
|
|
420
|
+
void secureEmit(socket, "join_room", { conversationId }).catch(() => {
|
|
421
|
+
});
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
onTransitReady(flushJoinedRooms);
|
|
425
|
+
onSocketStatus((status) => {
|
|
426
|
+
if (status === "connected") flushJoinedRooms();
|
|
427
|
+
});
|
|
381
428
|
async function connectSocket(config, getToken) {
|
|
382
429
|
if (_socket && !_socket.disconnected) return _socket;
|
|
383
430
|
if (_connectingPromise) return _connectingPromise;
|
|
@@ -399,6 +446,7 @@ async function _doConnect(config, getToken) {
|
|
|
399
446
|
...config.avatar?.url && { avatarUrl: config.avatar.url },
|
|
400
447
|
...config.avatar?.base64 && { avatarBase64: config.avatar.base64 }
|
|
401
448
|
};
|
|
449
|
+
configureTransitIfUnset(config.transitEncryption);
|
|
402
450
|
let boundDeriveSessionKey = null;
|
|
403
451
|
if (config.transitEncryption) {
|
|
404
452
|
const inFlight = getTransitHandshakePromise();
|
|
@@ -463,7 +511,6 @@ async function _doConnect(config, getToken) {
|
|
|
463
511
|
_socket.on("connect", () => setStatus("connected"));
|
|
464
512
|
_socket.on("disconnect", () => {
|
|
465
513
|
setStatus("disconnected");
|
|
466
|
-
if (!_preservingSession) clearTransitSession();
|
|
467
514
|
});
|
|
468
515
|
_socket.on("connect_error", (err) => {
|
|
469
516
|
console.error("[AntzChat] Socket connect_error:", err?.message, err?.data);
|
|
@@ -478,8 +525,9 @@ async function _doConnect(config, getToken) {
|
|
|
478
525
|
resolve();
|
|
479
526
|
};
|
|
480
527
|
const timeout = setTimeout(() => {
|
|
481
|
-
console.
|
|
482
|
-
|
|
528
|
+
console.error(
|
|
529
|
+
"[AntzChat] transit_session did not arrive within 5s. Transit stays REQUIRED \u2014 chat requests are gated (not downgraded to plaintext) until the handshake succeeds via REST retry or socket reconnect. Persistent failure = check POST /crypto/session (rate limit / 5xx) and the socket transit middleware."
|
|
530
|
+
);
|
|
483
531
|
done();
|
|
484
532
|
}, 5e3);
|
|
485
533
|
_socket.on("transit_session", async ({ sessionId }) => {
|
|
@@ -566,13 +614,8 @@ function reconnectSocket(token, userId, tenantId) {
|
|
|
566
614
|
...tenantId && { tenantId },
|
|
567
615
|
transitSessionId: existing.sessionId
|
|
568
616
|
};
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
if (_socket.connected) _socket.disconnect();
|
|
572
|
-
_socket.connect();
|
|
573
|
-
} finally {
|
|
574
|
-
_preservingSession = false;
|
|
575
|
-
}
|
|
617
|
+
if (_socket.connected) _socket.disconnect();
|
|
618
|
+
_socket.connect();
|
|
576
619
|
return;
|
|
577
620
|
}
|
|
578
621
|
if (_getToken) {
|
|
@@ -617,7 +660,15 @@ async function drainSendQueue(conversationId) {
|
|
|
617
660
|
entry.reject(new AntzChatNetworkError("Message dropped: queued too long", "MESSAGE_DROPPED"));
|
|
618
661
|
continue;
|
|
619
662
|
}
|
|
620
|
-
|
|
663
|
+
let acked;
|
|
664
|
+
try {
|
|
665
|
+
({ acked } = await emitWithAck("send_message", entry.payload));
|
|
666
|
+
} catch (err) {
|
|
667
|
+
entry.reject(err);
|
|
668
|
+
while (queue.length > 0) queue.shift().reject(err);
|
|
669
|
+
break;
|
|
670
|
+
}
|
|
671
|
+
acked.then(entry.resolve).catch(entry.reject);
|
|
621
672
|
}
|
|
622
673
|
sendQueues.delete(conversationId);
|
|
623
674
|
sendQueueRunning.delete(conversationId);
|
|
@@ -630,7 +681,7 @@ function queueSendMessage(payload) {
|
|
|
630
681
|
return Promise.reject(new AntzChatNetworkError("Send queue full: too many messages in flight", "SEND_QUEUE_FULL", { conversationId }));
|
|
631
682
|
}
|
|
632
683
|
return new Promise((resolve, reject) => {
|
|
633
|
-
queue.push({
|
|
684
|
+
queue.push({ payload, resolve, reject, enqueuedAt: Date.now() });
|
|
634
685
|
drainSendQueue(conversationId);
|
|
635
686
|
});
|
|
636
687
|
}
|
|
@@ -653,33 +704,44 @@ function waitForReconnect() {
|
|
|
653
704
|
});
|
|
654
705
|
});
|
|
655
706
|
}
|
|
656
|
-
async function
|
|
707
|
+
async function emitWithAck(event, payload) {
|
|
657
708
|
let socket = tryGetSocket();
|
|
658
709
|
if (!socket) {
|
|
659
710
|
await waitForReconnect();
|
|
660
711
|
socket = tryGetSocket();
|
|
661
712
|
}
|
|
662
|
-
if (!socket)
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
}).then(() => {
|
|
669
|
-
timer = setTimeout(() => reject(new AntzChatNetworkError(`Socket ack timeout: ${event}`, "SOCKET_TIMEOUT", { event })), ACK_TIMEOUT);
|
|
670
|
-
}).catch(reject);
|
|
713
|
+
if (!socket) throw new AntzChatNetworkError(`Socket not connected (event: ${event})`, "SOCKET_NOT_CONNECTED", { event });
|
|
714
|
+
let resolveAck;
|
|
715
|
+
let rejectAck;
|
|
716
|
+
const acked = new Promise((res, rej) => {
|
|
717
|
+
resolveAck = res;
|
|
718
|
+
rejectAck = rej;
|
|
671
719
|
});
|
|
720
|
+
await secureEmit(socket, event, payload, (response) => resolveAck(response));
|
|
721
|
+
const timer = setTimeout(
|
|
722
|
+
() => rejectAck(new AntzChatNetworkError(`Socket ack timeout: ${event}`, "SOCKET_TIMEOUT", { event })),
|
|
723
|
+
ACK_TIMEOUT
|
|
724
|
+
);
|
|
725
|
+
void acked.then(() => clearTimeout(timer), () => clearTimeout(timer));
|
|
726
|
+
return { acked };
|
|
727
|
+
}
|
|
728
|
+
async function withAck(event, payload) {
|
|
729
|
+
const { acked } = await emitWithAck(event, payload);
|
|
730
|
+
return acked;
|
|
672
731
|
}
|
|
673
732
|
function fireAndForget(event, payload) {
|
|
674
733
|
const socket = tryGetSocket();
|
|
675
734
|
if (!socket) return;
|
|
676
|
-
secureEmit(socket, event, payload)
|
|
735
|
+
secureEmit(socket, event, payload).catch(() => {
|
|
736
|
+
});
|
|
677
737
|
}
|
|
678
738
|
var socketEmit = {
|
|
679
739
|
joinRoom(conversationId) {
|
|
740
|
+
trackRoomJoin(conversationId);
|
|
680
741
|
fireAndForget("join_room", { conversationId });
|
|
681
742
|
},
|
|
682
743
|
leaveRoom(conversationId) {
|
|
744
|
+
trackRoomLeave(conversationId);
|
|
683
745
|
fireAndForget("leave_room", { conversationId });
|
|
684
746
|
},
|
|
685
747
|
sendMessage(payload) {
|
|
@@ -1292,6 +1354,7 @@ export {
|
|
|
1292
1354
|
getSocketStatus,
|
|
1293
1355
|
initApiClient,
|
|
1294
1356
|
initAuthStore,
|
|
1357
|
+
isApiClientConfigured,
|
|
1295
1358
|
isMentionAll,
|
|
1296
1359
|
isTransitEnvelope,
|
|
1297
1360
|
messagesApi,
|
|
@@ -1304,9 +1367,11 @@ export {
|
|
|
1304
1367
|
refreshSocketAuth,
|
|
1305
1368
|
renderMentionParts,
|
|
1306
1369
|
resetAuthStore,
|
|
1370
|
+
resetTrackedRooms,
|
|
1307
1371
|
resolveConfig,
|
|
1308
1372
|
resolveSystemMessageText,
|
|
1309
1373
|
setApiClientInstance,
|
|
1374
|
+
setAuthReadyPromise,
|
|
1310
1375
|
setTransitSession,
|
|
1311
1376
|
socketEmit,
|
|
1312
1377
|
storageApi,
|