import { SpaceUser } from '@spacehq/users'; import { Users, UserAuth, UserMessage } from '@textile/hub'; import ee from 'event-emitter'; export interface MailboxConfig { textileHubAddress?: string; usersInit?: (auth: UserAuth) => Users; } export interface DecryptedUserMessage extends UserMessage { decryptedBody: Uint8Array; } /** * Mailbox performs mailbox actions on behalf of the user provided. * * @example * ```typescript * * const mb = await Mailbox.CreateMailbox(user); * await mb.sendMessage(pubkey, body); * ``` */ export declare class Mailbox { private readonly user; private readonly config; private listener?; private emitters; private constructor(); /** * Initializes the mailbox on the Textile hub server for this user * * @example * ```typescript * const mb = await MailBox.createMailbox(user); * ``` */ static createMailbox(user: SpaceUser, config: MailboxConfig | undefined, parser: (dec: DecryptedUserMessage) => {}): Promise; subscribe(emitter: ee.Emitter): void; /** * Get messages from a mailbox * * @example * ```typescript * const mb = await Mailbox.createMailbox(user); * // seek is a cursor to start the messages from * const msgs = await mb.ListInboxMessages(seek, limit); * ``` */ listInboxMessages(seek?: string, limit?: number): Promise; /** * Send a message using mailbox * * @example * ```typescript * const mb = await Mailbox.createMailbox(user); * const sentMsg = await mb.sendMessage(pubkey, body); * ``` */ sendMessage(to: string, body: Uint8Array): Promise; /** * Deletes the specified message from inbox * * @param id - UserMessage id gotten from list inbox message */ deleteMessage(id: string): Promise; private getUserAuth; private getUsersClient; private initUsers; /** * Decrypts a user's inbox messages using their PrivateKey */ messageDecoder: (user: SpaceUser, message: UserMessage) => Promise; }