Page MenuHomePhabricator

D13935.id.diff
No OneTemporary

D13935.id.diff

diff --git a/native/backup/use-client-backup.js b/native/backup/use-client-backup.js
--- a/native/backup/use-client-backup.js
+++ b/native/backup/use-client-backup.js
@@ -16,6 +16,7 @@
type ClientBackup = {
+uploadBackupProtocol: () => Promise<void>,
+ +createUserKeysBackup: () => Promise<void>,
+retrieveLatestBackupInfo: () => Promise<LatestBackupInfo>,
};
@@ -51,6 +52,15 @@
console.info('Backup uploaded.');
}, [loggedIn, currentUserID, currentUserInfo, getBackupSecret]);
+ const createUserKeysBackup = React.useCallback(async () => {
+ if (!loggedIn || !currentUserID) {
+ throw new Error('Attempt to upload User Keys for not logged in user.');
+ }
+
+ const backupSecret = await getBackupSecret();
+ await commCoreModule.createUserKeysBackup(backupSecret);
+ }, [loggedIn, currentUserID, getBackupSecret]);
+
const retrieveLatestBackupInfo = React.useCallback(async () => {
if (!loggedIn || !currentUserID || !currentUserInfo?.username) {
throw new Error('Attempt to restore backup for not logged in user.');
@@ -69,9 +79,10 @@
return React.useMemo(
() => ({
uploadBackupProtocol,
+ createUserKeysBackup,
retrieveLatestBackupInfo,
}),
- [retrieveLatestBackupInfo, uploadBackupProtocol],
+ [retrieveLatestBackupInfo, uploadBackupProtocol, createUserKeysBackup],
);
}
diff --git a/native/profile/backup-menu.react.js b/native/profile/backup-menu.react.js
--- a/native/profile/backup-menu.react.js
+++ b/native/profile/backup-menu.react.js
@@ -39,7 +39,11 @@
state => state.localSettings.isBackupEnabled,
);
- const { uploadBackupProtocol, retrieveLatestBackupInfo } = useClientBackup();
+ const {
+ uploadBackupProtocol,
+ retrieveLatestBackupInfo,
+ createUserKeysBackup,
+ } = useClientBackup();
const uploadBackup = React.useCallback(async () => {
let message = 'Success';
@@ -52,6 +56,17 @@
Alert.alert('Upload protocol result', message);
}, [uploadBackupProtocol]);
+ const uploadUserKeys = React.useCallback(async () => {
+ let message = 'Success';
+ try {
+ await createUserKeysBackup();
+ } catch (e) {
+ message = `User Keys upload error: ${String(getMessageForException(e))}`;
+ console.error(message);
+ }
+ Alert.alert('Upload User Keys result', message);
+ }, [createUserKeysBackup]);
+
const testRestoreForPasswordUser = React.useCallback(async () => {
let message = 'success';
try {
@@ -161,6 +176,17 @@
<Text style={styles.submenuText}>Test backup upload protocol</Text>
</Button>
</View>
+ <View style={styles.section}>
+ <Button
+ onPress={uploadUserKeys}
+ style={styles.row}
+ iosFormat="highlight"
+ iosHighlightUnderlayColor={colors.panelIosHighlightUnderlay}
+ iosActiveOpacity={0.85}
+ >
+ <Text style={styles.submenuText}>Test User Keys upload</Text>
+ </Button>
+ </View>
<View style={styles.section}>
<Button
onPress={onPressRestoreButton}

File Metadata

Mime Type
text/plain
Expires
Mon, Dec 23, 12:25 AM (11 h, 28 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2692947
Default Alt Text
D13935.id.diff (3 KB)

Event Timeline