import { type AttachmentInput } from './attachment-router.js'; import { LocoSession } from './protocol/session.js'; import type { LocoPacket } from './protocol/types.js'; import { type KakaoChat, type KakaoDeviceType, type KakaoKickList, type KakaoKickMemberResult, type KakaoLeaveChatResult, type KakaoMarkReadResult, type KakaoMember, type KakaoMemberSnapshot, type KakaoMemberSnapshotOptions, type KakaoMentionInput, type KakaoMessage, type KakaoMessagePage, type KakaoPartialMemberSnapshot, type KakaoProfile, type KakaoReadWatermarks, type KakaoReplyTarget, type KakaoSendResult, type KakaoWriteOptions, type KakaoTalkClientOptions, type KakaoTypingResult, type KakaoUnkickMemberResult } from './types.js'; export type KakaoSessionEvent = { type: 'connected'; userId: string; } | { type: 'disconnected'; } | { type: 'kicked'; reason: string; }; export type KakaoPushHandler = (packet: LocoPacket) => void; export type KakaoSessionEventHandler = (event: KakaoSessionEvent) => void; export type KakaoTalkResponseFailureKind = 'provider_rejection' | 'transient_or_unknown'; export type KakaoTalkResponseStatusSource = 'packet' | 'body'; export type KakaoTalkGetChatFailureReason = 'provider_rejection' | 'synthetic_connection_close' | 'chat_info_absent' | 'transport_or_unknown'; export declare class KakaoTalkError extends Error { code: string; readonly serverStatus?: number; readonly responseFailureKind?: KakaoTalkResponseFailureKind; readonly responseStatusSource?: KakaoTalkResponseStatusSource; readonly getChatFailureReason?: KakaoTalkGetChatFailureReason; constructor(message: string, code: string, options?: { cause?: unknown; serverStatus?: number; responseFailureKind?: KakaoTalkResponseFailureKind; responseStatusSource?: KakaoTalkResponseStatusSource; getChatFailureReason?: KakaoTalkGetChatFailureReason; }); } export declare class KakaoTalkClient { private readonly options; private oauthToken; private userId; private deviceUuid; private deviceType; private state; private initPromise; private closed; private nextMessageId; private pushHandlers; private sessionEventHandlers; private nameCache; constructor(options?: KakaoTalkClientOptions); login(credentials?: { oauthToken: string; userId: string; deviceUuid?: string; deviceType?: KakaoDeviceType; }, accountId?: string): Promise; getCredentials(): { oauthToken: string; userId: string; deviceUuid: string; deviceType: KakaoDeviceType; }; private ensureAuth; private ensureSession; acquireSession(): Promise; onPush(handler: KakaoPushHandler): () => void; onSessionEvent(handler: KakaoSessionEventHandler): () => void; isConnected(): boolean; private executeWithReconnect; private retryUncertainSend; private connect; private dispatchPush; private invalidateSession; private emitSessionEvent; getChats(options?: { all?: boolean; search?: string; resolveTitles?: boolean; }): Promise; /** * Fetch one chat directly by id via read-only CHATINFO. * * Unlike `getChats()`, this does not depend on the login-time snapshot or * LCHATLIST pagination, so a room first observed from a live push can be * resolved without interpreting protocol fields outside this SDK. * The returned chat type preserves numeric values and non-empty protocol * strings, including DirectChat, MultiChat, PlusChat, MemoChat, OM, and OD; * unknown non-empty strings are preserved for forward compatibility. */ getChat(chatId: string): Promise; /** * Resolve the user-set room title via CHATINFO. Returns null on any error * (network, malformed response, or no TITLE meta present). Designed to be * fire-and-forget per chat — failures don't poison the whole `getChats` call. */ getChatTitle(chatId: string): Promise; private fetchChatTitle; /** * Fetch one forward-only, lossless history page after `from`. * * The page never keeps only the newest `count` entries. If the protocol * returns more entries than requested, the oldest entries are returned and * `complete` remains false so callers can continue from `next_cursor`. */ getMessagePage(chatId: string, options?: { count?: number; from?: string; }): Promise; getMessages(chatId: string, options?: { count?: number; from?: string; }): Promise; /** * Member snapshot of a chat. By default it is read-only (CHATINFO + GETMEM, each * observed twice) and throws `get_member_snapshot_failed` unless the result is * confirmed complete. `allowPartial: true` returns a `complete: false` snapshot * with an `incomplete_reason` instead. `allowRoomEntry: true` lets an incomplete * read-only snapshot be completed through CHATONROOM member ids + MEMBER; CHATONROOM * enters the room and can advance the account's unread state. */ getMemberSnapshot(chatId: string, options?: KakaoMemberSnapshotOptions & { allowPartial?: false; }): Promise; getMemberSnapshot(chatId: string, options: KakaoMemberSnapshotOptions): Promise; private readOnlyMemberSnapshot; private roomEntryMemberSnapshot; getMembers(chatId: string): Promise; getMembersByIds(chatId: string, userIds: string[]): Promise; sendMessage(chatId: string, text: string, options?: KakaoWriteOptions & { replyTo?: KakaoReplyTarget; mentions?: KakaoMentionInput[]; }): Promise; sendTyping(chatId: string, opts?: { linkId?: string; }): Promise; sendAttachment(chatId: string, data: Uint8Array | Buffer, filename: string, mimeType?: string): Promise; sendAttachment(chatId: string, attachments: ReadonlyArray): Promise; private dispatchSingleAttachment; sendPhoto(chatId: string, photo: Uint8Array | Buffer, filename?: string): Promise; sendVideo(chatId: string, video: Uint8Array | Buffer, filename?: string): Promise; sendAudio(chatId: string, audio: Uint8Array | Buffer, filename?: string): Promise; sendFile(chatId: string, file: Uint8Array | Buffer, filename: string, mimeType?: string): Promise; sendMultiPhoto(chatId: string, photos: Array<{ data: Uint8Array | Buffer; filename?: string; }>): Promise; private sendMediaViaLoco; /** * Advance the read watermark for `chatId` up to and including `logId`. * The caller decides open vs normal: pass `opts.linkId` for open chats * (오픈채팅) and omit it for normal chats. Open chats without a `linkId` * are rejected by the server with a non-zero `body.status` — this method * does not auto-detect. */ markRead(chatId: string, logId: string, opts?: { linkId?: string; }): Promise; /** * Per-member read watermarks for a chat, from CHATONROOM. Note that CHATONROOM * is the room-entry command: the server may clear the caller's own unread count * for this chat (see #315), so do not call it from passive polling. The server * returns watermarks only on the first CHATONROOM for a chat per LOCO session; * a repeat call throws `get_read_watermarks_failed`. Seed once, then apply * DECUNREAD `read` events (watermark only moves forward). */ getReadWatermarks(chatId: string): Promise; leaveChat(chatId: string): Promise; /** * Kick a member from an open chat (KICKMEM). This cannot be undone: the member * is removed and blocked from rejoining through the room's link until * `unkickMember` clears them from the kick list. Requires host or co-host * permission; the server reports a rejection as `success: false` with a * non-zero `status_code`. Throws `not_open_chat` for regular chats. */ kickMember(chatId: string, userId: string): Promise; /** * List members kicked from an open chat (KLSYNC). Kicked members cannot rejoin * through the room's link until removed with `unkickMember`. */ getKickList(chatId: string): Promise; /** * Remove a member from an open chat's kick list (KLDELITEM) so they can rejoin * through the room's link. This does not add them back to the room. */ unkickMember(chatId: string, userId: string): Promise; getProfile(): Promise; close(): void; lookupAuthorName(chatId: string, authorId: number): string | null; } //# sourceMappingURL=client.d.ts.map