@sudoplatform/sudo-email
    Preparing search index...

    Class DefaultSudoEmailClient

    Implements

    Index
    • 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 Promise<CreateSingletonKeysIfAbsentResult>

      Whether the singleton key pair was created, and its identifier.

      InvalidConfigError if the client doesn't enforce a singleton key pair.

    • 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.

      Parameters

      • id: string

        The identifier of the email address to deprovision.

      Returns Promise<EmailAddress>

      The deprovisioned email address.

      NotRegisteredError

      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.

    • 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.

      Parameters

      • archiveData: ArrayBuffer

        Key archive data to import the keys from.

      Returns Promise<void>

      InvalidArgumentError if archiveData is empty.

      InvalidKeyArchiveError if the archive is invalid. The existing keys are unchanged.

      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.

    • 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.

      Returns Promise<void>

    • 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.

      Parameters

      • bytes: number

        New cache size limit in bytes. Must be >= 0.

      Returns Promise<void>

    • 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.

      Parameters

      • Optionalcallback: SudoPlatformSignInCallback

      Returns void