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

@@ -31,7 +31,7 @@ describe('001 protocol operations', () => {
})
it('cost minimum', () => {
expect(application.protocolService.costMinimumForVersion('001')).to.equal(3000)
expect(application.encryptionService.costMinimumForVersion('001')).to.equal(3000)
})
it('generates valid keys for registration', async () => {
@@ -46,7 +46,7 @@ describe('001 protocol operations', () => {
it('generates valid keys from existing params and decrypts', async () => {
const password = 'password'
const keyParams = await application.protocolService.createKeyParams({
const keyParams = await application.encryptionService.createKeyParams({
pw_func: 'pbkdf2',
pw_alg: 'sha512',
pw_key_size: 512,
@@ -67,7 +67,7 @@ describe('001 protocol operations', () => {
'sVuHmG0XAp1PRDE8r8XqFXijjP8Pqdwal9YFRrXK4hKLt1yyq8MwQU+1Z95Tz/b7ajYdidwFE0iDwd8Iu8281VtJsQ4yhh2tJiAzBy6newyHfhA5nH93yZ3iXRJaG87bgNQE9lsXzTV/OHAvqMuQtw/QVSWI3Qy1Pyu1Tn72q7FPKKhRRkzEEZ+Ax0BA1fHg',
uuid: '54001a6f-7c22-4b34-8316-fadf9b1fc255',
})
const decrypted = await application.protocolService.decryptSplitSingle({
const decrypted = await application.encryptionService.decryptSplitSingle({
usesRootKey: {
items: [payload],
key: key,

View File

@@ -30,7 +30,7 @@ describe('002 protocol operations', () => {
})
it('cost minimum', () => {
expect(application.protocolService.costMinimumForVersion('002')).to.equal(3000)
expect(application.encryptionService.costMinimumForVersion('002')).to.equal(3000)
})
it('generates valid keys for registration', async () => {
@@ -46,7 +46,7 @@ describe('002 protocol operations', () => {
it('generates valid keys from existing params and decrypts', async () => {
const password = 'password'
const keyParams = await application.protocolService.createKeyParams({
const keyParams = await application.encryptionService.createKeyParams({
pw_salt: '8d381ef44cdeab1489194f87066b747b46053a833ee24956e846e7b40440f5f4',
pw_cost: 101000,
version: '002',
@@ -64,7 +64,7 @@ describe('002 protocol operations', () => {
'002:24a8e8f7728bbe06605d8209d87ad338d3d15ef81154bb64d3967c77daa01333:959b042a-3892-461e-8c50-477c10c7c40a:f1d294388742dca34f6f266a01483a4e:VdlEDyjhZ35GbJDg8ruSZv3Tp6WtMME3T5LLvcBYLHIMhrMi0RlPK83lK6F0aEaZvY82pZ0ntU+XpAX7JMSEdKdPXsACML7WeFrqKb3z2qHnA7NxgnIC0yVT/Z2mRrvlY3NNrUPGwJbfRcvfS7FVyw87MemT9CSubMZRviXvXETx82t7rsgjV/AIwOOeWhFi',
uuid: '959b042a-3892-461e-8c50-477c10c7c40a',
})
const decrypted = await application.protocolService.decryptSplitSingle({
const decrypted = await application.encryptionService.decryptSplitSingle({
usesRootKey: {
items: [payload],
key: key,

View File

@@ -39,7 +39,7 @@ describe('003 protocol operations', () => {
it('cost minimum should throw', () => {
expect(() => {
sharedApplication.protocolService.costMinimumForVersion('003')
sharedApplication.encryptionService.costMinimumForVersion('003')
}).to.throw('Cost minimums only apply to versions <= 002')
})
@@ -59,7 +59,7 @@ describe('003 protocol operations', () => {
it('computes proper keys for sign in', async () => {
const identifier = 'foo@bar.com'
const password = 'very_secure'
const keyParams = sharedApplication.protocolService.createKeyParams({
const keyParams = sharedApplication.encryptionService.createKeyParams({
pw_nonce: 'baaec0131d677cf993381367eb082fe377cefe70118c1699cb9b38f0bc850e7b',
identifier: identifier,
version: '003',
@@ -73,7 +73,7 @@ describe('003 protocol operations', () => {
it('can decrypt item generated with web version 3.3.6', async () => {
const identifier = 'demo@standardnotes.org'
const password = 'password'
const keyParams = sharedApplication.protocolService.createKeyParams({
const keyParams = sharedApplication.encryptionService.createKeyParams({
pw_nonce: '31107837b44d86179140b7c602a55d694243e2e9ced0c4c914ac21ad90215055',
identifier: identifier,
version: '003',

View File

@@ -25,12 +25,12 @@ describe('004 protocol operations', function () {
it('cost minimum should throw', function () {
expect(function () {
application.protocolService.costMinimumForVersion('004')
application.encryptionService.costMinimumForVersion('004')
}).to.throw('Cost minimums only apply to versions <= 002')
})
it('generates valid keys for registration', async function () {
const key = await application.protocolService.createRootKey(
const key = await application.encryptionService.createRootKey(
_identifier,
_password,
KeyParamsOrigination.Registration,
@@ -51,7 +51,7 @@ describe('004 protocol operations', function () {
it('computes proper keys for sign in', async function () {
const identifier = 'foo@bar.com'
const password = 'very_secure'
const keyParams = application.protocolService.createKeyParams({
const keyParams = application.encryptionService.createKeyParams({
pw_nonce: 'baaec0131d677cf993381367eb082fe377cefe70118c1699cb9b38f0bc850e7b',
identifier: identifier,
version: '004',
@@ -64,7 +64,7 @@ describe('004 protocol operations', function () {
it('generates random key', async function () {
const length = 96
const key = await application.protocolService.crypto.generateRandomKey(length)
const key = await application.encryptionService.crypto.generateRandomKey(length)
expect(key.length).to.equal(length / 4)
})
@@ -78,7 +78,7 @@ describe('004 protocol operations', function () {
}),
})
const operator = application.protocolService.operatorManager.operatorForVersion(ProtocolVersion.V004)
const operator = application.encryptionService.operators.operatorForVersion(ProtocolVersion.V004)
const encrypted = await operator.generateEncryptedParameters(payload, rootKey)
const decrypted = await operator.generateDecryptedParameters(encrypted, rootKey)
@@ -97,7 +97,7 @@ describe('004 protocol operations', function () {
}),
})
const operator = application.protocolService.operatorManager.operatorForVersion(ProtocolVersion.V004)
const operator = application.encryptionService.operators.operatorForVersion(ProtocolVersion.V004)
const encrypted = await operator.generateEncryptedParameters(payload, rootKey)
const decrypted = await operator.generateDecryptedParameters(
@@ -112,7 +112,7 @@ describe('004 protocol operations', function () {
})
it('generates existing keys for key params', async function () {
const key = await application.protocolService.computeRootKey(_password, rootKeyParams)
const key = await application.encryptionService.computeRootKey(_password, rootKeyParams)
expect(key.compare(rootKey)).to.be.true
})

View File

@@ -25,7 +25,7 @@ describe('actions service', () => {
password: this.password,
})
const rootKey = await this.application.protocolService.createRootKey(
const rootKey = await this.application.encryptionService.createRootKey(
this.email,
this.password,
KeyParamsOrigination.Registration,
@@ -117,7 +117,7 @@ describe('actions service', () => {
})
const encryptedPayload = CreateEncryptedServerSyncPushPayload(
await this.application.protocolService.encryptSplitSingle({
await this.application.encryptionService.encryptSplitSingle({
usesItemsKeyWithKeyLookup: {
items: [payload],
},
@@ -359,14 +359,14 @@ describe('actions service', () => {
const response = await this.actionsManager.runAction(this.encryptedPostAction, this.noteItem)
expect(response.items[0].enc_item_key).to.satisfy((string) => {
return string.startsWith(this.application.protocolService.getLatestVersion())
return string.startsWith(this.application.encryptionService.getLatestVersion())
})
expect(response.items[0].uuid).to.eq(this.noteItem.uuid)
expect(response.items[0].auth_hash).to.not.be.ok
expect(response.items[0].content_type).to.be.ok
expect(response.items[0].created_at).to.be.ok
expect(response.items[0].content).to.satisfy((string) => {
return string.startsWith(this.application.protocolService.getLatestVersion())
return string.startsWith(this.application.encryptionService.getLatestVersion())
})
})

View File

@@ -31,7 +31,7 @@ describe('basic auth', function () {
it('successfully register new account', async function () {
const response = await this.application.register(this.email, this.password)
expect(response).to.be.ok
expect(await this.application.protocolService.getRootKey()).to.be.ok
expect(await this.application.encryptionService.getRootKey()).to.be.ok
})
it('fails register new account with short password', async function () {
@@ -49,18 +49,18 @@ describe('basic auth', function () {
'For your security, please choose a longer password or, ideally, a passphrase, and try again.',
)
expect(await this.application.protocolService.getRootKey()).to.not.be.ok
expect(await this.application.encryptionService.getRootKey()).to.not.be.ok
})
it('successfully signs out of account', async function () {
await this.application.register(this.email, this.password)
expect(await this.application.protocolService.getRootKey()).to.be.ok
expect(await this.application.encryptionService.getRootKey()).to.be.ok
this.application = await Factory.signOutApplicationAndReturnNew(this.application)
expect(await this.application.protocolService.getRootKey()).to.not.be.ok
expect(this.application.protocolService.rootKeyEncryption.keyMode).to.equal(KeyMode.RootKeyNone)
expect(await this.application.encryptionService.getRootKey()).to.not.be.ok
expect(this.application.encryptionService.rootKeyManager.getKeyMode()).to.equal(KeyMode.RootKeyNone)
})
it('successfully signs in to registered account', async function () {
@@ -69,7 +69,7 @@ describe('basic auth', function () {
const response = await this.application.signIn(this.email, this.password, undefined, undefined, undefined, true)
expect(response).to.be.ok
expect(response.data.error).to.not.be.ok
expect(await this.application.protocolService.getRootKey()).to.be.ok
expect(await this.application.encryptionService.getRootKey()).to.be.ok
}).timeout(20000)
it('cannot sign while already signed in', async function () {
@@ -79,7 +79,7 @@ describe('basic auth', function () {
const response = await this.application.signIn(this.email, this.password, undefined, undefined, undefined, true)
expect(response).to.be.ok
expect(response.data.error).to.not.be.ok
expect(await this.application.protocolService.getRootKey()).to.be.ok
expect(await this.application.encryptionService.getRootKey()).to.be.ok
let error
try {
@@ -99,7 +99,7 @@ describe('basic auth', function () {
error = e
}
expect(error).to.be.ok
expect(await this.application.protocolService.getRootKey()).to.be.ok
expect(await this.application.encryptionService.getRootKey()).to.be.ok
}).timeout(20000)
it('cannot perform two sign-ins at the same time', async function () {
@@ -111,7 +111,7 @@ describe('basic auth', function () {
const response = await this.application.signIn(this.email, this.password, undefined, undefined, undefined, true)
expect(response).to.be.ok
expect(response.data.error).to.not.be.ok
expect(await this.application.protocolService.getRootKey()).to.be.ok
expect(await this.application.encryptionService.getRootKey()).to.be.ok
})(),
(async () => {
/** Make sure the first function runs first */
@@ -134,7 +134,7 @@ describe('basic auth', function () {
const response = await this.application.register(this.email, this.password)
expect(response).to.be.ok
expect(response.error).to.not.be.ok
expect(await this.application.protocolService.getRootKey()).to.be.ok
expect(await this.application.encryptionService.getRootKey()).to.be.ok
})(),
(async () => {
/** Make sure the first function runs first */
@@ -204,7 +204,7 @@ describe('basic auth', function () {
const response = await this.application.signIn(uppercase, this.password, undefined, undefined, undefined, true)
expect(response).to.be.ok
expect(response.data.error).to.not.be.ok
expect(await this.application.protocolService.getRootKey()).to.be.ok
expect(await this.application.encryptionService.getRootKey()).to.be.ok
}).timeout(20000)
it('can sign into account regardless of whitespace', async function () {
@@ -220,7 +220,7 @@ describe('basic auth', function () {
const response = await this.application.signIn(withspace, this.password, undefined, undefined, undefined, true)
expect(response).to.be.ok
expect(response.data.error).to.not.be.ok
expect(await this.application.protocolService.getRootKey()).to.be.ok
expect(await this.application.encryptionService.getRootKey()).to.be.ok
}).timeout(20000)
it('fails login with wrong password', async function () {
@@ -229,7 +229,7 @@ describe('basic auth', function () {
const response = await this.application.signIn(this.email, 'wrongpassword', undefined, undefined, undefined, true)
expect(response).to.be.ok
expect(response.data.error).to.be.ok
expect(await this.application.protocolService.getRootKey()).to.not.be.ok
expect(await this.application.encryptionService.getRootKey()).to.not.be.ok
}).timeout(20000)
it('fails to change to short password', async function () {
@@ -339,7 +339,7 @@ describe('basic auth', function () {
expect(signinResponse).to.be.ok
expect(signinResponse.data.error).to.not.be.ok
expect(await this.application.protocolService.getRootKey()).to.be.ok
expect(await this.application.encryptionService.getRootKey()).to.be.ok
expect(this.application.itemManager.items.length).to.equal(this.expectedItemCount)
expect(this.application.payloadManager.invalidPayloads.length).to.equal(0)
@@ -421,7 +421,7 @@ describe('basic auth', function () {
expect(signinResponse).to.be.ok
expect(signinResponse.data.error).to.not.be.ok
expect(await this.application.protocolService.getRootKey()).to.be.ok
expect(await this.application.encryptionService.getRootKey()).to.be.ok
}
}).timeout(80000)

View File

@@ -27,10 +27,10 @@ describe('backups', function () {
it('backup file should have a version number', async function () {
let data = await this.application.createDecryptedBackupFile()
expect(data.version).to.equal(this.application.protocolService.getLatestVersion())
expect(data.version).to.equal(this.application.encryptionService.getLatestVersion())
await this.application.addPasscode('passcode')
data = await this.application.createEncryptedBackupFileForAutomatedDesktopBackups()
expect(data.version).to.equal(this.application.protocolService.getLatestVersion())
expect(data.version).to.equal(this.application.encryptionService.getLatestVersion())
})
it('no passcode + no account backup file should have correct number of items', async function () {
@@ -143,7 +143,7 @@ describe('backups', function () {
const note = await Factory.createSyncedNote(this.application)
const encrypted = await this.application.protocolService.encryptSplitSingle({
const encrypted = await this.application.encryptionService.encryptSplitSingle({
usesItemsKeyWithKeyLookup: {
items: [note.payload],
},

View File

@@ -22,7 +22,7 @@ describe('device authentication', function () {
await application.addPasscode(passcode)
expect(await application.hasPasscode()).to.equal(true)
expect(await application.protectionService.createLaunchChallenge()).to.be.ok
expect(application.protocolService.rootKeyEncryption.keyMode).to.equal(KeyMode.WrapperOnly)
expect(application.encryptionService.rootKeyManager.getKeyMode()).to.equal(KeyMode.WrapperOnly)
await Factory.safeDeinit(application)
/** Recreate application and initialize */
@@ -49,10 +49,10 @@ describe('device authentication', function () {
tmpApplication.submitValuesForChallenge(challenge, initialValues)
}
await tmpApplication.prepareForLaunch({ receiveChallenge })
expect(await tmpApplication.protocolService.getRootKey()).to.not.be.ok
expect(await tmpApplication.encryptionService.getRootKey()).to.not.be.ok
await tmpApplication.launch(true)
expect(await tmpApplication.protocolService.getRootKey()).to.be.ok
expect(tmpApplication.protocolService.rootKeyEncryption.keyMode).to.equal(KeyMode.WrapperOnly)
expect(await tmpApplication.encryptionService.getRootKey()).to.be.ok
expect(tmpApplication.encryptionService.rootKeyManager.getKeyMode()).to.equal(KeyMode.WrapperOnly)
await Factory.safeDeinit(tmpApplication)
}).timeout(10000)
@@ -65,7 +65,7 @@ describe('device authentication', function () {
await application.protections.enableBiometrics()
expect(await application.hasPasscode()).to.equal(true)
expect((await application.protectionService.createLaunchChallenge()).prompts.length).to.equal(2)
expect(application.protocolService.rootKeyEncryption.keyMode).to.equal(KeyMode.WrapperOnly)
expect(application.encryptionService.rootKeyManager.getKeyMode()).to.equal(KeyMode.WrapperOnly)
await Factory.safeDeinit(application)
/** Recreate application and initialize */
@@ -98,11 +98,11 @@ describe('device authentication', function () {
}
await tmpApplication.prepareForLaunch({ receiveChallenge })
expect(await tmpApplication.protocolService.getRootKey()).to.not.be.ok
expect(await tmpApplication.encryptionService.getRootKey()).to.not.be.ok
expect((await tmpApplication.protectionService.createLaunchChallenge()).prompts.length).to.equal(2)
await tmpApplication.launch(true)
expect(await tmpApplication.protocolService.getRootKey()).to.be.ok
expect(tmpApplication.protocolService.rootKeyEncryption.keyMode).to.equal(KeyMode.WrapperOnly)
expect(await tmpApplication.encryptionService.getRootKey()).to.be.ok
expect(tmpApplication.encryptionService.rootKeyManager.getKeyMode()).to.equal(KeyMode.WrapperOnly)
await Factory.safeDeinit(tmpApplication)
}).timeout(Factory.TwentySecondTimeout)
@@ -119,11 +119,11 @@ describe('device authentication', function () {
const sampleStorageKey = 'foo'
const sampleStorageValue = 'bar'
await application.diskStorageService.setValue(sampleStorageKey, sampleStorageValue)
expect(application.protocolService.rootKeyEncryption.keyMode).to.equal(KeyMode.RootKeyOnly)
expect(application.encryptionService.rootKeyManager.getKeyMode()).to.equal(KeyMode.RootKeyOnly)
const passcode = 'foobar'
Factory.handlePasswordChallenges(application, password)
await application.addPasscode(passcode)
expect(application.protocolService.rootKeyEncryption.keyMode).to.equal(KeyMode.RootKeyPlusWrapper)
expect(application.encryptionService.rootKeyManager.getKeyMode()).to.equal(KeyMode.RootKeyPlusWrapper)
expect(await application.hasPasscode()).to.equal(true)
await Factory.safeDeinit(application)
@@ -154,11 +154,11 @@ describe('device authentication', function () {
await tmpApplication.prepareForLaunch({
receiveChallenge: receiveChallenge,
})
expect(await tmpApplication.protocolService.getRootKey()).to.not.be.ok
expect(await tmpApplication.encryptionService.getRootKey()).to.not.be.ok
await tmpApplication.launch(true)
expect(await tmpApplication.diskStorageService.getValue(sampleStorageKey)).to.equal(sampleStorageValue)
expect(await tmpApplication.protocolService.getRootKey()).to.be.ok
expect(tmpApplication.protocolService.rootKeyEncryption.keyMode).to.equal(KeyMode.RootKeyPlusWrapper)
expect(await tmpApplication.encryptionService.getRootKey()).to.be.ok
expect(tmpApplication.encryptionService.rootKeyManager.getKeyMode()).to.equal(KeyMode.RootKeyPlusWrapper)
await Factory.safeDeinit(tmpApplication)
}).timeout(Factory.TwentySecondTimeout)
})

View File

@@ -37,21 +37,21 @@ describe('key recovery service', function () {
await context.register()
const randomRootKey = await application.protocolService.createRootKey(
const randomRootKey = await application.encryptionService.createRootKey(
unassociatedIdentifier,
unassociatedPassword,
KeyParamsOrigination.Registration,
)
const randomItemsKey = await application.protocolService.operatorManager.defaultOperator().createItemsKey()
const randomItemsKey = await application.encryptionService.operators.defaultOperator().createItemsKey()
const encrypted = await application.protocolService.encryptSplitSingle({
const encrypted = await application.encryptionService.encryptSplitSingle({
usesRootKey: {
items: [randomItemsKey.payload],
key: randomRootKey,
},
})
const errored = await application.protocolService.decryptSplitSingle({
const errored = await application.encryptionService.decryptSplitSingle({
usesRootKeyWithKeyLookup: {
items: [encrypted],
},
@@ -89,13 +89,13 @@ describe('key recovery service', function () {
})
await context.register()
const randomRootKey = await application.protocolService.createRootKey(
const randomRootKey = await application.encryptionService.createRootKey(
unassociatedIdentifier,
unassociatedPassword,
KeyParamsOrigination.Registration,
)
const randomItemsKey = await application.protocolService.operatorManager.defaultOperator().createItemsKey()
const randomItemsKey = await application.encryptionService.operators.defaultOperator().createItemsKey()
await application.payloadManager.emitPayload(
randomItemsKey.payload.copy({ dirty: true, dirtyIndex: getIncrementedDirtyIndex() }),
@@ -106,14 +106,14 @@ describe('key recovery service', function () {
const originalSyncTime = application.payloadManager.findOne(randomItemsKey.uuid).lastSyncEnd.getTime()
const encrypted = await application.protocolService.encryptSplitSingle({
const encrypted = await application.encryptionService.encryptSplitSingle({
usesRootKey: {
items: [randomItemsKey.payload],
key: randomRootKey,
},
})
const errored = await application.protocolService.decryptSplitSingle({
const errored = await application.encryptionService.decryptSplitSingle({
usesRootKeyWithKeyLookup: {
items: [encrypted],
},
@@ -214,15 +214,15 @@ describe('key recovery service', function () {
})
/** Create items key associated with a random root key */
const randomRootKey = await application.protocolService.createRootKey(
const randomRootKey = await application.encryptionService.createRootKey(
unassociatedIdentifier,
unassociatedPassword,
KeyParamsOrigination.Registration,
)
const randomItemsKey = await application.protocolService.operatorManager.defaultOperator().createItemsKey()
const randomItemsKey2 = await application.protocolService.operatorManager.defaultOperator().createItemsKey()
const randomItemsKey = await application.encryptionService.operators.defaultOperator().createItemsKey()
const randomItemsKey2 = await application.encryptionService.operators.defaultOperator().createItemsKey()
const encrypted = await application.protocolService.encryptSplit({
const encrypted = await application.encryptionService.encryptSplit({
usesRootKey: {
items: [randomItemsKey.payload, randomItemsKey2.payload],
key: randomRootKey,
@@ -230,7 +230,7 @@ describe('key recovery service', function () {
})
/** Attempt decryption and insert into rotation in errored state */
const decrypted = await application.protocolService.decryptSplit({
const decrypted = await application.encryptionService.decryptSplit({
usesRootKeyWithKeyLookup: {
items: encrypted,
},
@@ -293,8 +293,8 @@ describe('key recovery service', function () {
expect(key.errorDecrypting).to.not.be.ok
}
const aKey = await contextA.application.protocolService.getRootKey()
const bKey = await contextB.application.protocolService.getRootKey()
const aKey = await contextA.application.encryptionService.getRootKey()
const bKey = await contextB.application.encryptionService.getRootKey()
expect(aKey.compare(bKey)).to.equal(true)
expect(contextA.application.items.findItem(note.uuid).errorDecrypting).to.not.be.ok
@@ -379,7 +379,7 @@ describe('key recovery service', function () {
await application.launch(true)
await context.register()
const correctRootKey = await application.protocolService.getRootKey()
const correctRootKey = await application.encryptionService.getRootKey()
/**
* 1. Change our root key locally so that its keys params doesn't match the server's
@@ -390,7 +390,7 @@ describe('key recovery service', function () {
const unassociatedIdentifier = 'foorand'
/** Create items key associated with a random root key */
const randomRootKey = await application.protocolService.createRootKey(
const randomRootKey = await application.encryptionService.createRootKey(
unassociatedIdentifier,
unassociatedPassword,
KeyParamsOrigination.Registration,
@@ -398,11 +398,11 @@ describe('key recovery service', function () {
const signInFunction = sinon.spy(application.keyRecoveryService, 'performServerSignIn')
await application.protocolService.setRootKey(randomRootKey)
await application.encryptionService.setRootKey(randomRootKey)
const correctItemsKey = await application.protocolService.operatorManager.defaultOperator().createItemsKey()
const correctItemsKey = await application.encryptionService.operators.defaultOperator().createItemsKey()
const encrypted = await application.protocolService.encryptSplitSingle({
const encrypted = await application.encryptionService.encryptSplitSingle({
usesRootKey: {
items: [correctItemsKey.payload],
key: randomRootKey,
@@ -428,7 +428,7 @@ describe('key recovery service', function () {
expect(signInFunction.callCount).to.equal(1)
const clientRootKey = await application.protocolService.getRootKey()
const clientRootKey = await application.encryptionService.getRootKey()
expect(clientRootKey.compare(correctRootKey)).to.equal(true)
const decryptedKey = application.items.findItem(correctItemsKey.uuid)
@@ -448,8 +448,8 @@ describe('key recovery service', function () {
await context.register()
/** Create and emit errored encrypted items key payload */
const itemsKey = await application.protocolService.getSureDefaultItemsKey()
const encrypted = await application.protocolService.encryptSplitSingle({
const itemsKey = await application.encryptionService.getSureDefaultItemsKey()
const encrypted = await application.encryptionService.encryptSplitSingle({
usesRootKeyWithKeyLookup: {
items: [itemsKey.payload],
},
@@ -485,8 +485,8 @@ describe('key recovery service', function () {
await context.launch()
await context.register()
const itemsKey = await application.protocolService.getSureDefaultItemsKey()
const encrypted = await application.protocolService.encryptSplitSingle({
const itemsKey = await application.encryptionService.getSureDefaultItemsKey()
const encrypted = await application.encryptionService.encryptSplitSingle({
usesRootKeyWithKeyLookup: {
items: [itemsKey.payload],
},
@@ -524,8 +524,8 @@ describe('key recovery service', function () {
await context.register()
/** Create and emit errored encrypted items key payload */
const itemsKey = await application.protocolService.getSureDefaultItemsKey()
const encrypted = await application.protocolService.encryptSplitSingle({
const itemsKey = await application.encryptionService.getSureDefaultItemsKey()
const encrypted = await application.encryptionService.encryptSplitSingle({
usesRootKeyWithKeyLookup: {
items: [itemsKey.payload],
},
@@ -589,17 +589,17 @@ describe('key recovery service', function () {
})
/** Create items key associated with a random root key */
const randomRootKey = await application.protocolService.createRootKey(
const randomRootKey = await application.encryptionService.createRootKey(
unassociatedIdentifier,
unassociatedPassword,
KeyParamsOrigination.Registration,
ProtocolVersion.V003,
)
const randomItemsKey = await application.protocolService.operatorManager
const randomItemsKey = await application.encryptionService.operators
.operatorForVersion(ProtocolVersion.V003)
.createItemsKey()
const encrypted = await application.protocolService.encryptSplitSingle({
const encrypted = await application.encryptionService.encryptSplitSingle({
usesRootKey: {
items: [randomItemsKey.payload],
key: randomRootKey,
@@ -607,7 +607,7 @@ describe('key recovery service', function () {
})
/** Attempt decryption and insert into rotation in errored state */
const decrypted = await application.protocolService.decryptSplitSingle({
const decrypted = await application.encryptionService.decryptSplitSingle({
usesRootKeyWithKeyLookup: {
items: [encrypted],
},
@@ -653,9 +653,9 @@ describe('key recovery service', function () {
contextA.password = newPassword
await appB.sync.sync()
const newDefaultKey = appB.protocolService.getSureDefaultItemsKey()
const newDefaultKey = appB.encryptionService.getSureDefaultItemsKey()
const encrypted = await appB.protocolService.encryptSplitSingle({
const encrypted = await appB.encryptionService.encryptSplitSingle({
usesRootKeyWithKeyLookup: {
items: [newDefaultKey.payload],
},
@@ -676,13 +676,13 @@ describe('key recovery service', function () {
const stored = (await appA.deviceInterface.getAllDatabaseEntries(appA.identifier)).find(
(payload) => payload.uuid === newDefaultKey.uuid,
)
const storedParams = await appA.protocolService.getKeyEmbeddedKeyParamsFromItemsKey(new EncryptedPayload(stored))
const storedParams = await appA.encryptionService.getKeyEmbeddedKeyParamsFromItemsKey(new EncryptedPayload(stored))
const correctStored = (await appB.deviceInterface.getAllDatabaseEntries(appB.identifier)).find(
(payload) => payload.uuid === newDefaultKey.uuid,
)
const correctParams = await appB.protocolService.getKeyEmbeddedKeyParamsFromItemsKey(
const correctParams = await appB.encryptionService.getKeyEmbeddedKeyParamsFromItemsKey(
new EncryptedPayload(correctStored),
)

View File

@@ -29,7 +29,7 @@ describe('keys', function () {
})
it('should not have root key by default', async function () {
expect(await this.application.protocolService.getRootKey()).to.not.be.ok
expect(await this.application.encryptionService.getRootKey()).to.not.be.ok
})
it('validates content types requiring root encryption', function () {
@@ -43,7 +43,7 @@ describe('keys', function () {
/** Items key available by default */
const payload = Factory.createNotePayload()
const processedPayload = CreateEncryptedLocalStorageContextPayload(
await this.application.protocolService.encryptSplitSingle({
await this.application.encryptionService.encryptSplitSingle({
usesItemsKeyWithKeyLookup: {
items: [payload],
},
@@ -54,44 +54,44 @@ describe('keys', function () {
it('has root key and one items key after registering user', async function () {
await Factory.registerUserToApplication({ application: this.application })
expect(this.application.protocolService.getRootKey()).to.be.ok
expect(this.application.encryptionService.getRootKey()).to.be.ok
expect(this.application.itemManager.getDisplayableItemsKeys().length).to.equal(1)
})
it('changing root key with passcode should re-wrap root key', async function () {
const email = 'foo'
const password = 'bar'
const key = await this.application.protocolService.createRootKey(email, password, KeyParamsOrigination.Registration)
await this.application.protocolService.setRootKey(key)
const key = await this.application.encryptionService.createRootKey(email, password, KeyParamsOrigination.Registration)
await this.application.encryptionService.setRootKey(key)
Factory.handlePasswordChallenges(this.application, password)
await this.application.addPasscode(password)
/** We should be able to decrypt wrapped root key with passcode */
const wrappingKeyParams = await this.application.protocolService.rootKeyEncryption.getRootKeyWrapperKeyParams()
const wrappingKey = await this.application.protocolService.computeRootKey(password, wrappingKeyParams)
await this.application.protocolService.unwrapRootKey(wrappingKey).catch((error) => {
const wrappingKeyParams = await this.application.encryptionService.rootKeyManager.getRootKeyWrapperKeyParams()
const wrappingKey = await this.application.encryptionService.computeRootKey(password, wrappingKeyParams)
await this.application.encryptionService.unwrapRootKey(wrappingKey).catch((error) => {
expect(error).to.not.be.ok
})
const newPassword = 'bar'
const newKey = await this.application.protocolService.createRootKey(
const newKey = await this.application.encryptionService.createRootKey(
email,
newPassword,
KeyParamsOrigination.Registration,
)
await this.application.protocolService.setRootKey(newKey, wrappingKey)
await this.application.protocolService.unwrapRootKey(wrappingKey).catch((error) => {
await this.application.encryptionService.setRootKey(newKey, wrappingKey)
await this.application.encryptionService.unwrapRootKey(wrappingKey).catch((error) => {
expect(error).to.not.be.ok
})
})
it('items key should be encrypted with root key', async function () {
await Factory.registerUserToApplication({ application: this.application })
const itemsKey = await this.application.protocolService.getSureDefaultItemsKey()
const rootKey = await this.application.protocolService.getRootKey()
const itemsKey = await this.application.encryptionService.getSureDefaultItemsKey()
const rootKey = await this.application.encryptionService.getRootKey()
/** Encrypt items key */
const encryptedPayload = await this.application.protocolService.encryptSplitSingle({
const encryptedPayload = await this.application.encryptionService.encryptSplitSingle({
usesRootKey: {
items: [itemsKey.payloadRepresentation()],
key: rootKey,
@@ -102,7 +102,7 @@ describe('keys', function () {
expect(encryptedPayload.items_key_id).to.not.be.ok
/** Attempt to decrypt with root key. Should succeed. */
const decryptedPayload = await this.application.protocolService.decryptSplitSingle({
const decryptedPayload = await this.application.encryptionService.decryptSplitSingle({
usesRootKey: {
items: [encryptedPayload],
key: rootKey,
@@ -142,35 +142,35 @@ describe('keys', function () {
it('should use items key for encryption of note', async function () {
const notePayload = Factory.createNotePayload()
const keyToUse = await this.application.protocolService.itemsEncryption.keyToUseForItemEncryption(notePayload)
const keyToUse = await this.application.encryptionService.itemsEncryption.keyToUseForItemEncryption(notePayload)
expect(keyToUse.content_type).to.equal(ContentType.ItemsKey)
})
it('encrypting an item should associate an items key to it', async function () {
const note = Factory.createNotePayload()
const encryptedPayload = await this.application.protocolService.encryptSplitSingle({
const encryptedPayload = await this.application.encryptionService.encryptSplitSingle({
usesItemsKeyWithKeyLookup: {
items: [note],
},
})
const itemsKey = this.application.protocolService.itemsKeyForEncryptedPayload(encryptedPayload)
const itemsKey = this.application.encryptionService.itemsKeyForEncryptedPayload(encryptedPayload)
expect(itemsKey).to.be.ok
})
it('decrypt encrypted item with associated key', async function () {
const note = Factory.createNotePayload()
const title = note.content.title
const encryptedPayload = await this.application.protocolService.encryptSplitSingle({
const encryptedPayload = await this.application.encryptionService.encryptSplitSingle({
usesItemsKeyWithKeyLookup: {
items: [note],
},
})
const itemsKey = this.application.protocolService.itemsKeyForEncryptedPayload(encryptedPayload)
const itemsKey = this.application.encryptionService.itemsKeyForEncryptedPayload(encryptedPayload)
expect(itemsKey).to.be.ok
const decryptedPayload = await this.application.protocolService.decryptSplitSingle({
const decryptedPayload = await this.application.encryptionService.decryptSplitSingle({
usesItemsKeyWithKeyLookup: {
items: [encryptedPayload],
},
@@ -182,17 +182,17 @@ describe('keys', function () {
it('decrypts items waiting for keys', async function () {
const notePayload = Factory.createNotePayload()
const title = notePayload.content.title
const encryptedPayload = await this.application.protocolService.encryptSplitSingle({
const encryptedPayload = await this.application.encryptionService.encryptSplitSingle({
usesItemsKeyWithKeyLookup: {
items: [notePayload],
},
})
const itemsKey = this.application.protocolService.itemsKeyForEncryptedPayload(encryptedPayload)
const itemsKey = this.application.encryptionService.itemsKeyForEncryptedPayload(encryptedPayload)
await this.application.itemManager.removeItemLocally(itemsKey)
const erroredPayload = await this.application.protocolService.decryptSplitSingle({
const erroredPayload = await this.application.encryptionService.decryptSplitSingle({
usesItemsKeyWithKeyLookup: {
items: [encryptedPayload],
},
@@ -208,7 +208,7 @@ describe('keys', function () {
await this.application.mutator.emitItemsFromPayloads([keyPayload], PayloadEmitSource.LocalChanged)
/**
* Sleeping is required to trigger asyncronous protocolService.decryptItemsWaitingForKeys,
* Sleeping is required to trigger asyncronous encryptionService.decryptItemsWaitingForKeys,
* which occurs after keys are mapped above.
*/
await Factory.sleep(0.2)
@@ -223,7 +223,7 @@ describe('keys', function () {
it('attempting to emit errored items key for which there exists a non errored master copy should ignore it', async function () {
await Factory.registerUserToApplication({ application: this.application })
const itemsKey = await this.application.protocolService.getSureDefaultItemsKey()
const itemsKey = await this.application.encryptionService.getSureDefaultItemsKey()
expect(itemsKey.errorDecrypting).to.not.be.ok
@@ -250,13 +250,13 @@ describe('keys', function () {
it('generating export params with logged in account should produce encrypted payload', async function () {
await Factory.registerUserToApplication({ application: this.application })
const payload = Factory.createNotePayload()
const encryptedPayload = await this.application.protocolService.encryptSplitSingle({
const encryptedPayload = await this.application.encryptionService.encryptSplitSingle({
usesItemsKeyWithKeyLookup: {
items: [payload],
},
})
expect(typeof encryptedPayload.content).to.equal('string')
expect(encryptedPayload.content.substring(0, 3)).to.equal(this.application.protocolService.getLatestVersion())
expect(encryptedPayload.content.substring(0, 3)).to.equal(this.application.encryptionService.getLatestVersion())
})
it('When setting passcode, should encrypt items keys', async function () {
@@ -276,7 +276,7 @@ describe('keys', function () {
const itemsKeyPayload = new EncryptedPayload(itemsKeyRawPayload)
const authenticatedData = this.context.encryption.getEmbeddedPayloadAuthenticatedData(itemsKeyPayload)
const rootKeyParams = await this.application.protocolService.getRootKeyParams()
const rootKeyParams = await this.application.encryptionService.getRootKeyParams()
expect(authenticatedData.kp).to.be.ok
expect(authenticatedData.kp).to.eql(rootKeyParams.getPortableValue())
@@ -286,8 +286,8 @@ describe('keys', function () {
it('correctly validates local passcode', async function () {
const passcode = 'foo'
await this.application.addPasscode('foo')
expect((await this.application.protocolService.validatePasscode('wrong')).valid).to.equal(false)
expect((await this.application.protocolService.validatePasscode(passcode)).valid).to.equal(true)
expect((await this.application.encryptionService.validatePasscode('wrong')).valid).to.equal(false)
expect((await this.application.encryptionService.validatePasscode(passcode)).valid).to.equal(true)
})
it('signing into 003 account should delete latest offline items key and create 003 items key', async function () {
@@ -296,8 +296,8 @@ describe('keys', function () {
* Upon signing into an 003 account, the application should delete any neverSynced items keys,
* and create a new default items key that is the default for a given protocol version.
*/
const defaultItemsKey = await this.application.protocolService.getSureDefaultItemsKey()
const latestVersion = this.application.protocolService.getLatestVersion()
const defaultItemsKey = await this.application.encryptionService.getSureDefaultItemsKey()
const latestVersion = this.application.encryptionService.getLatestVersion()
expect(defaultItemsKey.keyVersion).to.equal(latestVersion)
/** Register with 003 version */
@@ -312,7 +312,7 @@ describe('keys', function () {
expect(itemsKeys.length).to.equal(1)
const newestItemsKey = itemsKeys[0]
expect(newestItemsKey.keyVersion).to.equal(ProtocolVersion.V003)
const rootKey = await this.application.protocolService.getRootKey()
const rootKey = await this.application.encryptionService.getRootKey()
expect(newestItemsKey.itemsKey).to.equal(rootKey.masterKey)
expect(newestItemsKey.dataAuthenticationKey).to.equal(rootKey.dataAuthenticationKey)
})
@@ -347,12 +347,12 @@ describe('keys', function () {
expect(itemsKeys.length).to.equal(1)
const originalItemsKey = itemsKeys[0]
const originalRootKey = await this.application.protocolService.getRootKey()
const originalRootKey = await this.application.encryptionService.getRootKey()
/** Expect that we can decrypt raw payload with current root key */
const rawPayloads = await this.application.diskStorageService.getAllRawPayloads()
const itemsKeyRawPayload = rawPayloads.find((p) => p.uuid === originalItemsKey.uuid)
const itemsKeyPayload = new EncryptedPayload(itemsKeyRawPayload)
const decrypted = await this.application.protocolService.decryptSplitSingle({
const decrypted = await this.application.encryptionService.decryptSplitSingle({
usesRootKey: {
items: [itemsKeyPayload],
key: originalRootKey,
@@ -366,7 +366,7 @@ describe('keys', function () {
Factory.handlePasswordChallenges(this.application, passcode)
await this.application.changePasscode('bar')
const newRootKey = await this.application.protocolService.getRootKey()
const newRootKey = await this.application.encryptionService.getRootKey()
expect(newRootKey).to.not.equal(originalRootKey)
expect(newRootKey.masterKey).to.not.equal(originalRootKey.masterKey)
@@ -379,7 +379,7 @@ describe('keys', function () {
expect(itemsKeyRawPayload2.content).to.not.equal(itemsKeyRawPayload.content)
const itemsKeyPayload2 = new EncryptedPayload(itemsKeyRawPayload2)
const decrypted2 = await this.application.protocolService.decryptSplitSingle({
const decrypted2 = await this.application.encryptionService.decryptSplitSingle({
usesRootKey: {
items: [itemsKeyPayload2],
key: originalRootKey,
@@ -388,7 +388,7 @@ describe('keys', function () {
expect(decrypted2.errorDecrypting).to.equal(true)
/** Should be able to decrypt with new root key */
const decrypted3 = await this.application.protocolService.decryptSplitSingle({
const decrypted3 = await this.application.encryptionService.decryptSplitSingle({
usesRootKey: {
items: [itemsKeyPayload2],
key: newRootKey,
@@ -405,17 +405,17 @@ describe('keys', function () {
})
const itemsKeys = this.application.itemManager.getDisplayableItemsKeys()
expect(itemsKeys.length).to.equal(1)
const defaultItemsKey = await this.application.protocolService.getSureDefaultItemsKey()
const defaultItemsKey = await this.application.encryptionService.getSureDefaultItemsKey()
const result = await this.application.changePassword(this.password, 'foobarfoo')
expect(result.error).to.not.be.ok
expect(this.application.itemManager.getDisplayableItemsKeys().length).to.equal(2)
const newDefaultItemsKey = await this.application.protocolService.getSureDefaultItemsKey()
const newDefaultItemsKey = await this.application.encryptionService.getSureDefaultItemsKey()
expect(newDefaultItemsKey.uuid).to.not.equal(defaultItemsKey.uuid)
const note = await Factory.createSyncedNote(this.application)
const payload = await this.application.protocolService.encryptSplitSingle({
const payload = await this.application.encryptionService.encryptSplitSingle({
usesItemsKeyWithKeyLookup: {
items: [note.payload],
},
@@ -432,18 +432,18 @@ describe('keys', function () {
})
const itemsKeys = application.itemManager.getDisplayableItemsKeys()
expect(itemsKeys.length).to.equal(1)
const defaultItemsKey = application.protocolService.getSureDefaultItemsKey()
const defaultItemsKey = application.encryptionService.getSureDefaultItemsKey()
const newEmail = UuidGenerator.GenerateUuid()
const result = await application.changeEmail(newEmail, password)
expect(result.error).to.not.be.ok
expect(application.itemManager.getDisplayableItemsKeys().length).to.equal(2)
const newDefaultItemsKey = application.protocolService.getSureDefaultItemsKey()
const newDefaultItemsKey = application.encryptionService.getSureDefaultItemsKey()
expect(newDefaultItemsKey.uuid).to.not.equal(defaultItemsKey.uuid)
const note = await Factory.createSyncedNote(application)
const payload = await application.protocolService.encryptSplitSingle({
const payload = await application.encryptionService.encryptSplitSingle({
usesItemsKeyWithKeyLookup: {
items: [note.payload],
},
@@ -480,7 +480,7 @@ describe('keys', function () {
it('loading the keychain root key should also load its key params', async function () {
await Factory.registerUserToApplication({ application: this.application })
const rootKey = await this.application.protocolService.rootKeyEncryption.getRootKeyFromKeychain()
const rootKey = await this.application.encryptionService.rootKeyManager.getRootKeyFromKeychain()
expect(rootKey.keyParams).to.be.ok
})
@@ -497,7 +497,7 @@ describe('keys', function () {
it('persisted key params should exactly equal in memory rootKey.keyParams', async function () {
await Factory.registerUserToApplication({ application: this.application })
const rootKey = await this.application.protocolService.getRootKey()
const rootKey = await this.application.encryptionService.getRootKey()
const rawKeyParams = await this.application.diskStorageService.getValue(
StorageKey.RootKeyParams,
StorageValueModes.Nonwrapped,
@@ -507,7 +507,7 @@ describe('keys', function () {
it('key params should have expected values', async function () {
await Factory.registerUserToApplication({ application: this.application })
const keyParamsObject = await this.application.protocolService.getRootKeyParams()
const keyParamsObject = await this.application.encryptionService.getRootKeyParams()
const keyParams = keyParamsObject.content
expect(keyParams.identifier).to.be.ok
expect(keyParams.pw_nonce).to.be.ok
@@ -533,7 +533,7 @@ describe('keys', function () {
email,
password,
})
const keyParamsObject = await this.application.protocolService.getRootKeyParams()
const keyParamsObject = await this.application.encryptionService.getRootKeyParams()
const keyParams = keyParamsObject.content
expect(keyParams.created).to.be.ok
@@ -551,7 +551,7 @@ describe('keys', function () {
password: this.password,
version: ProtocolVersion.V003,
})
const keyParamsObject = await this.application.protocolService.getRootKeyParams()
const keyParamsObject = await this.application.encryptionService.getRootKeyParams()
const keyParams = keyParamsObject.content
expect(keyParams.created).to.be.ok
@@ -566,12 +566,12 @@ describe('keys', function () {
password: this.password,
version: ProtocolVersion.V003,
})
expect(await this.application.protocolService.getEncryptionDisplayName()).to.equal('AES-256')
expect(await this.application.encryptionService.getEncryptionDisplayName()).to.equal('AES-256')
this.application = await Factory.signOutApplicationAndReturnNew(this.application)
/** Register with 004 account */
await this.application.register(this.email + 'new', this.password)
expect(await this.application.protocolService.getEncryptionDisplayName()).to.equal('XChaCha20-Poly1305')
expect(await this.application.encryptionService.getEncryptionDisplayName()).to.equal('XChaCha20-Poly1305')
})
it('when launching app with no keychain but data, should present account recovery challenge', async function () {
@@ -599,7 +599,7 @@ describe('keys', function () {
await recreatedApp.prepareForLaunch({ receiveChallenge })
await recreatedApp.launch(true)
expect(recreatedApp.protocolService.getRootKey()).to.be.ok
expect(recreatedApp.encryptionService.getRootKey()).to.be.ok
expect(totalChallenges).to.equal(expectedChallenges)
await Factory.safeDeinit(recreatedApp)
})
@@ -684,11 +684,11 @@ describe('keys', function () {
/** Change password through session manager directly instead of application,
* as not to create any items key (to simulate 003 client behavior) */
const currentRootKey = await oldClient.protocolService.computeRootKey(
const currentRootKey = await oldClient.encryptionService.computeRootKey(
this.password,
await oldClient.protocolService.getRootKeyParams(),
await oldClient.encryptionService.getRootKeyParams(),
)
const operator = oldClient.protocolService.operatorManager.operatorForVersion(ProtocolVersion.V003)
const operator = oldClient.encryptionService.operators.operatorForVersion(ProtocolVersion.V003)
const newRootKey = await operator.createRootKey(this.email, this.password)
Object.defineProperty(oldClient.apiService, 'apiVersion', {
get: function () {
@@ -734,11 +734,11 @@ describe('keys', function () {
/** Change password through session manager directly instead of application,
* as not to create any items key (to simulate 003 client behavior) */
const currentRootKey = await this.application.protocolService.computeRootKey(
const currentRootKey = await this.application.encryptionService.computeRootKey(
this.password,
await this.application.protocolService.getRootKeyParams(),
await this.application.encryptionService.getRootKeyParams(),
)
const operator = this.application.protocolService.operatorManager.operatorForVersion(ProtocolVersion.V003)
const operator = this.application.encryptionService.operators.operatorForVersion(ProtocolVersion.V003)
const newRootKeyTemplate = await operator.createRootKey(this.email, this.password)
const newRootKey = CreateNewRootKey({
...newRootKeyTemplate.content,
@@ -761,7 +761,7 @@ describe('keys', function () {
currentServerPassword: currentRootKey.serverPassword,
newRootKey,
})
await this.application.protocolService.reencryptApplicableItemsAfterUserRootKeyChange()
await this.application.encryptionService.reencryptApplicableItemsAfterUserRootKeyChange()
/** Note: this may result in a deadlock if features_service syncs and results in an error */
await this.application.sync.sync({ awaitAll: true })
@@ -786,7 +786,7 @@ describe('keys', function () {
* will have an updated_at value, which tell our protocol service that this key has been
* synced before, which sort of "lies" to the protocol service because now it thinks it doesnt
* need to create a new items key because one has already been synced with the account.
* The corrective action was to do a final check in protocolService.handleDownloadFirstSyncCompletion
* The corrective action was to do a final check in encryptionService.handleDownloadFirstSyncCompletion
* to ensure there exists an items key corresponding to the user's account version.
*/
const promise = this.context.awaitNextSucessfulSync()
@@ -794,7 +794,7 @@ describe('keys', function () {
await promise
await this.application.itemManager.removeAllItemsFromMemory()
expect(this.application.protocolService.getSureDefaultItemsKey()).to.not.be.ok
expect(this.application.encryptionService.getSureDefaultItemsKey()).to.not.be.ok
const protocol003 = new SNProtocolOperator003(new SNWebCrypto())
const key = await protocol003.createItemsKey()
@@ -810,14 +810,14 @@ describe('keys', function () {
}),
)
const defaultKey = this.application.protocolService.getSureDefaultItemsKey()
const defaultKey = this.application.encryptionService.getSureDefaultItemsKey()
expect(defaultKey.keyVersion).to.equal(ProtocolVersion.V003)
expect(defaultKey.uuid).to.equal(key.uuid)
await Factory.registerUserToApplication({ application: this.application })
const notePayload = Factory.createNotePayload()
expect(await this.application.protocolService.itemsEncryption.keyToUseForItemEncryption(notePayload)).to.be.ok
expect(await this.application.encryptionService.itemsEncryption.keyToUseForItemEncryption(notePayload)).to.be.ok
})
it('having unsynced items keys should resync them upon download first sync completion', async function () {
@@ -856,7 +856,7 @@ describe('keys', function () {
email: this.email,
password: this.password,
})
const defaultKeys = otherClient.protocolService.itemsEncryption.getItemsKeys().filter((key) => {
const defaultKeys = otherClient.encryptionService.itemsEncryption.getItemsKeys().filter((key) => {
return key.isDefault
})
expect(defaultKeys.length).to.equal(1)

View File

@@ -70,7 +70,7 @@ export class AppContext {
}
get encryption() {
return this.application.protocolService
return this.application.encryptionService
}
get contacts() {

View File

@@ -112,10 +112,10 @@ export function registerUserToApplication({ application, email, password, epheme
}
export async function setOldVersionPasscode({ application, passcode, version }) {
const identifier = await application.protocolService.crypto.generateUUID()
const operator = application.protocolService.operatorManager.operatorForVersion(version)
const identifier = await application.encryptionService.crypto.generateUUID()
const operator = application.encryptionService.operators.operatorForVersion(version)
const key = await operator.createRootKey(identifier, passcode, KeyParamsOrigination.PasscodeCreate)
await application.protocolService.setNewRootKeyWrapper(key)
await application.encryptionService.setNewRootKeyWrapper(key)
await application.userService.rewriteItemsKeys()
await application.syncService.sync(syncOptions)
}
@@ -127,7 +127,7 @@ export async function setOldVersionPasscode({ application, passcode, version })
export async function registerOldUser({ application, email, password, version }) {
if (!email) email = Utils.generateUuid()
if (!password) password = Utils.generateUuid()
const operator = application.protocolService.operatorManager.operatorForVersion(version)
const operator = application.encryptionService.operators.operatorForVersion(version)
const accountKey = await operator.createRootKey(email, password, KeyParamsOrigination.Registration)
const response = await application.userApiService.register({
@@ -145,7 +145,7 @@ export async function registerOldUser({ application, email, password, version })
mode: SyncMode.DownloadFirst,
...syncOptions,
})
await application.protocolService.decryptErroredPayloads()
await application.encryptionService.decryptErroredPayloads()
}
export function createStorageItemPayload(contentType) {

View File

@@ -282,7 +282,7 @@ describe('app models', () => {
const itemsKey = this.application.itemManager.getDisplayableItemsKeys()[0]
/** Encrypt item1 and emit as errored so it persists with items_key_id */
const encrypted = await this.application.protocolService.encryptSplitSingle({
const encrypted = await this.application.encryptionService.encryptSplitSingle({
usesItemsKeyWithKeyLookup: {
items: [item1.payload],
},
@@ -297,7 +297,7 @@ describe('app models', () => {
expect(this.application.payloadManager.findOne(item1.uuid).errorDecrypting).to.equal(true)
expect(this.application.payloadManager.findOne(item1.uuid).items_key_id).to.equal(itemsKey.uuid)
sinon.stub(this.application.protocolService.itemsEncryption, 'decryptErroredItemPayloads').callsFake(() => {
sinon.stub(this.application.encryptionService.itemsEncryption, 'decryptErroredItemPayloads').callsFake(() => {
// prevent auto decryption
})

View File

@@ -40,7 +40,7 @@ describe('payload encryption', function () {
lastSyncBegan: new Date(),
})
const encryptedPayload = await this.application.protocolService.encryptSplitSingle({
const encryptedPayload = await this.application.encryptionService.encryptSplitSingle({
usesItemsKeyWithKeyLookup: {
items: [notePayload],
},
@@ -114,7 +114,7 @@ describe('payload encryption', function () {
it('returns valid encrypted params for syncing', async function () {
const payload = Factory.createNotePayload()
const encryptedPayload = CreateEncryptedServerSyncPushPayload(
await this.application.protocolService.encryptSplitSingle({
await this.application.encryptionService.encryptSplitSingle({
usesItemsKeyWithKeyLookup: {
items: [payload],
},
@@ -126,7 +126,7 @@ describe('payload encryption', function () {
expect(encryptedPayload.content_type).to.be.ok
expect(encryptedPayload.created_at).to.be.ok
expect(encryptedPayload.content).to.satisfy((string) => {
return string.startsWith(this.application.protocolService.getLatestVersion())
return string.startsWith(this.application.encryptionService.getLatestVersion())
})
}).timeout(5000)
@@ -134,7 +134,7 @@ describe('payload encryption', function () {
const payload = Factory.createNotePayload()
const encryptedPayload = CreateEncryptedLocalStorageContextPayload(
await this.application.protocolService.encryptSplitSingle({
await this.application.encryptionService.encryptSplitSingle({
usesItemsKeyWithKeyLookup: {
items: [payload],
},
@@ -150,14 +150,14 @@ describe('payload encryption', function () {
expect(encryptedPayload.deleted).to.not.be.ok
expect(encryptedPayload.errorDecrypting).to.not.be.ok
expect(encryptedPayload.content).to.satisfy((string) => {
return string.startsWith(this.application.protocolService.getLatestVersion())
return string.startsWith(this.application.encryptionService.getLatestVersion())
})
})
it('omits deleted for export file', async function () {
const payload = Factory.createNotePayload()
const encryptedPayload = CreateEncryptedBackupFileContextPayload(
await this.application.protocolService.encryptSplitSingle({
await this.application.encryptionService.encryptSplitSingle({
usesItemsKeyWithKeyLookup: {
items: [payload],
},
@@ -170,7 +170,7 @@ describe('payload encryption', function () {
expect(encryptedPayload.created_at).to.be.ok
expect(encryptedPayload.deleted).to.not.be.ok
expect(encryptedPayload.content).to.satisfy((string) => {
return string.startsWith(this.application.protocolService.getLatestVersion())
return string.startsWith(this.application.encryptionService.getLatestVersion())
})
})

View File

@@ -19,43 +19,43 @@ describe('protocol', function () {
})
it('checks version to make sure its 004', function () {
expect(this.application.protocolService.getLatestVersion()).to.equal('004')
expect(this.application.encryptionService.getLatestVersion()).to.equal('004')
})
it('checks supported versions to make sure it includes 001, 002, 003, 004', function () {
expect(this.application.protocolService.supportedVersions()).to.eql(['001', '002', '003', '004'])
expect(this.application.encryptionService.supportedVersions()).to.eql(['001', '002', '003', '004'])
})
it('platform derivation support', function () {
expect(
this.application.protocolService.platformSupportsKeyDerivation({
this.application.encryptionService.platformSupportsKeyDerivation({
version: '001',
}),
).to.equal(true)
expect(
this.application.protocolService.platformSupportsKeyDerivation({
this.application.encryptionService.platformSupportsKeyDerivation({
version: '002',
}),
).to.equal(true)
expect(
this.application.protocolService.platformSupportsKeyDerivation({
this.application.encryptionService.platformSupportsKeyDerivation({
version: '003',
}),
).to.equal(true)
expect(
this.application.protocolService.platformSupportsKeyDerivation({
this.application.encryptionService.platformSupportsKeyDerivation({
version: '004',
}),
).to.equal(true)
expect(
this.application.protocolService.platformSupportsKeyDerivation({
this.application.encryptionService.platformSupportsKeyDerivation({
version: '005',
}),
).to.equal(true)
})
it('key params versions <= 002 should include pw_cost in portable value', function () {
const keyParams002 = this.application.protocolService.createKeyParams({
const keyParams002 = this.application.encryptionService.createKeyParams({
version: '002',
pw_cost: 5000,
})
@@ -63,15 +63,15 @@ describe('protocol', function () {
})
it('version comparison of 002 should be older than library version', function () {
expect(this.application.protocolService.isVersionNewerThanLibraryVersion('002')).to.equal(false)
expect(this.application.encryptionService.isVersionNewerThanLibraryVersion('002')).to.equal(false)
})
it('version comparison of 005 should be newer than library version', function () {
expect(this.application.protocolService.isVersionNewerThanLibraryVersion('005')).to.equal(true)
expect(this.application.encryptionService.isVersionNewerThanLibraryVersion('005')).to.equal(true)
})
it('library version should not be outdated', function () {
var currentVersion = this.application.protocolService.getLatestVersion()
var currentVersion = this.application.encryptionService.getLatestVersion()
expect(isProtocolVersionExpired(currentVersion)).to.equal(false)
})
@@ -91,7 +91,7 @@ describe('protocol', function () {
const payload = Factory.createNotePayload()
let error
try {
await this.application.protocolService.decryptSplitSingle({
await this.application.encryptionService.decryptSplitSingle({
usesItemsKeyWithKeyLookup: {
items: [payload],
},
@@ -106,7 +106,7 @@ describe('protocol', function () {
await this.application.addPasscode('123')
const payload = Factory.createNotePayload()
const result = CreateEncryptedServerSyncPushPayload(
await this.application.protocolService.encryptSplitSingle({
await this.application.encryptionService.encryptSplitSingle({
usesItemsKeyWithKeyLookup: {
items: [payload],
},
@@ -121,7 +121,7 @@ describe('protocol', function () {
it('encrypted payload for server should include duplicate_of field', async function () {
const payload = Factory.createNotePayload('Test')
const encryptedPayload = CreateEncryptedServerSyncPushPayload(
await this.application.protocolService.encryptSplitSingle({
await this.application.encryptionService.encryptSplitSingle({
usesItemsKeyWithKeyLookup: {
items: [payload],
},
@@ -134,7 +134,7 @@ describe('protocol', function () {
it('ejected payload for server should include duplicate_of field', async function () {
const payload = Factory.createNotePayload('Test')
const encryptedPayload = CreateEncryptedServerSyncPushPayload(
await this.application.protocolService.encryptSplitSingle({
await this.application.encryptionService.encryptSplitSingle({
usesItemsKeyWithKeyLookup: {
items: [payload],
},
@@ -147,7 +147,7 @@ describe('protocol', function () {
it('encrypted payload for storage should include duplicate_of field', async function () {
const payload = Factory.createNotePayload('Test')
const encryptedPayload = CreateEncryptedLocalStorageContextPayload(
await this.application.protocolService.encryptSplitSingle({
await this.application.encryptionService.encryptSplitSingle({
usesItemsKeyWithKeyLookup: {
items: [payload],
},
@@ -160,7 +160,7 @@ describe('protocol', function () {
it('ejected payload for storage should include duplicate_of field', async function () {
const payload = Factory.createNotePayload('Test')
const encryptedPayload = CreateEncryptedLocalStorageContextPayload(
await this.application.protocolService.encryptSplitSingle({
await this.application.encryptionService.encryptSplitSingle({
usesItemsKeyWithKeyLookup: {
items: [payload],
},
@@ -173,7 +173,7 @@ describe('protocol', function () {
it('encrypted payload for file should include duplicate_of field', async function () {
const payload = Factory.createNotePayload('Test')
const encryptedPayload = CreateEncryptedBackupFileContextPayload(
await this.application.protocolService.encryptSplitSingle({
await this.application.encryptionService.encryptSplitSingle({
usesItemsKeyWithKeyLookup: {
items: [payload],
},
@@ -186,7 +186,7 @@ describe('protocol', function () {
it('ejected payload for file should include duplicate_of field', async function () {
const payload = Factory.createNotePayload('Test')
const encryptedPayload = CreateEncryptedBackupFileContextPayload(
await this.application.protocolService.encryptSplitSingle({
await this.application.encryptionService.encryptSplitSingle({
usesItemsKeyWithKeyLookup: {
items: [payload],
},

View File

@@ -44,7 +44,7 @@ describe('account recovery', function () {
application = await context.signout()
expect(await application.protocolService.getRootKey()).to.not.be.ok
expect(await application.encryptionService.getRootKey()).to.not.be.ok
await application.signInWithRecoveryCodes.execute({
recoveryCodes: generatedRecoveryCodes.getValue(),
@@ -52,7 +52,7 @@ describe('account recovery', function () {
password: context.password,
})
expect(await application.protocolService.getRootKey()).to.be.ok
expect(await application.encryptionService.getRootKey()).to.be.ok
})
it('should automatically generate new recovery code after recovery sign in', async () => {
@@ -96,7 +96,7 @@ describe('account recovery', function () {
application = await context.signout()
expect(await application.protocolService.getRootKey()).to.not.be.ok
expect(await application.encryptionService.getRootKey()).to.not.be.ok
await application.signInWithRecoveryCodes.execute({
recoveryCodes: generatedRecoveryCodes.getValue(),
@@ -104,7 +104,7 @@ describe('account recovery', function () {
password: 'foobar',
})
expect(await application.protocolService.getRootKey()).to.not.be.ok
expect(await application.encryptionService.getRootKey()).to.not.be.ok
})
it('should not allow to sign in with invalid recovery code', async () => {
@@ -112,7 +112,7 @@ describe('account recovery', function () {
application = await context.signout()
expect(await application.protocolService.getRootKey()).to.not.be.ok
expect(await application.encryptionService.getRootKey()).to.not.be.ok
await application.signInWithRecoveryCodes.execute({
recoveryCodes: 'invalid recovery code',
@@ -120,13 +120,13 @@ describe('account recovery', function () {
password: context.paswword,
})
expect(await application.protocolService.getRootKey()).to.not.be.ok
expect(await application.encryptionService.getRootKey()).to.not.be.ok
})
it('should not allow to sign in with recovery code if user has none', async () => {
application = await context.signout()
expect(await application.protocolService.getRootKey()).to.not.be.ok
expect(await application.encryptionService.getRootKey()).to.not.be.ok
await application.signInWithRecoveryCodes.execute({
recoveryCodes: 'foo bar',
@@ -134,6 +134,6 @@ describe('account recovery', function () {
password: context.paswword,
})
expect(await application.protocolService.getRootKey()).to.not.be.ok
expect(await application.encryptionService.getRootKey()).to.not.be.ok
})
})

View File

@@ -574,7 +574,7 @@ describe('server session', function () {
password: password,
})
const oldRootKey = await appA.protocolService.getRootKey()
const oldRootKey = await appA.encryptionService.getRootKey()
/** Set the session as nonsense */
appA.diskStorageService.setValue(StorageKey.Session, {
@@ -597,7 +597,7 @@ describe('server session', function () {
expect(appA.apiService.session.refreshToken.value).to.not.equal('bar')
/** Expect that the session recovery replaces the global root key */
const newRootKey = await appA.protocolService.getRootKey()
const newRootKey = await appA.encryptionService.getRootKey()
expect(oldRootKey).to.not.equal(newRootKey)
await Factory.safeDeinit(appA)

View File

@@ -171,7 +171,7 @@ describe('storage manager', function () {
password: this.password,
ephemeral: true,
})
const accountKey = await this.application.protocolService.getRootKey()
const accountKey = await this.application.encryptionService.getRootKey()
expect(await this.application.diskStorageService.canDecryptWithKey(accountKey)).to.equal(true)
})
@@ -201,7 +201,7 @@ describe('storage manager', function () {
})
/** Should not be wrapped root key yet */
expect(await this.application.protocolService.rootKeyEncryption.getWrappedRootKey()).to.not.be.ok
expect(await this.application.encryptionService.rootKeyManager.getWrappedRootKey()).to.not.be.ok
const passcode = '123'
Factory.handlePasswordChallenges(this.application, this.password)
@@ -209,15 +209,15 @@ describe('storage manager', function () {
await this.application.diskStorageService.setValueAndAwaitPersist('bar', 'foo')
/** Root key should now be wrapped */
expect(await this.application.protocolService.rootKeyEncryption.getWrappedRootKey()).to.be.ok
expect(await this.application.encryptionService.rootKeyManager.getWrappedRootKey()).to.be.ok
const accountKey = await this.application.protocolService.getRootKey()
const accountKey = await this.application.encryptionService.getRootKey()
expect(await this.application.diskStorageService.canDecryptWithKey(accountKey)).to.equal(true)
const passcodeKey = await this.application.protocolService.computeWrappingKey(passcode)
const wrappedRootKey = await this.application.protocolService.rootKeyEncryption.getWrappedRootKey()
const passcodeKey = await this.application.encryptionService.computeWrappingKey(passcode)
const wrappedRootKey = await this.application.encryptionService.rootKeyManager.getWrappedRootKey()
/** Expect that we can decrypt wrapped root key with passcode key */
const payload = new EncryptedPayload(wrappedRootKey)
const decrypted = await this.application.protocolService.decryptSplitSingle({
const decrypted = await this.application.encryptionService.decryptSplitSingle({
usesRootKey: {
items: [payload],
key: passcodeKey,

View File

@@ -90,7 +90,7 @@ describe('offline syncing', () => {
const payload = rawPayloads2[0]
expect(typeof payload.content).to.equal('string')
expect(payload.content.startsWith(this.application.protocolService.getLatestVersion())).to.equal(true)
expect(payload.content.startsWith(this.application.encryptionService.getLatestVersion())).to.equal(true)
})
it('signing out while offline should succeed', async function () {

View File

@@ -277,7 +277,7 @@ describe('online syncing', function () {
await this.application.syncService.sync(syncOptions)
const encrypted = CreateEncryptedServerSyncPushPayload(
await this.application.protocolService.encryptSplitSingle({
await this.application.encryptionService.encryptSplitSingle({
usesItemsKeyWithKeyLookup: {
items: [note.payloadRepresentation()],
},
@@ -295,7 +295,7 @@ describe('online syncing', function () {
expect(typeof mappedItem.content).to.equal('string')
const decryptedPayload = await this.application.protocolService.decryptSplitSingle({
const decryptedPayload = await this.application.encryptionService.decryptSplitSingle({
usesItemsKeyWithKeyLookup: {
items: [errorred],
},
@@ -515,7 +515,7 @@ describe('online syncing', function () {
const keyedSplit = CreateDecryptionSplitWithKeyLookup(encryptionSplit)
const decryptionResults = await this.application.protocolService.decryptSplit(keyedSplit)
const decryptionResults = await this.application.encryptionService.decryptSplit(keyedSplit)
await this.application.mutator.emitItemsFromPayloads(decryptionResults, PayloadEmitSource.LocalChanged)
@@ -918,7 +918,7 @@ describe('online syncing', function () {
const lastSyncBegan = note.lastSyncBegan
const lastSyncEnd = note.lastSyncEnd
const encrypted = await this.application.protocolService.encryptSplitSingle({
const encrypted = await this.application.encryptionService.encryptSplitSingle({
usesItemsKeyWithKeyLookup: {
items: [note.payload],
},

View File

@@ -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)
})
})
})