Skip to main content

Fetch Data

Data can be retrieved and decrypted via getDataFromCloud. This method fetches the given filename, or the first file in the directory, decrypts the data, and deserializes the data into the requested shape.

Parameters

NameTypeDescription
cloudTypeCloudTypeThe type of cloud service to use ('iCloud' or 'gDrive')
backupPasswordstringThe password used for decrypting the data
filenamestring (optional)The name of the file to retrieve. If not provided, the most recent file will be retrieved.
optsOmit<CloudOptions<T>, 'scope' 'encryptor'> (optional)Additional options for customization. See below for more information.

Options

The CloudOptions<T> object allows you to customize the behavior of encryptAndSaveDataToCloud by specifying alternate implementations for certain tasks. The available options are:

NameTypeDescription
decryptor(pass: string, cipher: string) => string (optional)An alternate function to use for decrypting the data. By default, AES-256-CBC is used.
pathstring (optional)An alternate path to use for the saved file on the cloud service. By default, the file is saved in the REMOTE_BACKUP_WALLET_DIR directory.
serialize(data: T) => string (optional)An alternate function to use for serializing the data before it is encrypted and saved. By default, JSON.stringify is used.

Return value

A Promise that resolves to the retrieved and decrypted data.