-
-
Notifications
You must be signed in to change notification settings - Fork 602
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Device Dehydration | js-sdk: store/load dehydration key #4599
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I only did a quick review because the the compiler errors are distracting
const keyB64 = await this.secretStorage.get(SECRET_STORAGE_NAME); | ||
if (keyB64 === undefined) { | ||
if (!create) { | ||
return null; | ||
} | ||
await this.resetKey(); | ||
} else { | ||
this.key = decodeBase64(keyB64); | ||
const bytes = decodeBase64(keyB64); | ||
const key = RustSdkCryptoJs.DehydratedDeviceKey.createKeyFromArray(bytes); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bytes
should be zeroed out after this line, to avoid keeping the key in memory
@@ -190,7 +202,7 @@ export class DehydratedDeviceManager { | |||
* Returns whether or not a dehydrated device was found. | |||
*/ | |||
public async rehydrateDeviceIfAvailable(): Promise<boolean> { | |||
const key = await this.getKey(false); | |||
const key = (await this.getCachedKey()) || (await this.getKey(false)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is getCachedKey
called, when getKey
already calls getCachedKey
and returns its value if it's non-empty?
Fixes #4483
Draft because depends on rust-sdk: matrix-org/matrix-rust-sdk#4399 and needs new wasm bindings version.
Added basic support to cache created keys and read from store instead of in memory.
Then adding some basic signalling to DeviceDehydrationManager, helpfull for tests and also for apps to have some feedbacks on device rehydration (reports progress for example)
Checklist
public
/exported
symbols have accurate TSDoc documentation.