1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-12-05 17:02:07 +03:00

Restore key backup from stored key

This commit is contained in:
J. Ryan Stinnett
2019-12-12 15:11:48 +00:00
parent 376e56d5fd
commit d35f5152a9

View File

@@ -53,7 +53,7 @@ import { isCryptoAvailable } from './crypto';
import { decodeRecoveryKey } from './crypto/recoverykey'; import { decodeRecoveryKey } from './crypto/recoverykey';
import { keyFromAuthData } from './crypto/key_passphrase'; import { keyFromAuthData } from './crypto/key_passphrase';
import { randomString } from './randomstring'; import { randomString } from './randomstring';
import { encodeBase64 } from '../lib/crypto/olmlib'; import { encodeBase64, decodeBase64 } from '../lib/crypto/olmlib';
const SCROLLBACK_DELAY_MS = 3000; const SCROLLBACK_DELAY_MS = 3000;
const CRYPTO_ENABLED = isCryptoAvailable(); const CRYPTO_ENABLED = isCryptoAvailable();
@@ -1634,6 +1634,15 @@ MatrixClient.prototype.restoreKeyBackupWithPassword = async function(
); );
}; };
MatrixClient.prototype.restoreKeyBackupWithSecretStorage = async function(
backupInfo, targetRoomId, targetSessionId,
) {
const privKey = decodeBase64(await this.getSecret("m.megolm_backup.v1"));
return this._restoreKeyBackup(
privKey, targetRoomId, targetSessionId, backupInfo,
);
};
MatrixClient.prototype.restoreKeyBackupWithRecoveryKey = function( MatrixClient.prototype.restoreKeyBackupWithRecoveryKey = function(
recoveryKey, targetRoomId, targetSessionId, backupInfo, recoveryKey, targetRoomId, targetSessionId, backupInfo,
) { ) {