refactor: root key manager (#2344)
This commit is contained in:
@@ -92,11 +92,11 @@ describe('upgrading', () => {
|
||||
version: oldVersion,
|
||||
})
|
||||
|
||||
expect((await this.application.protocolService.rootKeyEncryption.getRootKeyWrapperKeyParams()).version).to.equal(
|
||||
expect((await this.application.encryptionService.rootKeyManager.getRootKeyWrapperKeyParams()).version).to.equal(
|
||||
oldVersion,
|
||||
)
|
||||
expect((await this.application.protocolService.getRootKeyParams()).version).to.equal(oldVersion)
|
||||
expect((await this.application.protocolService.getRootKey()).keyVersion).to.equal(oldVersion)
|
||||
expect((await this.application.encryptionService.getRootKeyParams()).version).to.equal(oldVersion)
|
||||
expect((await this.application.encryptionService.getRootKey()).keyVersion).to.equal(oldVersion)
|
||||
|
||||
this.application.setLaunchCallback({
|
||||
receiveChallenge: this.receiveChallenge,
|
||||
@@ -104,15 +104,15 @@ describe('upgrading', () => {
|
||||
const result = await this.application.upgradeProtocolVersion()
|
||||
expect(result).to.deep.equal({ success: true })
|
||||
|
||||
const wrappedRootKey = await this.application.protocolService.rootKeyEncryption.getWrappedRootKey()
|
||||
const wrappedRootKey = await this.application.encryptionService.rootKeyManager.getWrappedRootKey()
|
||||
const payload = new EncryptedPayload(wrappedRootKey)
|
||||
expect(payload.version).to.equal(newVersion)
|
||||
|
||||
expect((await this.application.protocolService.rootKeyEncryption.getRootKeyWrapperKeyParams()).version).to.equal(
|
||||
expect((await this.application.encryptionService.rootKeyManager.getRootKeyWrapperKeyParams()).version).to.equal(
|
||||
newVersion,
|
||||
)
|
||||
expect((await this.application.protocolService.getRootKeyParams()).version).to.equal(newVersion)
|
||||
expect((await this.application.protocolService.getRootKey()).keyVersion).to.equal(newVersion)
|
||||
expect((await this.application.encryptionService.getRootKeyParams()).version).to.equal(newVersion)
|
||||
expect((await this.application.encryptionService.getRootKey()).keyVersion).to.equal(newVersion)
|
||||
|
||||
/**
|
||||
* Immediately logging out ensures we don't rely on subsequent
|
||||
@@ -172,7 +172,7 @@ describe('upgrading', () => {
|
||||
|
||||
it('protocol version should be upgraded on password change', async function () {
|
||||
/** Delete default items key that is created on launch */
|
||||
const itemsKey = await this.application.protocolService.getSureDefaultItemsKey()
|
||||
const itemsKey = await this.application.encryptionService.getSureDefaultItemsKey()
|
||||
await this.application.mutator.setItemToBeDeleted(itemsKey)
|
||||
expect(Uuids(this.application.itemManager.getDisplayableItemsKeys()).includes(itemsKey.uuid)).to.equal(false)
|
||||
|
||||
@@ -188,8 +188,8 @@ describe('upgrading', () => {
|
||||
|
||||
expect(this.application.itemManager.getDisplayableItemsKeys().length).to.equal(1)
|
||||
|
||||
expect((await this.application.protocolService.getRootKeyParams()).version).to.equal(ProtocolVersion.V003)
|
||||
expect((await this.application.protocolService.getRootKey()).keyVersion).to.equal(ProtocolVersion.V003)
|
||||
expect((await this.application.encryptionService.getRootKeyParams()).version).to.equal(ProtocolVersion.V003)
|
||||
expect((await this.application.encryptionService.getRootKey()).keyVersion).to.equal(ProtocolVersion.V003)
|
||||
|
||||
/** Ensure note is encrypted with 003 */
|
||||
const notePayloads = await Factory.getStoragePayloadsOfType(this.application, ContentType.Note)
|
||||
@@ -199,11 +199,11 @@ describe('upgrading', () => {
|
||||
const { error } = await this.application.changePassword(this.password, 'foobarfoo')
|
||||
expect(error).to.not.exist
|
||||
|
||||
const latestVersion = this.application.protocolService.getLatestVersion()
|
||||
expect((await this.application.protocolService.getRootKeyParams()).version).to.equal(latestVersion)
|
||||
expect((await this.application.protocolService.getRootKey()).keyVersion).to.equal(latestVersion)
|
||||
const latestVersion = this.application.encryptionService.getLatestVersion()
|
||||
expect((await this.application.encryptionService.getRootKeyParams()).version).to.equal(latestVersion)
|
||||
expect((await this.application.encryptionService.getRootKey()).keyVersion).to.equal(latestVersion)
|
||||
|
||||
const defaultItemsKey = await this.application.protocolService.getSureDefaultItemsKey()
|
||||
const defaultItemsKey = await this.application.encryptionService.getSureDefaultItemsKey()
|
||||
expect(defaultItemsKey.keyVersion).to.equal(latestVersion)
|
||||
|
||||
/** After change, note should now be encrypted with latest protocol version */
|
||||
@@ -247,19 +247,19 @@ describe('upgrading', () => {
|
||||
this.application.setLaunchCallback({
|
||||
receiveChallenge: this.receiveChallenge,
|
||||
})
|
||||
expect((await this.application.protocolService.rootKeyEncryption.getRootKeyWrapperKeyParams()).version).to.equal(
|
||||
expect((await this.application.encryptionService.rootKeyManager.getRootKeyWrapperKeyParams()).version).to.equal(
|
||||
oldVersion,
|
||||
)
|
||||
const errors = await this.application.upgradeProtocolVersion()
|
||||
expect(errors).to.not.be.empty
|
||||
|
||||
/** Ensure we're still on 003 */
|
||||
expect((await this.application.protocolService.rootKeyEncryption.getRootKeyWrapperKeyParams()).version).to.equal(
|
||||
expect((await this.application.encryptionService.rootKeyManager.getRootKeyWrapperKeyParams()).version).to.equal(
|
||||
oldVersion,
|
||||
)
|
||||
expect((await this.application.protocolService.getRootKeyParams()).version).to.equal(oldVersion)
|
||||
expect((await this.application.protocolService.getRootKey()).keyVersion).to.equal(oldVersion)
|
||||
expect((await this.application.protocolService.getSureDefaultItemsKey()).keyVersion).to.equal(oldVersion)
|
||||
expect((await this.application.encryptionService.getRootKeyParams()).version).to.equal(oldVersion)
|
||||
expect((await this.application.encryptionService.getRootKey()).keyVersion).to.equal(oldVersion)
|
||||
expect((await this.application.encryptionService.getSureDefaultItemsKey()).keyVersion).to.equal(oldVersion)
|
||||
})
|
||||
|
||||
it('rolls back the local protocol upgrade if the server responds with an error', async function () {
|
||||
@@ -268,19 +268,19 @@ describe('upgrading', () => {
|
||||
this.application.setLaunchCallback({
|
||||
receiveChallenge: this.receiveChallenge,
|
||||
})
|
||||
expect((await this.application.protocolService.rootKeyEncryption.getRootKeyWrapperKeyParams()).version).to.equal(
|
||||
expect((await this.application.encryptionService.rootKeyManager.getRootKeyWrapperKeyParams()).version).to.equal(
|
||||
oldVersion,
|
||||
)
|
||||
const errors = await this.application.upgradeProtocolVersion()
|
||||
expect(errors).to.not.be.empty
|
||||
|
||||
/** Ensure we're still on 003 */
|
||||
expect((await this.application.protocolService.rootKeyEncryption.getRootKeyWrapperKeyParams()).version).to.equal(
|
||||
expect((await this.application.encryptionService.rootKeyManager.getRootKeyWrapperKeyParams()).version).to.equal(
|
||||
oldVersion,
|
||||
)
|
||||
expect((await this.application.protocolService.getRootKeyParams()).version).to.equal(oldVersion)
|
||||
expect((await this.application.protocolService.getRootKey()).keyVersion).to.equal(oldVersion)
|
||||
expect((await this.application.protocolService.getSureDefaultItemsKey()).keyVersion).to.equal(oldVersion)
|
||||
expect((await this.application.encryptionService.getRootKeyParams()).version).to.equal(oldVersion)
|
||||
expect((await this.application.encryptionService.getRootKey()).keyVersion).to.equal(oldVersion)
|
||||
expect((await this.application.encryptionService.getSureDefaultItemsKey()).keyVersion).to.equal(oldVersion)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user