/** * Copyright © 2026 Anonyome Labs, Inc. All rights reserved. * * SPDX-License-Identifier: Apache-2.0 */ import { ListOutput, SudoCryptoProvider, SudoKeyManager } from '@sudoplatform/sudo-common'; import { SudoPlatformSignInCallback, SudoUserClient } from '@sudoplatform/sudo-user'; import { CreateSingletonKeysIfAbsentResult } from './typings/createSingletonKeysIfAbsentResult'; import { BlockEmailAddressesInput, UnblockEmailAddressesByHashedValueInput } from './inputs/blockedAddresses'; import { CancelScheduledDraftMessageInput, CreateDraftEmailMessageInput, DeleteDraftEmailMessagesInput, GetDraftEmailMessageInput, ListDraftEmailMessageMetadataForEmailAddressIdInput, ListDraftEmailMessagesForEmailAddressIdInput, ListScheduledDraftMessagesForEmailAddressIdInput, ScheduleSendDraftMessageInput, UpdateDraftEmailMessageInput } from './inputs/draftEmailMessage'; import { CheckEmailAddressAvailabilityInput, GetEmailAddressInput, ListEmailAddressesForSudoIdInput, ListEmailAddressesInput, LookupEmailAddressesPublicInfoInput, ProvisionEmailAddressInput, UpdateEmailAddressMetadataInput } from './inputs/emailAddress'; import { CreateCustomEmailFolderInput, DeleteCustomEmailFolderInput, DeleteMessagesForFolderIdInput, ListEmailFoldersForEmailAddressIdInput, UpdateCustomEmailFolderInput } from './inputs/emailFolder'; import { GetEmailMessageInput, GetEmailMessageWithBodyInput, ListEmailMessagesForEmailAddressIdInput, ListEmailMessagesForEmailFolderIdInput, ListEmailMessagesInput, SendEmailMessageInput, SendEmailMessageViaAliasInput, UpdateEmailMessagesInput } from './inputs/emailMessage'; import { ScheduledDraftMessage, UpdatedEmailMessageSuccess } from './typings'; import { BatchOperationResult, EmailMessageOperationFailureResult } from './typings/batchOperationResult'; import { UnsealedBlockedAddress } from './typings/blockedAddresses'; import { ConfigurationData } from './typings/configurationData'; import { DeleteEmailMessageSuccessResult } from './typings/deleteEmailMessageSuccessResult'; import { DraftEmailMessage } from './typings/draftEmailMessage'; import { DraftEmailMessageMetadata } from './typings/draftEmailMessageMetadata'; import { EmailAddress } from './typings/emailAddress'; import { EmailAddressPublicInfo } from './typings/emailAddressPublicInfo'; import { EmailFolder } from './typings/emailFolder'; import { EmailDomain } from './typings/emailDomain'; import { EmailMessage, EmailMessageSubscriber, SendEmailMessageResult } from './typings/emailMessage'; import { EmailMessageWithBody } from './typings/emailMessageWithBody'; import { ListEmailAddressesResult, ListEmailMessagesResult } from './typings/listOperationResult'; import { DeprovisionEmailAliasInput, DisableEmailAliasInput, EnableEmailAliasInput, GetEmailAliasByIdInput, ListEmailAliasesForOwnerInput, ListEmailAliasesInput, ProvisionEmailAliasInput, UpdateEmailAliasInput } from './inputs/emailAlias'; import { FlushMessageBodyCacheInput } from './inputs/flushMessageBodyCache'; import { EmailAlias, EmailAliasListItem } from './typings/emailAlias'; import { VerifyExternalEmailAddressInput, VerifyExternalEmailAddressResult } from './typings/verifyExternalEmailAddress'; export interface SudoEmailClient { /** * Provision an email address. * * @param {ProvisionEmailAddressInput} input Parameters used to provision an email address. Email addresses must meet * the following criteria: * - Total length (including both local part and domain) must not exceed 256 characters. * - Local part must not exceed more than 64 characters. * - Input domain parts (domain separated by `.`) must not exceed 63 characters. * - Address must match standard email address pattern: * `^[a-zA-Z0-9](\.?[-_a-zA-Z0-9])*@[a-zA-Z0-9](-*\.?[a-zA-Z0-9])*\.[a-zA-Z](-?[a-zA-Z0-9])+$`. * - Domain must be a registered domain retrieved from {@link SudoEmailClient.listEmailDomains}. * * @returns {EmailAddress} The provisioned email address. * * @throws {@link InvalidAddressError} * @throws {@link InvalidKeyRingIdError} * @throws {@link AddressUnavailableError} * @throws NotRegisteredError * @throws InvalidTokenError * @throws InsufficientEntitlementsError * @throws ServiceError */ provisionEmailAddress(input: ProvisionEmailAddressInput): Promise; /** * Deprovision an email address. * * If `SudoEmailClientConfig.allowCallerManagedKeys` is `false`, once the email address is deprovisioned its key * pair is removed from the key store, unless another of the user's email addresses or email aliases still uses it. * Nothing is removed if the client allows caller managed keys (the default) or enforces a singleton key pair, or * if the service can't say whether the key pair is still used. Key pairs of email aliases aren't removed, because * the service doesn't report which key pair an alias was provisioned with. * * @param {string} id The identifier of the email address to deprovision. * @returns {EmailAddress} The deprovisioned email address. * * @throws {@link AddressNotFoundError} * @throws NotRegisteredError * @throws {@link KeyPairRemovalFailedError} if the email address was deprovisioned, but its key pair couldn't be * removed from the key store. The error carries the deprovisioned email address, so callers can treat it as success. */ deprovisionEmailAddress(id: string): Promise; /** * Update the metadata of an email address. * * @param {UpdateEmailAddressMetadataInput} input Parameters used to update the metadata of an email address. * @returns {string} The id of the updated email address. * * @throws NotRegisteredError * @throws ServiceError */ updateEmailAddressMetadata(input: UpdateEmailAddressMetadataInput): Promise; /** * Get a list of all of the email domains for which end-to-end encryption is supported. * * @returns {string[]} A list of all configured domains. * * @throws NotRegisteredError * @throws ServiceError */ getConfiguredEmailDomains(): Promise; /** * List all email domains. * * @returns {EmailDomain[]} A list of email domains with metadata. * * @throws NotRegisteredError * @throws ServiceError */ listEmailDomains(): Promise; /** * Check if an email address is available to be provisioned within a domain. * * @param {CheckEmailAddressAvailabilityInput} input Parameters used to perform the email addresses check. * @returns {string[]} Returns the fully qualified email addresses, filtering out already used email addresses. * * @throws {@link InvalidEmailDomainError} * @throws {@link InvalidArgumentError} * @throws {@link InvalidAddressError} */ checkEmailAddressAvailability(input: CheckEmailAddressAvailabilityInput): Promise; /** * Get an email address identified by id. * * @param {GetEmailAddressInput} input Parameters used to retrieve an email address. * @returns {EmailAddress | undefined} The email address identified by id or undefined if the email address * cannot be found. */ getEmailAddress(input: GetEmailAddressInput): Promise; /** * Get a list of all provisioned email addresses for the signed in user. * * @param {ListEmailAddressesInput} input Parameters used to retrieve a list of provisioned email addresses. * @returns {ListEmailAddressesResult} List operation result. */ listEmailAddresses(input?: ListEmailAddressesInput): Promise; /** * Get a list of provisioned email addresses owned by the Sudo identified by sudoId. * * @param {ListEmailAddressesForSudoIdInput} input Parameters used to retrieve a list of provisioned email addresses for a sudoId. * @returns {ListEmailAddressesResult} List operation result. */ listEmailAddressesForSudoId(input: ListEmailAddressesForSudoIdInput): Promise; /** * Get a list of public information objects associated with the provided email addresses. * Results can only be retrieved in batches of 50. Anything greater will throw a {@link LimitExceededError}. * * @param {LookupEmailAddressesPublicInfoInput} input Parameters used to retrieve a list of public information objects for a list * of email addresses. * @returns {EmailAddressPublicInfo[]} An array of public info objects, or an empty array if email addresses * or their public keys cannot be found. * * @throws LimitExceededError */ lookupEmailAddressesPublicInfo(input: LookupEmailAddressesPublicInfoInput): Promise; /** * Get a list of email folders associated with the email address identified by emailAddressId. * * @param {ListEmailFoldersForEmailAddressIdInput} input Parameters used to retrieve a list of email folders for an emailAddressId. * @returns {ListOutput} An array of email folders or an empty array if no matching email folders * can be found. */ listEmailFoldersForEmailAddressId(input: ListEmailFoldersForEmailAddressIdInput): Promise>; /** * Create a custom email folder for the email address identified by emailAddressId. * * @param {CreateCustomEmailFolderInput} input Parameters used to create a custom email folder. * @returns {EmailFolder} The created custom email folder. */ createCustomEmailFolder(input: CreateCustomEmailFolderInput): Promise; /** * Delete a custom email folder for the email address identified by emailAddressId. * When a custom folder is deleted, any messages in the folder will be moved to TRASH. * * @param {DeleteCustomEmailFolderInput} input Parameters used to delete a custom email folder. * @returns {EmailFolder | undefined} The deleted folder, or undefined if folder was not found. */ deleteCustomEmailFolder(input: DeleteCustomEmailFolderInput): Promise; /** * Update the custom email folder identified by emailFolderId * * @param {UpdateCustomEmailFolderInput} input Parameters used to update a custom email folder. * @returns {EmailFolder} The updated email folder. */ updateCustomEmailFolder(input: UpdateCustomEmailFolderInput): Promise; /** * Block email address(es) for the given owner * * @param {BlockEmailAddressesInput} input Parameters to block email addresses * @returns {Promise>} The results of the operation */ blockEmailAddresses(input: BlockEmailAddressesInput): Promise>; /** * Unblock email address(es) for the given owner * * @param {UnblockEmailAddressesByHashedValueInput} input Parameters to unblock email addresses * @returns {Promise>} The results of the operation */ unblockEmailAddressesByHashedValue(input: UnblockEmailAddressesByHashedValueInput): Promise>; /** * Get email address blocklist for logged in user * * @returns {Promise} The list of unsealed blocked addresses */ getEmailAddressBlocklist(): Promise; /** * Create a draft email message in RFC 6854 (supersedes RFC 822)(https://tools.ietf.org/html/rfc6854) format. * * @param {CreateDraftEmailMessageInput} input Parameters used to create a draft email message. * @returns {DraftEmailMessageMetadata} The metadata of the saved draft email message. * * @throws {@link AddressNotFoundError} */ createDraftEmailMessage(input: CreateDraftEmailMessageInput): Promise; /** * Update a draft email message in RFC 6854 (supersedes RFC 822)(https://tools.ietf.org/html/rfc6854) format. * * @param {UpdateDraftEmailMessageInput} input Parameters used to update a draft email message. * @returns {DraftEmailMessageMetadata} The metadata of the updated draft email message. * * @throws {@link AddressNotFoundError} * @throws {@link MessageNotFoundError} */ updateDraftEmailMessage(input: UpdateDraftEmailMessageInput): Promise; /** * Delete the draft email messages identified by the list of ids. * * Any draft email message ids that do not exist will be marked as success. * Any emailAddressId that is not owned or does not exist, will throw an error. * * @param {DeleteDraftEmailMessagesInput} input Parameters used to delete a draft email message. * @returns The status of the delete: * Success - All draft email messages succeeded to delete. * Partial - Only a partial amount of draft email messages succeeded to delete. Includes a list of the * identifiers of the draft email messages that failed and succeeded to delete. * Failure - All draft email messages failed to delete. * * @throws {@link AddressNotFoundError} * @throws {@link LimitExceededError} */ deleteDraftEmailMessages(input: DeleteDraftEmailMessagesInput): Promise>; /** * Get a draft email message that has been previously saved. * * @param {GetDraftEmailMessageInput} input Parameters used to retrieve a draft email message. * @returns {DraftEmailMessage | undefined} The draft email message identified by id or undefined if not found. */ getDraftEmailMessage(input: GetDraftEmailMessageInput): Promise; /** * Lists the metadata and content of all draft messages for the specified email address identifier. * Supports pagination with limit and nextToken parameters. * * @param {ListDraftEmailMessagesForEmailAddressIdInput} input Parameters for listing draft email messages * including emailAddressId, optional limit (defaults to 10), and optional nextToken for pagination. * @returns {ListOutput} A list output containing draft email messages and pagination token. */ listDraftEmailMessagesForEmailAddressId(input: ListDraftEmailMessagesForEmailAddressIdInput): Promise>; /** * Lists the metadata of all draft email messages for the specified email address identifier. * Supports pagination with limit and nextToken parameters. * Supports pagination with limit and nextToken parameters. * * @param {ListDraftEmailMessageMetadataForEmailAddressIdInput} input Parameters for listing draft email message metadata * including emailAddressId, optional limit (defaults to 10), and optional nextToken for pagination. * @returns {ListOutput} A list output containing draft email message metadata and pagination token. * @param {ListDraftEmailMessageMetadataForEmailAddressIdInput} input Parameters for listing draft email message metadata * including emailAddressId, optional limit (defaults to 10), and optional nextToken for pagination. * @returns {ListOutput} A list output containing draft email message metadata and pagination token. */ listDraftEmailMessageMetadataForEmailAddressId(input: ListDraftEmailMessageMetadataForEmailAddressIdInput): Promise>; /** * * @param {ScheduleSendDraftMessageInput} input Parameters used to schedule send a draft message. * @returns {ScheduledDraftMessage} */ scheduleSendDraftMessage(input: ScheduleSendDraftMessageInput): Promise; /** * Cancels a scheduled draft message. If no matching scheduled message is found, * the operation completes successfully without error. * * @param {CancelScheduledDraftMessageInput} input Parameters used to cancel a scheduled draft message * @returns {string} */ cancelScheduledDraftMessage(input: CancelScheduledDraftMessageInput): Promise; /** * List scheduled draft messages associated with an email address. * @param {ListScheduledDraftMessagesForEmailAddressIdInput} input Parameters ued to list scheduled draft messages for an email address * @returns {ListOutput} */ listScheduledDraftMessagesForEmailAddressId(input: ListScheduledDraftMessagesForEmailAddressIdInput): Promise>; /** * Send an email message using RFC 6854 (supersedes RFC 822)(https://tools.ietf.org/html/rfc6854) data. * * Email messages sent to in-network recipients (i.e. email addresses that exist within the Sudo Platform) * will be sent end-to-end encrypted. * * @param {SendEmailMessageInput} input Parameters used to send an email message. * @returns {string} The identifier of the email message that is being sent. * * @throws {@link UnauthorizedAddressError} * @throws {@link InvalidEmailContentsError} * @throws NotAuthorizedError * @throws NotRegisteredError * @throws LimitExceededError * @throws InsufficientEntitlementsError */ sendEmailMessage(input: SendEmailMessageInput): Promise; /** * Send an email message via an email alias using RFC 6854 (supersedes RFC 822)(https://tools.ietf.org/html/rfc6854) data. * * Email messages sent to in-network recipients (i.e. email addresses/aliases that exist within the Sudo Platform) * will be sent end-to-end encrypted. * * @param {SendEmailMessageViaAliasInput} input Parameters used to send an email message via an email alias. * @returns {string} The identifier of the email message that is being sent. * * @throws {@link UnauthorizedAddressError} * @throws {@link InvalidEmailContentsError} * @throws NotAuthorizedError * @throws NotRegisteredError * @throws LimitExceededError * @throws InsufficientEntitlementsError */ sendEmailMessageViaAlias(input: SendEmailMessageViaAliasInput): Promise; /** * Update the email messages identified by the list of ids. * * Email messages can only be updated in batches of 100. Anything greater will throw a {@link LimitExceededError}. * * @param {UpdateEmailMessagesInput} input Parameters used to update a list of email messages. * @returns The status of the update: * Success - All email messages succeeded to update. * Partial - Only a partial amount of messages succeeded to update. Includes a list of the * identifiers of the email messages that failed and succeeded to update. * Failure - All email messages failed to update. * * @throws NotRegisteredError * @throws LimitExceededError * @throws InvalidArgumentError */ updateEmailMessages(input: UpdateEmailMessagesInput): Promise>; /** * Delete the email messages identified by the list of ids. * * Email messages can only be deleted in batches of 100. Anything greater will throw a {@link LimitExceededError}. * * @param {string[]} ids A list of one or more identifiers of the email messages to be deleted. There is a limit of * 100 email message ids per API request. Exceeding this will cause an error to be thrown. * * @returns The status of the delete: * Success - All email messages succeeded to delete. * Partial - Only a partial amount of messages succeeded to delete. Includes a list of the * identifiers of the email messages that failed and succeeded to delete. * Failure - All email messages failed to delete. * * @throws NotRegisteredError * @throws InvalidArgumentError * @throws LimitExceededError * @throws ServiceError */ deleteEmailMessages(ids: string[]): Promise>; /** * Delete a single email message identified by id. * * @param {string} id The identifier of the email message to be deleted. * @returns {DeleteEmailMessageSuccessResult | undefined} Result object containing the identifier of the email * message that was deleted, or undefined if the email message could not be deleted. * * @throws NotRegisteredError * @throws LimitExceededError * @throws ServiceError */ deleteEmailMessage(id: string): Promise; /** * Delete all messages for in an email folder. * Deletion will be processed asynchronously since it may take a substantial amount of time. * This method does not wait for deletion to complete. To check for completion, listen for subscriptions or check list endpoints. * * @param {DeleteMessagesForFolderIdInput} input Parameters used to delete messages from a folder * @returns {string} The id of the folder */ deleteMessagesForFolderId(input: DeleteMessagesForFolderIdInput): Promise; /** * Get an email message identified by id. * * @param {GetEmailMessageInput} input Parameters used to retrieve an email message. * @returns {EmailMessage | undefined} The email message identified by id or undefined if the email message * cannot be found. */ getEmailMessage(input: GetEmailMessageInput): Promise; /** * Get the body and attachment data of an EmailMessage * * @param {GetEmailMessageWithBodyInput} input Parameters used to retrieve the data of the email message. * @returns {EmailMessageWithBody | undefined} The data associated with the email message or undefined if not found */ getEmailMessageWithBody(input: GetEmailMessageWithBodyInput): Promise; /** * Get the list of all email messages for the user. * * @param {ListEmailMessagesInput} input Parameters used to retrieve a list of all email messages for a user. * @returns {ListEmailMessagesResult} List operation result. */ listEmailMessages(input: ListEmailMessagesInput): Promise; /** * Get the list of email messages for the specified email address. * * @param {ListEmailMessagesForEmailAddressIdInput} input Parameters used to retrieve a list of email messages for an emailAddressId. * @returns {ListEmailMessagesResult} List operation result. */ listEmailMessagesForEmailAddressId(input: ListEmailMessagesForEmailAddressIdInput): Promise; /** * Get the list of email messages for the specified email folder. * * @param {ListEmailMessagesForEmailFolderIdInput} input Parameters used to retrieve a list of email messages for a folderId. * @returns {ListEmailMessagesResult} List operation result. */ listEmailMessagesForEmailFolderId(input: ListEmailMessagesForEmailFolderIdInput): Promise; /** * Provisions a new email alias with the specified configuration. * * @param {ProvisionEmailAliasInput} input The input parameters for provisioning the email alias * @returns {EmailAlias} A promise that resolves to the newly created email alias */ provisionEmailAlias(input: ProvisionEmailAliasInput): Promise; /** * Deprovisions an existing email alias, permanently removing it from the system. * * @param {DeprovisionEmailAliasInput} input The input parameters for deprovisioning the email alias * @returns {EmailAlias} A promise that resolves to the deprovisioned email alias */ deprovisionEmailAlias(input: DeprovisionEmailAliasInput): Promise; /** * Updates the metadata or expiration date of an existing email alias. * * @param {UpdateEmailAliasInput} input The input parameters for updating the email alias * @returns {EmailAlias} A promise that resolves to the updated email alias */ updateEmailAlias(input: UpdateEmailAliasInput): Promise; /** * Enables a previously disabled email alias, allowing it to forward emails again. * * @param {EnableEmailAliasInput} input The input parameters for enabling the email alias * @returns {EmailAlias} A promise that resolves to the enabled email alias */ enableEmailAlias(input: EnableEmailAliasInput): Promise; /** * Disables an active email alias, preventing it from forwarding emails. * * @param {DisableEmailAliasInput} input The input parameters for disabling the email alias * @returns {EmailAlias} A promise that resolves to the disabled email alias */ disableEmailAlias(input: DisableEmailAliasInput): Promise; /** * Lists email aliases owned by the current user, with optional filtering and pagination. * * @deprecated Use {@link listEmailAliases} instead * @param {ListEmailAliasesForOwnerInput} input The input parameters for filtering and pagination * @returns {ListOutput} A promise that resolves to a list of email aliases and pagination info */ listEmailAliasesForOwner(input?: ListEmailAliasesForOwnerInput): Promise>; /** * Lists email aliases owned by the current user, with optional filtering and pagination. * * @param {ListEmailAliasesInput} input The input parameters for filtering and pagination * @returns {ListOutput} A promise that resolves to a list of email aliases and pagination info */ listEmailAliases(input?: ListEmailAliasesInput): Promise>; /** * Retrieve a specific {@link EmailAlias} by it's unique id * * @param {GetEmailAliasByIdInput} input The input parameters for retrieving an EmailAlias * @returns {EmailAlias} A promise that resolves to the retrieved EmailAlias * @throws {EmailAliasNotFoundError} If EmailAlias is not found */ getEmailAliasById(input: GetEmailAliasByIdInput): Promise; /** * Sends an email verification code or verifies an external email address given a verification code. * * @param {VerifyExternalEmailAddressInput} input The input parameters for verifying an external email address * @returns {VerifyExternalEmailAddressResult | undefined} A promise that resolves to a result if a verification code was * provided in the request or undefined if a verification code was sent. */ verifyExternalEmailAddress(input: VerifyExternalEmailAddressInput): Promise; /** * Subscribe to email message events. * * @param {string} subscriptionId unique identifier to differentiate subscriptions; note that specifying a duplicate subscription * id will replace the previous subscription. * @param {EmailMessageSubscriber} subscriber implementation of callback to be invoked when email message event occurs * @returns {void} */ subscribeToEmailMessages(subscriptionId: string, subscriber: EmailMessageSubscriber): Promise; /** * Unsubscribe from email message events. * * @param {string} subscriptionId unique identifier to differentiate subscription * @returns {void} **/ unsubscribeFromEmailMessages(subscriptionId: string): void; /** * Get the configuration data for the email service. * * @returns {ConfigurationData} The configuration data for the email service. */ getConfigurationData(): Promise; /** * Export the cryptographic keys to a key archive. * * @return Key archive data. */ exportKeys(): Promise; /** * Imports cryptographic keys from a key archive produced by `exportKeys`. * * The archive replaces the keys in the key store. It's read and checked first, so an archive that is invalid or * that this client can't import leaves the existing keys in place. An archive with no keys imports nothing and * leaves the existing keys in place. * * The archive's keys must be in this client's key namespace. * * If saving the keys fails, the existing keys have already been removed, so restore them from the app's own * copy, such as an archive exported before the import. * * @param archiveData Key archive data to import the keys from. * * @throws {@link InvalidArgumentError} if `archiveData` is empty. * @throws {@link InvalidKeyArchiveError} if the archive is invalid. The existing keys are unchanged. * @throws {@link KeyArchiveNotImportableError} if the archive contains keys this client can't import, for * example keys exported under a different key namespace. The existing keys are unchanged. */ importKeys(archiveData: ArrayBuffer): Promise; /** * Creates the singleton key pair that every email address and email alias is registered with, if the key store * doesn't have it. * * Requires `SudoEmailClientConfig.enforceSingletonPublicKey`. Call it once the user is signed in, before * provisioning: provisioning never creates the key, and fails with `SingletonKeyPairNotFoundError` without it. * * The result says whether the key had to be created. If it was, the key store has changed, so back the keys up * again with `exportKeys`. If the user already has email addresses or aliases, a new key also means this * client's key store doesn't have the one they're registered with (for example another browser, or one whose keys * were removed), so import the user's key backup with `importKeys`. * * @returns {CreateSingletonKeysIfAbsentResult} Whether the singleton key pair was created, and its identifier. * * @throws {@link InvalidConfigError} if the client doesn't enforce a singleton key pair. */ createSingletonKeysIfAbsent(): Promise; /** * Sets an optional callback to handle sign-in when operations are attempted * while not signed in. * * When set, all operations (exception subscriptions and initialization/reset) will * check sign-in status before performing their normal behavior. If the client is * not signed in, the callback will be invoked to allow the host app to perform * sign-in. Once the callback completes, then the client will attempt the original * operation that triggered the callback. * If the callback throws an error, then the error will be propagated to the caller * and the original operation will not be attempted. * To clear the callback, call this method with no arguments or undefined. */ setSignInCallback(callback?: SudoPlatformSignInCallback): void; /** * Flush all cached message bodies scoped to the given sudo or email address. * Call this after deleting a sudo or deprovisioning an email address. * * @param input Parameters specifying the scope of the flush. */ flushMessageBodyCache(input: FlushMessageBodyCacheInput): Promise; /** * Update the maximum size of the local message body cache. * The new limit is persisted and survives across client sessions. * Set to 0 to disable caching; existing cached entries are evicted * immediately when the limit is reduced. * * @param bytes New cache size limit in bytes. Must be >= 0. */ setCacheSizeLimit(bytes: number): Promise; /** * Removes all keys associated with this client and any cached data maintained by this client. * * The keys removed include the singleton key pair, so call `createSingletonKeysIfAbsent` again before * provisioning if the client enforces one. */ reset(): Promise; } /** * Options for how a `DefaultSudoEmailClient` manages the key pairs that email addresses and email aliases are * provisioned with. * * | `enforceSingletonPublicKey` | `allowCallerManagedKeys` | Key used when provisioning | Removed on deprovision | * | --- | --- | --- | --- | * | `false` | `true` (default) | Supplied `keyId`, otherwise a new key pair | Nothing | * | `false` | `false` | Always a new key pair (`keyId` rejected) | The address's key pairs, unless still in use | * | `true` | `true` | Supplied `keyId`, otherwise the singleton | Nothing | * | `true` | `false` | Always the singleton (`keyId` rejected) | Nothing | * * Only `false`/`false` ties a key pair's lifecycle to provisioning and deprovisioning. * * Single key mode registers the same public key for every address and alias, so the email service must allow * address public key reuse. Otherwise the second registration fails. */ export type SudoEmailClientConfig = { /** * Whether every email address and email alias is provisioned with one shared key pair instead of a key pair of * its own. * * When `true`, the app creates the singleton with `createSingletonKeysIfAbsent` before provisioning. The client * never creates it itself: provisioning without it throws `SingletonKeyPairNotFoundError`. Deprovisioning never * removes any key pair; only `reset` removes the singleton. * * Defaults to `false`. */ enforceSingletonPublicKey?: boolean; /** * Whether the app may supply the key pair an email address or email alias is provisioned with, through the * `keyId` of `ProvisionEmailAddressInput` or `ProvisionEmailAliasInput`. * * When `true`, the app manages the key pairs it supplies, so the client never removes a key pair when an email * address is deprovisioned. Key pairs the client generated itself are still removed when the service rejects the * provisioning they were generated for. * * When `false`, the client manages every key pair itself: provisioning with a `keyId` throws * `InvalidArgumentError`, and deprovisioning an email address removes its key pairs from the key store, except a * key pair another email address or email alias still uses, and the singleton key pair. Nothing is removed while * `enforceSingletonPublicKey` is `true`. * * Defaults to `true`. */ allowCallerManagedKeys?: boolean; }; export type SudoEmailClientOptions = { /** Sudo User client to use. No default */ sudoUserClient: SudoUserClient; /** * SudoCryptoProvider to use. Default is to create a WebSudoCryptoProvider * with the key namespace `DEFAULT_KEY_NAMESPACE` (`'sudo-email'`). * * Versions of this SDK before the introduction of that default stored keys under the namespace * `'SudoEmailClient'`. An app with keys under it can keep using them by supplying a `WebSudoCryptoProvider` * created with that namespace, or migrate them by exporting from a client using the old provider and * importing into one using the default. */ sudoCryptoProvider?: SudoCryptoProvider; /** SudoKeyManager to use. Default is to create a DefaultSudoKeyManager */ sudoKeyManager?: SudoKeyManager; /** Client configuration to use. No default */ sudoEmailClientConfig?: SudoEmailClientConfig; };