@antzsoft/chat-core 1.1.1 → 1.1.2
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 +22 -14
- package/dist/index.cjs +379 -27
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +22 -29
- package/dist/index.d.ts +22 -29
- package/dist/index.js +378 -27
- package/dist/index.js.map +1 -1
- package/docs/integration-guide.html +168 -6
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -3,7 +3,6 @@ import { Socket } from 'socket.io-client';
|
|
|
3
3
|
import * as zustand_middleware from 'zustand/middleware';
|
|
4
4
|
import * as zustand from 'zustand';
|
|
5
5
|
|
|
6
|
-
type EncryptionMode = 'none' | 'server' | 'e2ee';
|
|
7
6
|
type FileType = 'image' | 'video' | 'audio' | 'document';
|
|
8
7
|
type ConversationType = 'direct' | 'group';
|
|
9
8
|
type MessageStatus = 'sent' | 'delivered' | 'read' | 'failed' | 'deleted';
|
|
@@ -79,17 +78,6 @@ interface Attachment {
|
|
|
79
78
|
isUploading?: boolean;
|
|
80
79
|
uploadProgress?: number;
|
|
81
80
|
}
|
|
82
|
-
interface EncryptedContent {
|
|
83
|
-
ciphertext: string;
|
|
84
|
-
iv: string;
|
|
85
|
-
tag: string;
|
|
86
|
-
algorithm: 'aes-256-gcm';
|
|
87
|
-
}
|
|
88
|
-
interface EncryptionKeyInfo {
|
|
89
|
-
key: string;
|
|
90
|
-
enabled: boolean;
|
|
91
|
-
mode: EncryptionMode;
|
|
92
|
-
}
|
|
93
81
|
interface MessageReaction {
|
|
94
82
|
emoji: string;
|
|
95
83
|
userIds: string[];
|
|
@@ -149,9 +137,6 @@ interface Message {
|
|
|
149
137
|
userId: string;
|
|
150
138
|
deliveredAt: string;
|
|
151
139
|
}>;
|
|
152
|
-
isEncrypted?: boolean;
|
|
153
|
-
encryptionMode?: EncryptionMode;
|
|
154
|
-
encryptedContent?: EncryptedContent;
|
|
155
140
|
}
|
|
156
141
|
interface Participant {
|
|
157
142
|
userId: string;
|
|
@@ -188,9 +173,6 @@ interface Conversation {
|
|
|
188
173
|
isPinned?: boolean;
|
|
189
174
|
isMuted?: boolean;
|
|
190
175
|
mutedUntil?: string;
|
|
191
|
-
encryptionMode?: EncryptionMode;
|
|
192
|
-
isEncryptionEnabled?: boolean;
|
|
193
|
-
encryptionKey?: string;
|
|
194
176
|
}
|
|
195
177
|
interface AppConfig {
|
|
196
178
|
maxPinnedConversations: number;
|
|
@@ -260,6 +242,7 @@ interface PresignedUrlRequest {
|
|
|
260
242
|
size: number;
|
|
261
243
|
conversationId?: string;
|
|
262
244
|
folder?: string;
|
|
245
|
+
metadata?: Record<string, unknown>;
|
|
263
246
|
}
|
|
264
247
|
interface PresignedUrlResponse {
|
|
265
248
|
fileId: string;
|
|
@@ -388,8 +371,6 @@ interface SendMessagePayload {
|
|
|
388
371
|
attachments?: SendMessageAttachment[];
|
|
389
372
|
replyTo?: string;
|
|
390
373
|
tempId: string;
|
|
391
|
-
encryptedContent?: EncryptedContent;
|
|
392
|
-
isEncrypted?: boolean;
|
|
393
374
|
}
|
|
394
375
|
interface QuietHours {
|
|
395
376
|
enabled: boolean;
|
|
@@ -522,8 +503,14 @@ interface AntzChatConfig {
|
|
|
522
503
|
};
|
|
523
504
|
/** Required for multi-tenant backends. Sent as X-Tenant-ID header. */
|
|
524
505
|
tenantId?: string;
|
|
525
|
-
/**
|
|
526
|
-
|
|
506
|
+
/**
|
|
507
|
+
* Enable payload-level transit encryption (ECDH key exchange + AES-256-GCM).
|
|
508
|
+
* Encrypts every HTTP request/response body and every socket event payload.
|
|
509
|
+
* Server must have TRANSIT_ENCRYPTION_ENABLED=true to match.
|
|
510
|
+
* Default: true — set false only for local development/debugging.
|
|
511
|
+
* Safe to toggle anytime — no data migration needed (wire-only, never affects storage).
|
|
512
|
+
*/
|
|
513
|
+
transitEncryption?: boolean;
|
|
527
514
|
upload?: UploadConfig;
|
|
528
515
|
/**
|
|
529
516
|
* Optional compression config. Compression is disabled if platformCompressFn is not provided.
|
|
@@ -580,7 +567,7 @@ interface ResolvedConfig {
|
|
|
580
567
|
url?: string;
|
|
581
568
|
base64?: string;
|
|
582
569
|
};
|
|
583
|
-
|
|
570
|
+
transitEncryption: boolean;
|
|
584
571
|
upload: {
|
|
585
572
|
maxFileSizeMB: ResolvedFileSizeLimits;
|
|
586
573
|
maxFilesPerMessage: number;
|
|
@@ -639,7 +626,6 @@ interface SendData {
|
|
|
639
626
|
attachments?: SendMessagePayload['attachments'];
|
|
640
627
|
replyTo?: string;
|
|
641
628
|
tempId?: string;
|
|
642
|
-
isEncrypted?: boolean;
|
|
643
629
|
}
|
|
644
630
|
declare const messagesApi: {
|
|
645
631
|
list(conversationId: string, params?: ListMessagesParams): Promise<CursorPaginatedResponse<Message>>;
|
|
@@ -852,10 +838,7 @@ declare function disconnectSocket(): void;
|
|
|
852
838
|
declare function reconnectSocket(token: string, userId?: string, tenantId?: string): void;
|
|
853
839
|
/**
|
|
854
840
|
* Updates the socket auth token from the stored getToken function and reconnects.
|
|
855
|
-
* Called by SocketProvider on connect_error to handle expired-token scenarios
|
|
856
|
-
* 1. Token expired while disconnected → server rejects the reconnect handshake
|
|
857
|
-
* 2. authProvider returns a fresh token → we update socket auth and retry
|
|
858
|
-
*
|
|
841
|
+
* Called by SocketProvider on connect_error to handle expired-token scenarios.
|
|
859
842
|
* Returns true if the token was updated, false if no token source is available.
|
|
860
843
|
*/
|
|
861
844
|
declare function refreshSocketAuth(): boolean;
|
|
@@ -877,6 +860,16 @@ declare const socketEmit: {
|
|
|
877
860
|
getTypingUsers(conversationId: string): Promise<unknown>;
|
|
878
861
|
};
|
|
879
862
|
|
|
863
|
+
type TransitAlgo = 'x25519' | 'p256';
|
|
864
|
+
|
|
865
|
+
interface TransitSession {
|
|
866
|
+
sessionKey: CryptoKey;
|
|
867
|
+
algo: TransitAlgo;
|
|
868
|
+
sessionId: string;
|
|
869
|
+
enabled: boolean;
|
|
870
|
+
}
|
|
871
|
+
declare function setTransitSession(session: TransitSession): void;
|
|
872
|
+
|
|
880
873
|
interface AuthState {
|
|
881
874
|
user: User | null;
|
|
882
875
|
tokens: AuthTokens | null;
|
|
@@ -1135,4 +1128,4 @@ declare class AntzChatClient {
|
|
|
1135
1128
|
uploadIcon(conversationId: string, file: UploadableFile): Promise<Conversation>;
|
|
1136
1129
|
}
|
|
1137
1130
|
|
|
1138
|
-
export { AntzChatClient, type AntzChatConfig, type AppConfig, type Attachment, type AuthResponse, type AuthTokens, type BatchUploadResult, type CompressedFile, type CompressionAlgorithm, type CompressionConfig, type Conversation, type ConversationListParams, type ConversationUnreadCount, type CreateDirectData, type CreateGroupData, type CursorPaginatedResponse, type
|
|
1131
|
+
export { AntzChatClient, type AntzChatConfig, type AppConfig, type Attachment, type AuthResponse, type AuthTokens, type BatchUploadResult, type CompressedFile, type CompressionAlgorithm, type CompressionConfig, type Conversation, type ConversationListParams, type ConversationUnreadCount, type CreateDirectData, type CreateGroupData, type CursorPaginatedResponse, type FileResponse, type FileSizeLimits, type FileType, type LastReadEntry, type ListMessagesParams, type LoginCredentials, type Message, type MessageAckEvent, type MessageContent, type MessageDeletedEvent, type MessageDeletedForMeEvent, type MessageDeliveredEvent, type MessageReaction, type MessageReplyReference, type MessageUpdatedEvent, type MessagesDeliveredEvent, type MobileDeviceToken, type NewMessageEvent, type OptimisticAttachment, type PaginatedResponse, type Participant, type PersistStorage, type PlatformCompressFn, type PlatformUploadFn, type PresignedUrlRequest, type PresignedUrlResponse, type QuietHours, type ReactionUpdatedEvent, type ReadReceiptEvent, type RegisterData, type RegisterDeviceTokenPayload, type ReplyAttachmentSnapshot, type ResolvedCompressionConfig, type ResolvedConfig, type ResolvedFileSizeLimits, type SearchParams, type SendData, type SendMessageAttachment, type SendMessagePayload, type SocketStatus, type StatusListener, type TokenStore, type TypingIndicatorEvent, type UnreadSummary, type UpdateConversationData, type UploadConfig, type UploadProgress, type UploadableFile, type User, type UserPreferences, type UserStatusEvent, type WebPushDeviceToken, appConfigApi, authApi, connectSocket, conversationsApi, createAuthStore, devicesApi, disconnectSocket, getApiClient, getAuthStore, getCompressionStrategy, getSocket, getSocketStatus, initApiClient, initAuthStore, messagesApi, normalizeConversation, onSocketStatus, reconnectSocket, refreshSocketAuth, resetAuthStore, resolveConfig, setApiClientInstance, setTransitSession, socketEmit, storageApi, tryGetSocket, uploadBatch, useChatStore, usersApi };
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ import { Socket } from 'socket.io-client';
|
|
|
3
3
|
import * as zustand_middleware from 'zustand/middleware';
|
|
4
4
|
import * as zustand from 'zustand';
|
|
5
5
|
|
|
6
|
-
type EncryptionMode = 'none' | 'server' | 'e2ee';
|
|
7
6
|
type FileType = 'image' | 'video' | 'audio' | 'document';
|
|
8
7
|
type ConversationType = 'direct' | 'group';
|
|
9
8
|
type MessageStatus = 'sent' | 'delivered' | 'read' | 'failed' | 'deleted';
|
|
@@ -79,17 +78,6 @@ interface Attachment {
|
|
|
79
78
|
isUploading?: boolean;
|
|
80
79
|
uploadProgress?: number;
|
|
81
80
|
}
|
|
82
|
-
interface EncryptedContent {
|
|
83
|
-
ciphertext: string;
|
|
84
|
-
iv: string;
|
|
85
|
-
tag: string;
|
|
86
|
-
algorithm: 'aes-256-gcm';
|
|
87
|
-
}
|
|
88
|
-
interface EncryptionKeyInfo {
|
|
89
|
-
key: string;
|
|
90
|
-
enabled: boolean;
|
|
91
|
-
mode: EncryptionMode;
|
|
92
|
-
}
|
|
93
81
|
interface MessageReaction {
|
|
94
82
|
emoji: string;
|
|
95
83
|
userIds: string[];
|
|
@@ -149,9 +137,6 @@ interface Message {
|
|
|
149
137
|
userId: string;
|
|
150
138
|
deliveredAt: string;
|
|
151
139
|
}>;
|
|
152
|
-
isEncrypted?: boolean;
|
|
153
|
-
encryptionMode?: EncryptionMode;
|
|
154
|
-
encryptedContent?: EncryptedContent;
|
|
155
140
|
}
|
|
156
141
|
interface Participant {
|
|
157
142
|
userId: string;
|
|
@@ -188,9 +173,6 @@ interface Conversation {
|
|
|
188
173
|
isPinned?: boolean;
|
|
189
174
|
isMuted?: boolean;
|
|
190
175
|
mutedUntil?: string;
|
|
191
|
-
encryptionMode?: EncryptionMode;
|
|
192
|
-
isEncryptionEnabled?: boolean;
|
|
193
|
-
encryptionKey?: string;
|
|
194
176
|
}
|
|
195
177
|
interface AppConfig {
|
|
196
178
|
maxPinnedConversations: number;
|
|
@@ -260,6 +242,7 @@ interface PresignedUrlRequest {
|
|
|
260
242
|
size: number;
|
|
261
243
|
conversationId?: string;
|
|
262
244
|
folder?: string;
|
|
245
|
+
metadata?: Record<string, unknown>;
|
|
263
246
|
}
|
|
264
247
|
interface PresignedUrlResponse {
|
|
265
248
|
fileId: string;
|
|
@@ -388,8 +371,6 @@ interface SendMessagePayload {
|
|
|
388
371
|
attachments?: SendMessageAttachment[];
|
|
389
372
|
replyTo?: string;
|
|
390
373
|
tempId: string;
|
|
391
|
-
encryptedContent?: EncryptedContent;
|
|
392
|
-
isEncrypted?: boolean;
|
|
393
374
|
}
|
|
394
375
|
interface QuietHours {
|
|
395
376
|
enabled: boolean;
|
|
@@ -522,8 +503,14 @@ interface AntzChatConfig {
|
|
|
522
503
|
};
|
|
523
504
|
/** Required for multi-tenant backends. Sent as X-Tenant-ID header. */
|
|
524
505
|
tenantId?: string;
|
|
525
|
-
/**
|
|
526
|
-
|
|
506
|
+
/**
|
|
507
|
+
* Enable payload-level transit encryption (ECDH key exchange + AES-256-GCM).
|
|
508
|
+
* Encrypts every HTTP request/response body and every socket event payload.
|
|
509
|
+
* Server must have TRANSIT_ENCRYPTION_ENABLED=true to match.
|
|
510
|
+
* Default: true — set false only for local development/debugging.
|
|
511
|
+
* Safe to toggle anytime — no data migration needed (wire-only, never affects storage).
|
|
512
|
+
*/
|
|
513
|
+
transitEncryption?: boolean;
|
|
527
514
|
upload?: UploadConfig;
|
|
528
515
|
/**
|
|
529
516
|
* Optional compression config. Compression is disabled if platformCompressFn is not provided.
|
|
@@ -580,7 +567,7 @@ interface ResolvedConfig {
|
|
|
580
567
|
url?: string;
|
|
581
568
|
base64?: string;
|
|
582
569
|
};
|
|
583
|
-
|
|
570
|
+
transitEncryption: boolean;
|
|
584
571
|
upload: {
|
|
585
572
|
maxFileSizeMB: ResolvedFileSizeLimits;
|
|
586
573
|
maxFilesPerMessage: number;
|
|
@@ -639,7 +626,6 @@ interface SendData {
|
|
|
639
626
|
attachments?: SendMessagePayload['attachments'];
|
|
640
627
|
replyTo?: string;
|
|
641
628
|
tempId?: string;
|
|
642
|
-
isEncrypted?: boolean;
|
|
643
629
|
}
|
|
644
630
|
declare const messagesApi: {
|
|
645
631
|
list(conversationId: string, params?: ListMessagesParams): Promise<CursorPaginatedResponse<Message>>;
|
|
@@ -852,10 +838,7 @@ declare function disconnectSocket(): void;
|
|
|
852
838
|
declare function reconnectSocket(token: string, userId?: string, tenantId?: string): void;
|
|
853
839
|
/**
|
|
854
840
|
* Updates the socket auth token from the stored getToken function and reconnects.
|
|
855
|
-
* Called by SocketProvider on connect_error to handle expired-token scenarios
|
|
856
|
-
* 1. Token expired while disconnected → server rejects the reconnect handshake
|
|
857
|
-
* 2. authProvider returns a fresh token → we update socket auth and retry
|
|
858
|
-
*
|
|
841
|
+
* Called by SocketProvider on connect_error to handle expired-token scenarios.
|
|
859
842
|
* Returns true if the token was updated, false if no token source is available.
|
|
860
843
|
*/
|
|
861
844
|
declare function refreshSocketAuth(): boolean;
|
|
@@ -877,6 +860,16 @@ declare const socketEmit: {
|
|
|
877
860
|
getTypingUsers(conversationId: string): Promise<unknown>;
|
|
878
861
|
};
|
|
879
862
|
|
|
863
|
+
type TransitAlgo = 'x25519' | 'p256';
|
|
864
|
+
|
|
865
|
+
interface TransitSession {
|
|
866
|
+
sessionKey: CryptoKey;
|
|
867
|
+
algo: TransitAlgo;
|
|
868
|
+
sessionId: string;
|
|
869
|
+
enabled: boolean;
|
|
870
|
+
}
|
|
871
|
+
declare function setTransitSession(session: TransitSession): void;
|
|
872
|
+
|
|
880
873
|
interface AuthState {
|
|
881
874
|
user: User | null;
|
|
882
875
|
tokens: AuthTokens | null;
|
|
@@ -1135,4 +1128,4 @@ declare class AntzChatClient {
|
|
|
1135
1128
|
uploadIcon(conversationId: string, file: UploadableFile): Promise<Conversation>;
|
|
1136
1129
|
}
|
|
1137
1130
|
|
|
1138
|
-
export { AntzChatClient, type AntzChatConfig, type AppConfig, type Attachment, type AuthResponse, type AuthTokens, type BatchUploadResult, type CompressedFile, type CompressionAlgorithm, type CompressionConfig, type Conversation, type ConversationListParams, type ConversationUnreadCount, type CreateDirectData, type CreateGroupData, type CursorPaginatedResponse, type
|
|
1131
|
+
export { AntzChatClient, type AntzChatConfig, type AppConfig, type Attachment, type AuthResponse, type AuthTokens, type BatchUploadResult, type CompressedFile, type CompressionAlgorithm, type CompressionConfig, type Conversation, type ConversationListParams, type ConversationUnreadCount, type CreateDirectData, type CreateGroupData, type CursorPaginatedResponse, type FileResponse, type FileSizeLimits, type FileType, type LastReadEntry, type ListMessagesParams, type LoginCredentials, type Message, type MessageAckEvent, type MessageContent, type MessageDeletedEvent, type MessageDeletedForMeEvent, type MessageDeliveredEvent, type MessageReaction, type MessageReplyReference, type MessageUpdatedEvent, type MessagesDeliveredEvent, type MobileDeviceToken, type NewMessageEvent, type OptimisticAttachment, type PaginatedResponse, type Participant, type PersistStorage, type PlatformCompressFn, type PlatformUploadFn, type PresignedUrlRequest, type PresignedUrlResponse, type QuietHours, type ReactionUpdatedEvent, type ReadReceiptEvent, type RegisterData, type RegisterDeviceTokenPayload, type ReplyAttachmentSnapshot, type ResolvedCompressionConfig, type ResolvedConfig, type ResolvedFileSizeLimits, type SearchParams, type SendData, type SendMessageAttachment, type SendMessagePayload, type SocketStatus, type StatusListener, type TokenStore, type TypingIndicatorEvent, type UnreadSummary, type UpdateConversationData, type UploadConfig, type UploadProgress, type UploadableFile, type User, type UserPreferences, type UserStatusEvent, type WebPushDeviceToken, appConfigApi, authApi, connectSocket, conversationsApi, createAuthStore, devicesApi, disconnectSocket, getApiClient, getAuthStore, getCompressionStrategy, getSocket, getSocketStatus, initApiClient, initAuthStore, messagesApi, normalizeConversation, onSocketStatus, reconnectSocket, refreshSocketAuth, resetAuthStore, resolveConfig, setApiClientInstance, setTransitSession, socketEmit, storageApi, tryGetSocket, uploadBatch, useChatStore, usersApi };
|