refactor: key rotation (#2383)
This commit is contained in:
@@ -149,16 +149,24 @@ export class AppContext {
|
||||
return this.application.asymmetric
|
||||
}
|
||||
|
||||
get keyPair() {
|
||||
return this.application.dependencies.get(TYPES.GetKeyPairs).execute().getValue().encryption
|
||||
}
|
||||
|
||||
get signingKeyPair() {
|
||||
return this.application.dependencies.get(TYPES.GetKeyPairs).execute().getValue().signing
|
||||
}
|
||||
|
||||
get publicKey() {
|
||||
return this.sessions.getPublicKey()
|
||||
return this.keyPair.publicKey
|
||||
}
|
||||
|
||||
get signingPublicKey() {
|
||||
return this.sessions.getSigningPublicKey()
|
||||
return this.signingKeyPair.publicKey
|
||||
}
|
||||
|
||||
get privateKey() {
|
||||
return this.encryption.getKeyPair().privateKey
|
||||
return this.keyPair.privateKey
|
||||
}
|
||||
|
||||
ignoreChallenges() {
|
||||
@@ -453,34 +461,6 @@ export class AppContext {
|
||||
return this.resolveWhenAsyncFunctionCompletes(objectToSpy, 'shareContactWithVaults')
|
||||
}
|
||||
|
||||
resolveWhenSharedVaultKeyRotationInvitesGetSent(targetVault) {
|
||||
return new Promise((resolve) => {
|
||||
const objectToSpy = this.sharedVaults
|
||||
sinon.stub(objectToSpy, 'handleVaultRootKeyRotatedEvent').callsFake(async (vault) => {
|
||||
objectToSpy.handleVaultRootKeyRotatedEvent.restore()
|
||||
const result = await objectToSpy.handleVaultRootKeyRotatedEvent(vault)
|
||||
if (vault.systemIdentifier === targetVault.systemIdentifier) {
|
||||
resolve()
|
||||
}
|
||||
return result
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
resolveWhenSharedVaultChangeInvitesAreSent(sharedVaultUuid) {
|
||||
return new Promise((resolve) => {
|
||||
const objectToSpy = this.sharedVaults
|
||||
sinon.stub(objectToSpy, 'handleVaultRootKeyRotatedEvent').callsFake(async (vault) => {
|
||||
objectToSpy.handleVaultRootKeyRotatedEvent.restore()
|
||||
const result = await objectToSpy.handleVaultRootKeyRotatedEvent(vault)
|
||||
if (vault.sharing.sharedVaultUuid === sharedVaultUuid) {
|
||||
resolve()
|
||||
}
|
||||
return result
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
awaitUserPrefsSingletonCreation() {
|
||||
const preferences = this.application.preferences.preferences
|
||||
if (preferences) {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { AppContext } from './AppContext.js'
|
||||
import * as Collaboration from './Collaboration.js'
|
||||
|
||||
export class VaultsContext extends AppContext {
|
||||
constructor(params) {
|
||||
@@ -6,17 +7,22 @@ export class VaultsContext extends AppContext {
|
||||
}
|
||||
|
||||
async changeVaultName(vault, nameAndDesc) {
|
||||
const sendDataChangePromise = this.resolveWhenAsyncFunctionCompletes(
|
||||
this.sharedVaults._sendVaultDataChangeMessage,
|
||||
'execute',
|
||||
)
|
||||
|
||||
await this.vaults.changeVaultNameAndDescription(vault, {
|
||||
name: nameAndDesc.name,
|
||||
description: nameAndDesc.description,
|
||||
})
|
||||
}
|
||||
|
||||
await this.awaitPromiseOrThrow(sendDataChangePromise, undefined, 'Waiting for vault data change message to process')
|
||||
getKeyPair() {
|
||||
const result = this.application.dependencies.get(TYPES.GetKeyPairs).execute()
|
||||
|
||||
return result.getValue().encryption
|
||||
}
|
||||
|
||||
getSigningKeyPair() {
|
||||
const result = this.application.dependencies.get(TYPES.GetKeyPairs).execute()
|
||||
|
||||
return result.getValue().signing
|
||||
}
|
||||
|
||||
async changePassword(password) {
|
||||
@@ -51,4 +57,28 @@ export class VaultsContext extends AppContext {
|
||||
async runAnyRequestToPreventRefreshTokenFromExpiring() {
|
||||
await this.asymmetric.getInboundMessages()
|
||||
}
|
||||
|
||||
async createSharedPasswordVault(password) {
|
||||
const privateVault = await this.vaults.createUserInputtedPasswordVault({
|
||||
name: 'Our Vault',
|
||||
userInputtedPassword: password,
|
||||
storagePreference: KeySystemRootKeyStorageMode.Ephemeral,
|
||||
})
|
||||
|
||||
const note = await this.createSyncedNote('foo', 'bar')
|
||||
|
||||
await this.vaults.moveItemToVault(privateVault, note)
|
||||
|
||||
const sharedVault = await this.sharedVaults.convertVaultToSharedVault(privateVault)
|
||||
console.log('createSharedPasswordVault > sharedVault:', sharedVault)
|
||||
|
||||
const { thirdPartyContext, deinitThirdPartyContext } = await Collaboration.inviteNewPartyToSharedVault(
|
||||
this,
|
||||
sharedVault,
|
||||
)
|
||||
|
||||
await Collaboration.acceptAllInvites(thirdPartyContext)
|
||||
|
||||
return { sharedVault, thirdPartyContext, deinitThirdPartyContext }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,7 +158,8 @@ export async function registerOldUser({ application, email, password, version })
|
||||
mode: SyncMode.DownloadFirst,
|
||||
...syncOptions,
|
||||
})
|
||||
await application.encryption.decryptErroredPayloads()
|
||||
|
||||
await application.dependencies.get(TYPES.DecryptErroredPayloads).execute()
|
||||
}
|
||||
|
||||
export function createStorageItemPayload(contentType) {
|
||||
|
||||
Reference in New Issue
Block a user