File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -967,6 +967,20 @@ export class Crypto extends EventEmitter {
967967 fixedBackupKey || sessionBackupKey ,
968968 ) ) ;
969969 await builder . addSessionBackupPrivateKeyToCache ( decodedBackupKey ) ;
970+ } else if ( this . backupManager . getKeyBackupEnabled ( ) ) {
971+ // key backup is enabled but we don't have a session backup key in SSSS: see if we have one in
972+ // the cache or the user can provide one, and if so, write it to SSSS
973+ const backupKey = await this . getSessionBackupPrivateKey ( ) || await getKeyBackupPassphrase ( ) ;
974+ if ( ! backupKey ) {
975+ // This will require user intervention to recover from since we don't have the key
976+ // backup key anywhere. The user should probably just set up a new key backup and
977+ // the key for the new backup will be stored. If we hit this scenario in the wild
978+ // with any frequency, we should do more than just log an error.
979+ logger . error ( "Key backup is enabled but couldn't get key backup key!" ) ;
980+ return ;
981+ }
982+ logger . info ( "Got session backup key from cache/user that wasn't in SSSS: saving to SSSS" ) ;
983+ await secretStorage . store ( "m.megolm_backup.v1" , olmlib . encodeBase64 ( backupKey ) ) ;
970984 }
971985
972986 const operation = builder . buildOperation ( ) ;
You can’t perform that action at this time.
0 commit comments