import { ApiSecurity, ApiUrl, AppDetails } from '../shared'; import { RequestCanceler } from '../shared/http/client'; import { AddressAvailabilityResponse, MailboxResponse, EmailListResponse, EmailResponse, EmailCreatedResponse, SendEmailRequest, DraftEmailRequest, UpdateEmailRequest, ListEmailsQuery, EmailDomainsResponse, SetupMailAccountPayload, SearchFiltersQuery, MailAccountKeysResponse, MailAccountResponse, LookupRecipientKeysResponse, EncryptedKeystore, KeystoreType, RecipientWithPublicKey, HybridEncryptedEmail, EmailPublicParameters, PwdProtectedEmail, UploadAttachmentResponse, DownloadAttachmentResponse, DownloadAttachmentPayload, ReplyEmailRequest } from './types'; export declare class MailApi { private readonly client; private readonly appDetails; private readonly apiSecurity; static client(apiUrl: ApiUrl, appDetails: AppDetails, apiSecurity: ApiSecurity): MailApi; private constructor(); /** * Uploads encrypted keystore to the server * * @param keystore - The encrypted keystore * @returns Server response */ uploadKeystore(keystore: EncryptedKeystore): Promise; /** * Requests encrypted keystore from the server * * @param userEmail - The email of the user * @param keystoreType - The type of the keystore * @returns The encrypted keystore */ downloadKeystore(userEmail: string, keystoreType: KeystoreType): Promise; /** * Requests users with corresponding public keys from the server * * @param emails - The emails of the users * @returns Users with corresponding public keys */ getUsersWithPublicKeys(emails: string[]): Promise; /** * Sends the encrypted emails to the server * * @param emails - The encrypted emails * @param params - The public parameters of the email * @returns Server response */ sendE2EEmails(emails: HybridEncryptedEmail[], params: EmailPublicParameters): Promise; /** * Sends the password-protected email to the server * * @param email - The password-protected email * @param params - The public parameters of the email * @returns Server response */ sendE2EPasswordProtectedEmail(email: PwdProtectedEmail, params: EmailPublicParameters): Promise; search(filters: SearchFiltersQuery): Promise; /** * Gets the mailboxes of the user * * @returns The mailboxes of the user - `MailboxResponse[]` */ getMailboxes(): Promise; /** * Lists emails of the user * * @param query - The query to filter emails (e.g. mailbox, limit, etc.) * @returns The list of emails - `EmailListResponse` */ listEmails(query?: ListEmailsQuery): Promise; /** * Gets the email with the corresponding id * * @param id - The id of the email * @returns The email with the corresponding id - `EmailResponse` */ getEmail(id: string): Promise; getThreads(parentMessageId: string): Promise; /** * Deletes the email with the corresponding id * * @param id - The id of the email to delete * @returns A promise that resolves when the email is deleted */ deleteEmail(id: string): Promise; /** * Updates the email with the corresponding id * * @param id - The id of the email to update * @param body - The new body of the email * @returns A promise that resolves when the email is updated */ updateEmail(id: string, body: UpdateEmailRequest): Promise; /** * Sends an email to the specified recipients * * @param body - The body of the email to send * @returns The created email */ sendEmail(body: SendEmailRequest): Promise; /** * Reply a message to the sender * @param messageId - The ID of the message we want to reply * @param body - The body of the reply * @returns The created email */ replyEmail(messageId: string, body: ReplyEmailRequest): Promise; /** * Looks up the public encryption keys for one or more recipient addresses. * For each address, returns the public key if it belongs to an active * Internxt domain, or `null` for external or unknown addresses. * * @param addresses - 1-50 email addresses to look up * @returns Recipients with their public keys (or null) */ lookupRecipientKeys(addresses: string[]): Promise; /** * Saves a draft email * * @param body - The body of the draft email to save * @returns The created email - `EmailResponse` */ saveDraft(body: DraftEmailRequest): Promise; /** * Updates the draft with the corresponding id * * @param id - The id of the draft to update * @param body - The new body of the draft * @returns The new Draft Id for this email */ updateDraft(id: string, body: DraftEmailRequest): Promise; /** * Gets the draft with the corresponding id * * @param id - The id of the draft * @returns The draft with the corresponding id - `EmailResponse` */ getDraft(id: string): Promise; /** * Discards an existent mail draft * @param id - The id of the draft we want to discard * @returns A promise that resolves when the draft is discarded */ discardDraft(id: string): Promise; /** * Returns the list of active domains for the email gateway * * @returns The list of active domains - `ActiveDomainsResponse` */ getActiveDomains(): Promise; /** * Checks whether an email address is free to claim * * @param username - Local part of the address (before the @) * @param domain - Email domain to check the username against * @returns Whether the address is available and, when taken, a suggested * alternative full address - `AddressAvailabilityResponse` */ checkAddressAvailability(username: string, domain: string): Promise; /** * Returns the current mail account for the authenticated user, including its * state, default address, and (when suspended) the scheduled deletion time. * * @returns The mail account details — `MailAccountResponse` */ getMailAccount(): Promise; /** * Sets up a mail account for the user * * @param payload - Set of details for mail account setup * @returns A promise that resolves with the created mail account address */ setupMailAccount(payload: SetupMailAccountPayload): Promise<{ address: string; }>; /** * Gets the mail account keys for the given address. When omitted, the * backend returns the keys for the caller's default address. * * @param address - Optional. The mail address whose keys should be retrieved * @returns The public, encrypted private and recovery keys plus the salt */ getMailAccountKeys(address?: string): Promise; /** * Uploading an attachment to the S3 so we can attach it to an email * @param file - File to upload * @returns * - `blobId` - The blob id of the attachment * - `name` - The name of the attachment * - `type` - The content type of the attachment * - `size` - The size of the attachment * */ uploadAttachment(file: File): { promise: Promise; requestCanceler: RequestCanceler; }; /** * Downloads an attachment of the given email as raw bytes, together with the * metadata exposed by the response headers (filename, content type and * content length). The caller decides how to consume the bytes (write them * to disk, wrap them in a `Blob`, etc.). * * @param id - The id of the email that owns the attachment * @param blobId - The blob id of the attachment * @param query - Optional `name` and `type` overrides forwarded to the backend * @returns The attachment bytes plus filename, content type and length */ downloadAttachment(id: string, blobId: string, query?: DownloadAttachmentPayload): Promise; /** * Returns the needed headers for the module requests * @private */ private headers; }