refactor: key rotation (#2383)

This commit is contained in:
Mo
2023-08-04 09:25:28 -05:00
committed by GitHub
parent a7f266bb68
commit 494436bdb6
65 changed files with 1354 additions and 1232 deletions

View File

@@ -1,3 +1,4 @@
import { GetKeyPairs } from './../Encryption/UseCase/GetKeyPairs'
import { SyncServiceInterface } from './../Sync/SyncServiceInterface'
import { SessionsClientInterface } from './../Session/SessionsClientInterface'
import { MutatorClientInterface } from './../Mutator/MutatorClientInterface'
@@ -54,6 +55,7 @@ export class AsymmetricMessageService
private _getOutboundMessagesUseCase: GetOutboundMessages,
private _getInboundMessagesUseCase: GetInboundMessages,
private _getUntrustedPayload: GetUntrustedPayload,
private _getKeyPairs: GetKeyPairs,
eventBus: InternalEventBusInterface,
) {
super(eventBus)
@@ -196,8 +198,13 @@ export class AsymmetricMessageService
}
getUntrustedMessagePayload(message: AsymmetricMessageServerHash): Result<AsymmetricMessagePayload> {
const keys = this._getKeyPairs.execute()
if (keys.isFailed()) {
return Result.fail(keys.getError())
}
const result = this._getUntrustedPayload.execute({
privateKey: this.encryption.getKeyPair().privateKey,
privateKey: keys.getValue().encryption.privateKey,
message,
})
@@ -214,8 +221,13 @@ export class AsymmetricMessageService
return Result.fail(contact.getError())
}
const keys = this._getKeyPairs.execute()
if (keys.isFailed()) {
return Result.fail(keys.getError())
}
const result = this._getTrustedPayload.execute({
privateKey: this.encryption.getKeyPair().privateKey,
privateKey: keys.getValue().encryption.privateKey,
sender: contact.getValue(),
ownUserUuid: this.sessions.userUuid,
message,