internal: change password preprocessing step (#2347)
This commit is contained in:
@@ -111,7 +111,9 @@ export class SharedVaultService
|
||||
)
|
||||
|
||||
this.eventDisposers.push(
|
||||
items.addObserver<TrustedContactInterface>(ContentType.TrustedContact, ({ changed, inserted, source }) => {
|
||||
items.addObserver<TrustedContactInterface>(ContentType.TrustedContact, async ({ changed, inserted, source }) => {
|
||||
await this.reprocessCachedInvitesTrustStatusAfterTrustedContactsChange()
|
||||
|
||||
if (source === PayloadEmitSource.LocalChanged && inserted.length > 0) {
|
||||
void this.handleCreationOfNewTrustedContacts(inserted)
|
||||
}
|
||||
@@ -250,8 +252,6 @@ export class SharedVaultService
|
||||
}
|
||||
|
||||
private async handleTrustedContactsChange(contacts: TrustedContactInterface[]): Promise<void> {
|
||||
await this.reprocessCachedInvitesTrustStatusAfterTrustedContactsChange()
|
||||
|
||||
for (const contact of contacts) {
|
||||
await this.shareContactWithUserAdministeredSharedVaults(contact)
|
||||
}
|
||||
@@ -328,28 +328,9 @@ export class SharedVaultService
|
||||
}
|
||||
|
||||
private async reprocessCachedInvitesTrustStatusAfterTrustedContactsChange(): Promise<void> {
|
||||
const cachedInvites = this.getCachedPendingInviteRecords()
|
||||
const cachedInvites = this.getCachedPendingInviteRecords().map((record) => record.invite)
|
||||
|
||||
for (const record of cachedInvites) {
|
||||
if (record.trusted) {
|
||||
continue
|
||||
}
|
||||
|
||||
const trustedMessageUseCase = new GetAsymmetricMessageTrustedPayload<AsymmetricMessageSharedVaultInvite>(
|
||||
this.encryption,
|
||||
this.contacts,
|
||||
)
|
||||
|
||||
const trustedMessage = trustedMessageUseCase.execute({
|
||||
message: record.invite,
|
||||
privateKey: this.encryption.getKeyPair().privateKey,
|
||||
})
|
||||
|
||||
if (trustedMessage) {
|
||||
record.message = trustedMessage
|
||||
record.trusted = true
|
||||
}
|
||||
}
|
||||
await this.processInboundInvites(cachedInvites)
|
||||
}
|
||||
|
||||
private async processInboundInvites(invites: SharedVaultInviteServerHash[]): Promise<void> {
|
||||
|
||||
@@ -3,10 +3,12 @@ import { StorageServiceInterface } from '../../Storage/StorageServiceInterface'
|
||||
import { EncryptionProviderInterface } from '@standardnotes/encryption'
|
||||
import { ItemManagerInterface } from '../../Item/ItemManagerInterface'
|
||||
import { AnyItemInterface, VaultListingInterface } from '@standardnotes/models'
|
||||
import { Uuids } from '@standardnotes/utils'
|
||||
import { MutatorClientInterface } from '../../Mutator/MutatorClientInterface'
|
||||
import { RemoveItemsLocallyUseCase } from '../../UseCase/RemoveItemsLocally'
|
||||
|
||||
export class DeleteExternalSharedVaultUseCase {
|
||||
private removeItemsLocallyUsecase = new RemoveItemsLocallyUseCase(this.items, this.storage)
|
||||
|
||||
constructor(
|
||||
private items: ItemManagerInterface,
|
||||
private mutator: MutatorClientInterface,
|
||||
@@ -28,15 +30,13 @@ export class DeleteExternalSharedVaultUseCase {
|
||||
* The data will be removed locally without syncing the items
|
||||
*/
|
||||
private async deleteDataSharedByVaultUsers(vault: VaultListingInterface): Promise<void> {
|
||||
const vaultItems = this.items
|
||||
.allTrackedItems()
|
||||
.filter((item) => item.key_system_identifier === vault.systemIdentifier)
|
||||
this.items.removeItemsLocally(vaultItems as AnyItemInterface[])
|
||||
const vaultItems = <AnyItemInterface[]>(
|
||||
this.items.allTrackedItems().filter((item) => item.key_system_identifier === vault.systemIdentifier)
|
||||
)
|
||||
|
||||
const itemsKeys = this.encryption.keys.getKeySystemItemsKeys(vault.systemIdentifier)
|
||||
this.items.removeItemsLocally(itemsKeys)
|
||||
|
||||
await this.storage.deletePayloadsWithUuids([...Uuids(vaultItems), ...Uuids(itemsKeys)])
|
||||
await this.removeItemsLocallyUsecase.execute([...vaultItems, ...itemsKeys])
|
||||
}
|
||||
|
||||
private async deleteDataOwnedByThisUser(vault: VaultListingInterface): Promise<void> {
|
||||
|
||||
Reference in New Issue
Block a user