mirror of
https://github.com/element-hq/element-web
synced 2024-11-29 04:48:50 +03:00
Respond to backup key sharing requests
This commit is contained in:
parent
d869ac9a69
commit
4d63c11f26
1 changed files with 25 additions and 10 deletions
|
@ -145,18 +145,33 @@ const onSecretRequested = async function({
|
||||||
console.log(`CrossSigningManager: Ignoring request from untrusted device ${deviceId}`);
|
console.log(`CrossSigningManager: Ignoring request from untrusted device ${deviceId}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const callbacks = client.getCrossSigningCacheCallbacks();
|
if (name.startsWith("m.cross_signing")) {
|
||||||
if (!callbacks.getCrossSigningKeyCache) return;
|
const callbacks = client.getCrossSigningCacheCallbacks();
|
||||||
if (name === "m.cross_signing.self_signing") {
|
if (!callbacks.getCrossSigningKeyCache) return;
|
||||||
const key = await callbacks.getCrossSigningKeyCache("self_signing");
|
/* Explicit enumeration here is deliberate – never share the master key! */
|
||||||
if (!key) {
|
if (name === "m.cross_signing.self_signing") {
|
||||||
console.log(`self_signing requested by ${deviceId}, but not found in cache`);
|
const key = await callbacks.getCrossSigningKeyCache("self_signing");
|
||||||
|
if (!key) {
|
||||||
|
console.log(
|
||||||
|
`self_signing requested by ${deviceId}, but not found in cache`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return key && encodeBase64(key);
|
||||||
|
} else if (name === "m.cross_signing.user_signing") {
|
||||||
|
const key = await callbacks.getCrossSigningKeyCache("user_signing");
|
||||||
|
if (!key) {
|
||||||
|
console.log(
|
||||||
|
`user_signing requested by ${deviceId}, but not found in cache`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return key && encodeBase64(key);
|
||||||
}
|
}
|
||||||
return key && encodeBase64(key);
|
} else if (name === "m.megolm_backup.v1") {
|
||||||
} else if (name === "m.cross_signing.user_signing") {
|
const key = await client._crypto.getSessionBackupPrivateKey();
|
||||||
const key = await callbacks.getCrossSigningKeyCache("user_signing");
|
|
||||||
if (!key) {
|
if (!key) {
|
||||||
console.log(`user_signing requested by ${deviceId}, but not found in cache`);
|
console.log(
|
||||||
|
`session backup key requested by ${deviceId}, but not found in cache`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return key && encodeBase64(key);
|
return key && encodeBase64(key);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue