refactor: root key manager (#2344)

This commit is contained in:
Mo
2023-07-04 07:31:50 -05:00
committed by GitHub
parent b4a90025c4
commit b06999d25b
56 changed files with 1400 additions and 1231 deletions

View File

@@ -207,13 +207,13 @@ export class BaseMigration extends Migration {
this.services.challengeService.addChallengeObserver(challenge, {
onNonvalidatedSubmit: async (challengeResponse) => {
const password = challengeResponse.values[0].value as string
const accountParams = this.services.protocolService.createKeyParams(rawAccountParams)
const rootKey = await this.services.protocolService.computeRootKey(password, accountParams)
const accountParams = this.services.encryptionService.createKeyParams(rawAccountParams)
const rootKey = await this.services.encryptionService.computeRootKey(password, accountParams)
/** TS can't detect we returned early above if itemToDecrypt is null */
assert(itemToDecrypt)
const decryptedPayload = await this.services.protocolService.decryptSplitSingle({
const decryptedPayload = await this.services.encryptionService.decryptSplitSingle({
usesRootKey: {
items: [itemToDecrypt],
key: rootKey,

View File

@@ -13,7 +13,7 @@ import { ChallengeService, SNSingletonManager, SNFeaturesService, DiskStorageSer
import { LegacySession, MapperInterface } from '@standardnotes/domain-core'
export type MigrationServices = {
protocolService: EncryptionService
encryptionService: EncryptionService
deviceInterface: DeviceInterface
storageService: DiskStorageService
challengeService: ChallengeService

View File

@@ -14,8 +14,8 @@ export class Migration2_0_15 extends Migration {
}
private async createNewDefaultItemsKeyIfNecessary() {
if (this.services.protocolService.needsNewRootKeyBasedItemsKey()) {
await this.services.protocolService.createNewDefaultItemsKey()
if (this.services.encryptionService.needsNewRootKeyBasedItemsKey()) {
await this.services.encryptionService.createNewDefaultItemsKey()
}
}
}