@badgerclaw/connect 1.1.1 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/matrix/client/backup.ts +19 -6
package/package.json
CHANGED
|
@@ -48,19 +48,32 @@ export async function setupKeyBackup(client: MatrixClient): Promise<void> {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
try {
|
|
51
|
-
|
|
51
|
+
let backupInfo = await client.getKeyBackupVersion();
|
|
52
|
+
|
|
53
|
+
if (!backupInfo) {
|
|
54
|
+
// No backup exists — create one now
|
|
55
|
+
LogService.info("MatrixKeyBackup", "No key backup found — creating server-side key backup");
|
|
56
|
+
try {
|
|
57
|
+
backupInfo = await (client as any).signAndCreateKeyBackupVersion({
|
|
58
|
+
algorithm: "m.megolm_backup.v1.curve25519-aes-sha2",
|
|
59
|
+
auth_data: {},
|
|
60
|
+
});
|
|
61
|
+
LogService.info("MatrixKeyBackup", `Created new key backup version ${backupInfo?.version}`);
|
|
62
|
+
} catch (createErr) {
|
|
63
|
+
LogService.warn("MatrixKeyBackup", "Failed to create key backup version:", createErr);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
52
68
|
if (!backupInfo) {
|
|
53
|
-
LogService.info
|
|
54
|
-
"MatrixKeyBackup",
|
|
55
|
-
"No key backup version found on server — skipping backup setup",
|
|
56
|
-
);
|
|
69
|
+
LogService.warn("MatrixKeyBackup", "Key backup info unavailable after creation attempt");
|
|
57
70
|
return;
|
|
58
71
|
}
|
|
59
72
|
|
|
60
73
|
await client.crypto.enableKeyBackup(backupInfo);
|
|
61
74
|
LogService.info(
|
|
62
75
|
"MatrixKeyBackup",
|
|
63
|
-
`Key backup enabled (version ${backupInfo.version}) on device ${deviceId}`,
|
|
76
|
+
`Key backup enabled (version ${backupInfo.version}) on device ${deviceId} — keys will upload automatically`,
|
|
64
77
|
);
|
|
65
78
|
_persistBackupRecord(backupInfo.version, deviceId);
|
|
66
79
|
} catch (err) {
|