coven/storage_credentials.rs
1//! Restore-code access and S3 credential changes on an open handle.
2
3use super::*;
4
5impl CovenHandle {
6 /// This member's current restore code, for their other devices (§13.1).
7 /// It carries no S3 key.
8 pub async fn restore_code(&self) -> Result<String, SyncError> {
9 self.codes.restore_code().await
10 }
11
12 /// This member's current restore code for the app to show in a QR code
13 /// to the person's own new device, behind the same tap (§13.1, E10). On
14 /// S3 it carries the key this device uses now, so the new device asks for
15 /// none; after a replacement it is the new key. Without a key, on other
16 /// providers or when this device holds none, it is `restore_code`'s.
17 pub async fn restore_code_for_transfer(&self) -> Result<String, SyncError> {
18 self.codes.transfer_code().await
19 }
20
21 /// Commit a replacement S3 key and publish its id; the restore code is unchanged (E9).
22 /// A publication failure retains the credentials; retry with the same key.
23 /// Coven never deletes the key it replaces; the person deletes it in the
24 /// provider's console (§14.3).
25 /// Once this member's removal applies, returns Removed and saves nothing.
26 pub async fn replace_access_key(
27 &self,
28 access_key_id: String,
29 secret_access_key: SecretText,
30 ) -> Result<(), SyncError> {
31 self.storage.replace_access_key(access_key_id, secret_access_key).await
32 }
33
34 /// Install this member's separately supplied S3 key (E9). Identity, location
35 /// and restore code stay unchanged; disconnected handles keep it for connecting.
36 /// Once this member's removal applies, returns Removed and saves nothing:
37 /// the key would return to the person entries the removal emptied (§14.1).
38 pub async fn update_credentials(
39 &self,
40 access_key_id: String,
41 secret_access_key: SecretText,
42 ) -> Result<(), SyncError> {
43 self.storage.update_credentials(access_key_id, secret_access_key).await
44 }
45}