refactor: root key manager (#2344)
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user