To enable encryption in an Appservice, you must provide both a standard IStorageProvider and a RustSdkAppserviceCryptoStorageProvider. The standard storage handles general appservice data, while the crypto storage handles encryption keys.
Important: Always back up both the storage file (e.g., appservice.json) and the directory used for cryptoStorage to prevent data loss.
In the IAppserviceOptions, you can enable encryption globally for all appservice users (including the sender_localpart user) by setting intentOptions.encryption to true.
const storage = new SimpleFsStorageProvider("./path/to/appservice.json");
const cryptoStorage = new RustSdkAppserviceCryptoStorageProvider("./path/to/directory");
const options: IAppserviceOptions = {
storage: storage,
cryptoStorage: cryptoStorage,
intentOptions: {
// Enable encryption on all appservice users, including the `sender_localpart` user
encryption: true,
},
};
const appservice = new Appservice(options);