mirror of https://github.com/vector-im/riot-web
parent
7865f15ac2
commit
a61462bc85
|
@ -98,11 +98,24 @@ async function getSecretStorageKey(
|
||||||
{ keys: keyInfos }: { keys: Record<string, ISecretStorageKeyInfo> },
|
{ keys: keyInfos }: { keys: Record<string, ISecretStorageKeyInfo> },
|
||||||
ssssItemName,
|
ssssItemName,
|
||||||
): Promise<[string, Uint8Array]> {
|
): Promise<[string, Uint8Array]> {
|
||||||
const keyInfoEntries = Object.entries(keyInfos);
|
const cli = MatrixClientPeg.get();
|
||||||
if (keyInfoEntries.length > 1) {
|
let keyId = await cli.getDefaultSecretStorageKeyId();
|
||||||
throw new Error("Multiple storage key requests not implemented");
|
let keyInfo;
|
||||||
|
if (keyId) {
|
||||||
|
// use the default SSSS key if set
|
||||||
|
keyInfo = keyInfos[keyId];
|
||||||
|
if (!keyInfo) {
|
||||||
|
throw new Error("Unable to use default SSSS key");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// if no default SSSS key is set, fall back to a heuristic of using the
|
||||||
|
// only available key, if only one key is set
|
||||||
|
const keyInfoEntries = Object.entries(keyInfos);
|
||||||
|
if (keyInfoEntries.length > 1) {
|
||||||
|
throw new Error("Multiple storage key requests not implemented");
|
||||||
|
}
|
||||||
|
[keyId, keyInfo] = keyInfoEntries[0];
|
||||||
}
|
}
|
||||||
const [keyId, keyInfo] = keyInfoEntries[0];
|
|
||||||
|
|
||||||
// Check the in-memory cache
|
// Check the in-memory cache
|
||||||
if (isCachingAllowed() && secretStorageKeys[keyId]) {
|
if (isCachingAllowed() && secretStorageKeys[keyId]) {
|
||||||
|
|
Loading…
Reference in New Issue