-
-
Notifications
You must be signed in to change notification settings - Fork 590
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
replace prepareKeyBackupVersion by resetKeyBackup #3662
Conversation
if (setupNewKeyBackup) { | ||
await this.resetKeyBackup(); | ||
} |
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.
this seems to be adding new functionality, which doesn't really fit with the title of this PR (which implies we are just replacing the existing implementation). Maybe we should separate the new rust impl from the changes to the existing code? It's hard to review at the moment as it feels like we're doing two quite different things.
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 think that's the main point of the PR? to have boostraping complete now and creating a complete backup?
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 think that's the main point of the PR? to have boostraping complete now and creating a complete backup?
Yeah, that's probably fair. But then we should rename the PR to reflect what it's actually doing.
The problem is, I'm struggling to come up with a short summary of the PR. "Add new CryptoApi.resetKeyBackup
and CryptoApi.deleteKeyBackupVersion
APIs, and enable backups in RustCrypto.bootstrapSecretStorage
". What a mouthful!
All of which is to say... I feel like this PR is doing lots of things, and we should probably have broken it down. Which may be one of the reasons it has had 119 comments so far, and multiple rounds of review.
It may be too late now, but I think we can learn from this in the future.
expect(activeBackup).toStrictEqual(backupVersion); | ||
}); | ||
|
||
it("Reset key backup should create a new backup and update 4S", async () => { |
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.
seems like this isn't part of the tests for bootstrapSecretStorage
so should be moved outside the describe
block?
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.
refactored.
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.
refactored.
I don't see any changes here. It's still inside the describe("bootstrapSecretStorage" ... )
block.
spec/integ/crypto/crypto.spec.ts
Outdated
}); | ||
|
||
it("Reset key backup should create a new backup and update 4S", async () => { | ||
// First setup recovery |
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.
// First setup recovery | |
// First set up recovery |
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.
also, what is recovery?
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.
Recovery is 4S (cross signing and megolm backup)
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.
Recovery is 4S (cross signing and megolm backup)
Please could the comment say that then?
/** | ||
* Deletes the given backup. | ||
* | ||
* @param version - The version to delete. | ||
*/ | ||
public async deleteKeyBackupVersion(version: string): Promise<void> { | ||
await this.backupManager.deleteKeyBackupVersion(version); | ||
} | ||
|
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.
this still needs to be moved, please.
* The decryption key will be saved in Secret Storage (the `SecretStorageCallbacks.getSecretStorageKey` Crypto | ||
* callback will be called) | ||
* and the backup engine will be started. |
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.
* The decryption key will be saved in Secret Storage (the `SecretStorageCallbacks.getSecretStorageKey` Crypto | |
* callback will be called) | |
* and the backup engine will be started. | |
* The decryption key will be saved in Secret Storage (the {@link SecretStorageCallbacks#getSecretStorageKey} | |
* callback will be called) and the backup engine will be started. |
@@ -56,3 +58,35 @@ export function mockSetupCrossSigningRequests(): void { | |||
{}, | |||
); | |||
} | |||
|
|||
/** | |||
* Mock out requests to `/room_keys/version`. |
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.
* Mock out requests to `/room_keys/version`. | |
* Mock out requests to `/room_keys/version`. |
|
||
/** | ||
* Holds information of a created keybackup. | ||
* Useful to get the generated private key material and save it securely somewhere. |
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.
* Useful to get the generated private key material and save it securely somewhere. | |
* | |
* Useful to get the generated private key material and save it securely somewhere. |
public async resetKeyBackup(): Promise<void> { | ||
// Delete existing ones | ||
await this.backupManager.deleteKeyBackup(); | ||
// There is no use case for having several key backup version live server side. |
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.
// There is no use case for having several key backup version live server side. | |
// There is no use case for having several key backup versions live server side. |
/** | ||
* Prepare the keybackup version data, auth_data not signed at this point | ||
* @returns a {@link PreparedKeyBackupVersion} with all information about the creation. | ||
*/ | ||
private async prepareKeyBackupVersion(): Promise<PreparedKeyBackupVersion> { |
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.
(and same naming that legacy code)
this is not necessarily a good thing.
I think my problem is that "prepare" is very vague. We can keep the name of the method if you like but please expand the tsdoc to explain more clearly what it does.
spec/test-utils/mockEndpoints.ts
Outdated
* Returns 404 `M_NOT_FOUND` for GET `/room_keys/version` request until POST `room_keys/version` is called. | ||
* Once the POST is done GET `/room_keys/version` will return the posted backup instead of 404 | ||
* | ||
* @param backupVersion The version of the backup to create |
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.
done
Not as far as I can see?
* Once the POST is done, `GET /room_keys/version` will return the posted backup | ||
* instead of 404. | ||
* | ||
* @param backupVersion - The version of the backup to create |
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.
this still needs an update, per #3662 (comment)
// Return the newly created key in the sync response | ||
sendSyncResponse(secretStorageKey); | ||
|
||
// Wait for the cross signing keys to be uploaded |
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.
// Wait for the cross signing keys to be uploaded | |
// Wait for the cross signing keys and backup key to be uploaded |
expect(activeBackup).toStrictEqual(backupVersion); | ||
}); | ||
|
||
it("Reset key backup should create a new backup and update 4S", async () => { |
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.
refactored.
I don't see any changes here. It's still inside the describe("bootstrapSecretStorage" ... )
block.
Fixes https://github.com/vector-im/crypto-internal/issues/107
Checklist
This change is marked as an internal change (Task), so will not be included in the changelog.