refactor: import/export use cases (#2397)
This commit is contained in:
@@ -42,7 +42,7 @@ import {
|
||||
GetAllContacts,
|
||||
GetVault,
|
||||
HomeServerService,
|
||||
ImportDataUseCase,
|
||||
ImportData,
|
||||
InMemoryStore,
|
||||
IntegrityService,
|
||||
InternalEventBus,
|
||||
@@ -133,7 +133,13 @@ import {
|
||||
GenerateUuid,
|
||||
GetVaultItems,
|
||||
ValidateVaultPassword,
|
||||
DecryptBackupPayloads,
|
||||
DetermineKeyToUse,
|
||||
GetBackupFileType,
|
||||
GetFilePassword,
|
||||
IsApplicationUsingThirdPartyHost,
|
||||
CreateDecryptedBackupFile,
|
||||
CreateEncryptedBackupFile,
|
||||
} from '@standardnotes/services'
|
||||
import { ItemManager } from '../../Services/Items/ItemManager'
|
||||
import { PayloadManager } from '../../Services/Payloads/PayloadManager'
|
||||
@@ -160,7 +166,7 @@ import {
|
||||
WebSocketServer,
|
||||
} from '@standardnotes/api'
|
||||
import { TYPES } from './Types'
|
||||
import { Logger, isNotUndefined, isDeinitable } from '@standardnotes/utils'
|
||||
import { Logger, isNotUndefined, isDeinitable, LoggerInterface } from '@standardnotes/utils'
|
||||
import { EncryptionOperators } from '@standardnotes/encryption'
|
||||
import { AsymmetricMessagePayload, AsymmetricMessageSharedVaultInvite } from '@standardnotes/models'
|
||||
import { PureCryptoInterface } from '@standardnotes/sncrypto-common'
|
||||
@@ -219,6 +225,29 @@ export class Dependencies {
|
||||
}
|
||||
|
||||
private registerUseCaseMakers() {
|
||||
this.factory.set(TYPES.DecryptBackupPayloads, () => {
|
||||
return new DecryptBackupPayloads(
|
||||
this.get<EncryptionService>(TYPES.EncryptionService),
|
||||
this.get<DetermineKeyToUse>(TYPES.DetermineKeyToUse),
|
||||
this.get<LoggerInterface>(TYPES.Logger),
|
||||
)
|
||||
})
|
||||
|
||||
this.factory.set(TYPES.DetermineKeyToUse, () => {
|
||||
return new DetermineKeyToUse(
|
||||
this.get<EncryptionService>(TYPES.EncryptionService),
|
||||
this.get<KeySystemKeyManager>(TYPES.KeySystemKeyManager),
|
||||
)
|
||||
})
|
||||
|
||||
this.factory.set(TYPES.GetBackupFileType, () => {
|
||||
return new GetBackupFileType()
|
||||
})
|
||||
|
||||
this.factory.set(TYPES.GetFilePassword, () => {
|
||||
return new GetFilePassword(this.get<ChallengeService>(TYPES.ChallengeService))
|
||||
})
|
||||
|
||||
this.factory.set(TYPES.ValidateVaultPassword, () => {
|
||||
return new ValidateVaultPassword(
|
||||
this.get<EncryptionService>(TYPES.EncryptionService),
|
||||
@@ -273,16 +302,31 @@ export class Dependencies {
|
||||
)
|
||||
})
|
||||
|
||||
this.factory.set(TYPES.ImportDataUseCase, () => {
|
||||
return new ImportDataUseCase(
|
||||
this.factory.set(TYPES.CreateDecryptedBackupFile, () => {
|
||||
return new CreateDecryptedBackupFile(
|
||||
this.get<PayloadManager>(TYPES.PayloadManager),
|
||||
this.get<ProtectionService>(TYPES.ProtectionService),
|
||||
)
|
||||
})
|
||||
|
||||
this.factory.set(TYPES.CreateEncryptedBackupFile, () => {
|
||||
return new CreateEncryptedBackupFile(
|
||||
this.get<ItemManager>(TYPES.ItemManager),
|
||||
this.get<ProtectionService>(TYPES.ProtectionService),
|
||||
this.get<EncryptionService>(TYPES.EncryptionService),
|
||||
)
|
||||
})
|
||||
|
||||
this.factory.set(TYPES.ImportData, () => {
|
||||
return new ImportData(
|
||||
this.get<ItemManager>(TYPES.ItemManager),
|
||||
this.get<SyncService>(TYPES.SyncService),
|
||||
this.get<ProtectionService>(TYPES.ProtectionService),
|
||||
this.get<EncryptionService>(TYPES.EncryptionService),
|
||||
this.get<PayloadManager>(TYPES.PayloadManager),
|
||||
this.get<ChallengeService>(TYPES.ChallengeService),
|
||||
this.get<HistoryManager>(TYPES.HistoryManager),
|
||||
this.get<DecryptBackupFile>(TYPES.DecryptBackupFile),
|
||||
this.get<GetFilePassword>(TYPES.GetFilePassword),
|
||||
)
|
||||
})
|
||||
|
||||
@@ -291,7 +335,12 @@ export class Dependencies {
|
||||
})
|
||||
|
||||
this.factory.set(TYPES.DecryptBackupFile, () => {
|
||||
return new DecryptBackupFile(this.get<EncryptionService>(TYPES.EncryptionService), this.get<Logger>(TYPES.Logger))
|
||||
return new DecryptBackupFile(
|
||||
this.get<EncryptionService>(TYPES.EncryptionService),
|
||||
this.get<KeySystemKeyManager>(TYPES.KeySystemKeyManager),
|
||||
this.get<GetBackupFileType>(TYPES.GetBackupFileType),
|
||||
this.get<DecryptBackupPayloads>(TYPES.DecryptBackupPayloads),
|
||||
)
|
||||
})
|
||||
|
||||
this.factory.set(TYPES.DiscardItemsLocally, () => {
|
||||
|
||||
@@ -89,7 +89,7 @@ export const TYPES = {
|
||||
ListRevisions: Symbol.for('ListRevisions'),
|
||||
GetRevision: Symbol.for('GetRevision'),
|
||||
DeleteRevision: Symbol.for('DeleteRevision'),
|
||||
ImportDataUseCase: Symbol.for('ImportDataUseCase'),
|
||||
ImportData: Symbol.for('ImportData'),
|
||||
DiscardItemsLocally: Symbol.for('DiscardItemsLocally'),
|
||||
FindContact: Symbol.for('FindContact'),
|
||||
GetAllContacts: Symbol.for('GetAllContacts'),
|
||||
@@ -163,7 +163,13 @@ export const TYPES = {
|
||||
GenerateUuid: Symbol.for('GenerateUuid'),
|
||||
GetVaultItems: Symbol.for('GetVaultItems'),
|
||||
ValidateVaultPassword: Symbol.for('ValidateVaultPassword'),
|
||||
DecryptBackupPayloads: Symbol.for('DecryptBackupPayloads'),
|
||||
DetermineKeyToUse: Symbol.for('DetermineKeyToUse'),
|
||||
GetBackupFileType: Symbol.for('GetBackupFileType'),
|
||||
GetFilePassword: Symbol.for('GetFilePassword'),
|
||||
AuthorizeVaultDeletion: Symbol.for('AuthorizeVaultDeletion'),
|
||||
CreateDecryptedBackupFile: Symbol.for('CreateDecryptedBackupFile'),
|
||||
CreateEncryptedBackupFile: Symbol.for('CreateEncryptedBackupFile'),
|
||||
|
||||
// Mappers
|
||||
SessionStorageMapper: Symbol.for('SessionStorageMapper'),
|
||||
|
||||
Reference in New Issue
Block a user