chore: fix endpoints and properties used in shared vaults to match the server (#2370)
* chore: upgrade @standardnotes/domain-core * chore: enable vault tests by default * chore: fix asymmetric messages paths * chore: fix message property from user_uuid to recipient_uuid * chore: fix server response properties for messages and notifications * chore: fix user_uuid to recipient_uuid in resend all message use case * chore: use notification payload and type from domain-core * chore: fix non existent uuid in conflicts tests * chore: use shared vault user permission from domain-core * chore: enable all e2e tests * chore: upgrade domain-core * chore: mark failing tests as skipped * chore: skip test * chore: fix recipient_uuid in specs * chore: skip test * chore: skip test * chore: skip test * chore: skip test * chore: fix remove unused var and unskip test * Revert "chore: skip test" This reverts commit 26bb876cf55e2c4fa9eeea56f73b3c2917a26f5c. * chore: unskip passing tests * chore: skip test * chore: skip test * fix: handle invite creation error * chore: skip tests * fix: disable vault tests to merge the PR * chore: unskip asymmetric messages tests
This commit is contained in:
@@ -80,7 +80,7 @@ describe('AsymmetricMessageService', () => {
|
||||
const messages: AsymmetricMessageServerHash[] = [
|
||||
{
|
||||
uuid: 'keypair-changed-message',
|
||||
user_uuid: '1',
|
||||
recipient_uuid: '1',
|
||||
sender_uuid: '2',
|
||||
encrypted_message: 'encrypted_message',
|
||||
created_at_timestamp: 2,
|
||||
@@ -88,7 +88,7 @@ describe('AsymmetricMessageService', () => {
|
||||
},
|
||||
{
|
||||
uuid: 'misc-message',
|
||||
user_uuid: '1',
|
||||
recipient_uuid: '1',
|
||||
sender_uuid: '2',
|
||||
encrypted_message: 'encrypted_message',
|
||||
created_at_timestamp: 1,
|
||||
@@ -119,7 +119,7 @@ describe('AsymmetricMessageService', () => {
|
||||
const messages: AsymmetricMessageServerHash[] = [
|
||||
{
|
||||
uuid: 'newer-message',
|
||||
user_uuid: '1',
|
||||
recipient_uuid: '1',
|
||||
sender_uuid: '2',
|
||||
encrypted_message: 'encrypted_message',
|
||||
created_at_timestamp: 2,
|
||||
@@ -127,7 +127,7 @@ describe('AsymmetricMessageService', () => {
|
||||
},
|
||||
{
|
||||
uuid: 'older-message',
|
||||
user_uuid: '1',
|
||||
recipient_uuid: '1',
|
||||
sender_uuid: '2',
|
||||
encrypted_message: 'encrypted_message',
|
||||
created_at_timestamp: 1,
|
||||
@@ -153,7 +153,7 @@ describe('AsymmetricMessageService', () => {
|
||||
it('should handle ContactShare message', async () => {
|
||||
const message: AsymmetricMessageServerHash = {
|
||||
uuid: 'message',
|
||||
user_uuid: '1',
|
||||
recipient_uuid: '1',
|
||||
sender_uuid: '2',
|
||||
encrypted_message: 'encrypted_message',
|
||||
created_at_timestamp: 2,
|
||||
@@ -181,7 +181,7 @@ describe('AsymmetricMessageService', () => {
|
||||
it('should handle SenderKeypairChanged message', async () => {
|
||||
const message: AsymmetricMessageServerHash = {
|
||||
uuid: 'message',
|
||||
user_uuid: '1',
|
||||
recipient_uuid: '1',
|
||||
sender_uuid: '2',
|
||||
encrypted_message: 'encrypted_message',
|
||||
created_at_timestamp: 2,
|
||||
@@ -210,7 +210,7 @@ describe('AsymmetricMessageService', () => {
|
||||
it('should handle SharedVaultRootKeyChanged message', async () => {
|
||||
const message: AsymmetricMessageServerHash = {
|
||||
uuid: 'message',
|
||||
user_uuid: '1',
|
||||
recipient_uuid: '1',
|
||||
sender_uuid: '2',
|
||||
encrypted_message: 'encrypted_message',
|
||||
created_at_timestamp: 2,
|
||||
@@ -238,7 +238,7 @@ describe('AsymmetricMessageService', () => {
|
||||
it('should handle SharedVaultMetadataChanged message', async () => {
|
||||
const message: AsymmetricMessageServerHash = {
|
||||
uuid: 'message',
|
||||
user_uuid: '1',
|
||||
recipient_uuid: '1',
|
||||
sender_uuid: '2',
|
||||
encrypted_message: 'encrypted_message',
|
||||
created_at_timestamp: 2,
|
||||
@@ -268,7 +268,7 @@ describe('AsymmetricMessageService', () => {
|
||||
it('should throw if message type is SharedVaultInvite', async () => {
|
||||
const message: AsymmetricMessageServerHash = {
|
||||
uuid: 'message',
|
||||
user_uuid: '1',
|
||||
recipient_uuid: '1',
|
||||
sender_uuid: '2',
|
||||
encrypted_message: 'encrypted_message',
|
||||
created_at_timestamp: 2,
|
||||
@@ -294,7 +294,7 @@ describe('AsymmetricMessageService', () => {
|
||||
it('should delete message from server after processing', async () => {
|
||||
const message: AsymmetricMessageServerHash = {
|
||||
uuid: 'message',
|
||||
user_uuid: '1',
|
||||
recipient_uuid: '1',
|
||||
sender_uuid: '2',
|
||||
encrypted_message: 'encrypted_message',
|
||||
created_at_timestamp: 2,
|
||||
|
||||
@@ -31,9 +31,9 @@ export class ResendAllMessages implements UseCaseInterface<void> {
|
||||
const errors: string[] = []
|
||||
|
||||
for (const message of messages.data.messages) {
|
||||
const recipient = this.findContact.execute({ userUuid: message.user_uuid })
|
||||
const recipient = this.findContact.execute({ userUuid: message.recipient_uuid })
|
||||
if (recipient.isFailed()) {
|
||||
errors.push(`Contact not found for invite ${message.user_uuid}`)
|
||||
errors.push(`Contact not found for invite ${message.recipient_uuid}`)
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { DiscardItemsLocally } from './../UseCase/DiscardItemsLocally'
|
||||
import { UserKeyPairChangedEventData } from './../Session/UserKeyPairChangedEventData'
|
||||
import { ClientDisplayableError, UserEventType } from '@standardnotes/responses'
|
||||
import { ClientDisplayableError } from '@standardnotes/responses'
|
||||
import {
|
||||
DecryptedItemInterface,
|
||||
PayloadEmitSource,
|
||||
@@ -29,7 +29,7 @@ import { CreateSharedVault } from './UseCase/CreateSharedVault'
|
||||
import { SendVaultDataChangedMessage } from './UseCase/SendVaultDataChangedMessage'
|
||||
import { ConvertToSharedVault } from './UseCase/ConvertToSharedVault'
|
||||
import { GetVault } from '../Vault/UseCase/GetVault'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
import { ContentType, NotificationType, Uuid } from '@standardnotes/domain-core'
|
||||
import { HandleKeyPairChange } from '../Contacts/UseCase/HandleKeyPairChange'
|
||||
import { FindContact } from '../Contacts/UseCase/FindContact'
|
||||
import { EncryptionProviderInterface } from '../Encryption/EncryptionProviderInterface'
|
||||
@@ -121,18 +121,18 @@ export class SharedVaultService
|
||||
}
|
||||
|
||||
private async handleUserEvent(event: UserEventServiceEventPayload): Promise<void> {
|
||||
switch (event.eventPayload.eventType) {
|
||||
case UserEventType.RemovedFromSharedVault: {
|
||||
switch (event.eventPayload.props.type.value) {
|
||||
case NotificationType.TYPES.RemovedFromSharedVault: {
|
||||
const vault = this._getVault.execute<SharedVaultListingInterface>({
|
||||
sharedVaultUuid: event.eventPayload.sharedVaultUuid,
|
||||
sharedVaultUuid: event.eventPayload.props.sharedVaultUuid.value,
|
||||
})
|
||||
if (!vault.isFailed()) {
|
||||
await this._deleteThirdPartyVault.execute(vault.getValue())
|
||||
}
|
||||
break
|
||||
}
|
||||
case UserEventType.SharedVaultItemRemoved: {
|
||||
const item = this.items.findItem(event.eventPayload.itemUuid)
|
||||
case NotificationType.TYPES.SharedVaultItemRemoved: {
|
||||
const item = this.items.findItem((event.eventPayload.props.itemUuid as Uuid).value)
|
||||
if (item) {
|
||||
void this._discardItemsLocally.execute([item])
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ export class NotifyVaultUsersOfKeyRotation implements UseCaseInterface<void> {
|
||||
sharedVault: params.sharedVault,
|
||||
sharedVaultContacts: !contacts.isFailed() ? contacts.getValue() : [],
|
||||
recipient: recipient.getValue(),
|
||||
permissions: invite.permissions,
|
||||
permission: invite.permission,
|
||||
senderUuid: params.senderUuid,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import { InternalEventHandlerInterface } from '../Internal/InternalEventHandlerI
|
||||
import { InternalEventInterface } from '../Internal/InternalEventInterface'
|
||||
import { AbstractService } from '../Service/AbstractService'
|
||||
import { UserEventServiceEventPayload, UserEventServiceEvent } from './UserEventServiceEvent'
|
||||
import { NotificationPayload } from '@standardnotes/domain-core'
|
||||
|
||||
export class UserEventService
|
||||
extends AbstractService<UserEventServiceEvent, UserEventServiceEventPayload>
|
||||
@@ -28,9 +29,13 @@ export class UserEventService
|
||||
}
|
||||
|
||||
for (const serverEvent of userEvents) {
|
||||
const serviceEvent: UserEventServiceEventPayload = {
|
||||
eventPayload: JSON.parse(serverEvent.event_payload),
|
||||
const eventPayloadOrError = NotificationPayload.createFromString(serverEvent.payload)
|
||||
if (eventPayloadOrError.isFailed()) {
|
||||
continue
|
||||
}
|
||||
const eventPayload = eventPayloadOrError.getValue()
|
||||
|
||||
const serviceEvent: UserEventServiceEventPayload = { eventPayload }
|
||||
|
||||
await this.notifyEventSync(UserEventServiceEvent.UserEventReceived, serviceEvent)
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { UserEventPayload } from '@standardnotes/responses'
|
||||
import { NotificationPayload } from '@standardnotes/domain-core'
|
||||
|
||||
export enum UserEventServiceEvent {
|
||||
UserEventReceived = 'UserEventReceived',
|
||||
}
|
||||
|
||||
export type UserEventServiceEventPayload = {
|
||||
eventPayload: UserEventPayload
|
||||
eventPayload: NotificationPayload
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { SharedVaultInviteServerHash, SharedVaultPermission } from '@standardnotes/responses'
|
||||
import { SharedVaultInviteServerHash } from '@standardnotes/responses'
|
||||
import {
|
||||
TrustedContactInterface,
|
||||
SharedVaultListingInterface,
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
import { SendVaultInvite } from './SendVaultInvite'
|
||||
import { PkcKeyPair } from '@standardnotes/sncrypto-common'
|
||||
import { EncryptMessage } from '../../Encryption/UseCase/Asymmetric/EncryptMessage'
|
||||
import { Result, UseCaseInterface } from '@standardnotes/domain-core'
|
||||
import { Result, SharedVaultUserPermission, UseCaseInterface } from '@standardnotes/domain-core'
|
||||
import { ShareContactWithVault } from '../../SharedVaults/UseCase/ShareContactWithVault'
|
||||
import { KeySystemKeyManagerInterface } from '../../KeySystem/KeySystemKeyManagerInterface'
|
||||
|
||||
@@ -29,7 +29,7 @@ export class InviteToVault implements UseCaseInterface<SharedVaultInviteServerHa
|
||||
sharedVault: SharedVaultListingInterface
|
||||
sharedVaultContacts: TrustedContactInterface[]
|
||||
recipient: TrustedContactInterface
|
||||
permissions: SharedVaultPermission
|
||||
permission: string
|
||||
}): Promise<Result<SharedVaultInviteServerHash>> {
|
||||
const createInviteResult = await this.inviteContact(params)
|
||||
|
||||
@@ -74,8 +74,14 @@ export class InviteToVault implements UseCaseInterface<SharedVaultInviteServerHa
|
||||
sharedVault: SharedVaultListingInterface
|
||||
sharedVaultContacts: TrustedContactInterface[]
|
||||
recipient: TrustedContactInterface
|
||||
permissions: SharedVaultPermission
|
||||
permission: string
|
||||
}): Promise<Result<SharedVaultInviteServerHash>> {
|
||||
const permissionOrError = SharedVaultUserPermission.create(params.permission)
|
||||
if (permissionOrError.isFailed()) {
|
||||
return Result.fail(permissionOrError.getError())
|
||||
}
|
||||
const permission = permissionOrError.getValue()
|
||||
|
||||
const keySystemRootKey = this.keyManager.getPrimaryKeySystemRootKey(params.sharedVault.systemIdentifier)
|
||||
if (!keySystemRootKey) {
|
||||
return Result.fail('Cannot invite contact; key system root key not found')
|
||||
@@ -127,7 +133,7 @@ export class InviteToVault implements UseCaseInterface<SharedVaultInviteServerHa
|
||||
sharedVaultUuid: params.sharedVault.sharing.sharedVaultUuid,
|
||||
recipientUuid: params.recipient.contactUuid,
|
||||
encryptedMessage: encryptedMessage.getValue(),
|
||||
permissions: params.permissions,
|
||||
permission: permission.value,
|
||||
})
|
||||
|
||||
return createInviteResult
|
||||
|
||||
@@ -49,7 +49,7 @@ export class ReuploadInvite implements UseCaseInterface<void> {
|
||||
sharedVaultUuid: params.previousInvite.shared_vault_uuid,
|
||||
recipientUuid: params.recipient.contactUuid,
|
||||
encryptedMessage: encryptedMessage.getValue(),
|
||||
permissions: params.previousInvite.permissions,
|
||||
permission: params.previousInvite.permission,
|
||||
})
|
||||
|
||||
return createInviteResult
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
import {
|
||||
SharedVaultInviteServerHash,
|
||||
isErrorResponse,
|
||||
SharedVaultPermission,
|
||||
getErrorFromErrorResponse,
|
||||
} from '@standardnotes/responses'
|
||||
import { SharedVaultInviteServerHash, isErrorResponse, getErrorFromErrorResponse } from '@standardnotes/responses'
|
||||
import { SharedVaultInvitesServerInterface } from '@standardnotes/api'
|
||||
import { Result, UseCaseInterface } from '@standardnotes/domain-core'
|
||||
import { Result, SharedVaultUserPermission, UseCaseInterface } from '@standardnotes/domain-core'
|
||||
|
||||
export class SendVaultInvite implements UseCaseInterface<SharedVaultInviteServerHash> {
|
||||
constructor(private vaultInvitesServer: SharedVaultInvitesServerInterface) {}
|
||||
@@ -14,13 +9,19 @@ export class SendVaultInvite implements UseCaseInterface<SharedVaultInviteServer
|
||||
sharedVaultUuid: string
|
||||
recipientUuid: string
|
||||
encryptedMessage: string
|
||||
permissions: SharedVaultPermission
|
||||
permission: string
|
||||
}): Promise<Result<SharedVaultInviteServerHash>> {
|
||||
const permissionOrError = SharedVaultUserPermission.create(params.permission)
|
||||
if (permissionOrError.isFailed()) {
|
||||
return Result.fail(permissionOrError.getError())
|
||||
}
|
||||
const permission = permissionOrError.getValue()
|
||||
|
||||
const response = await this.vaultInvitesServer.createInvite({
|
||||
sharedVaultUuid: params.sharedVaultUuid,
|
||||
recipientUuid: params.recipientUuid,
|
||||
encryptedMessage: params.encryptedMessage,
|
||||
permissions: params.permissions,
|
||||
permission: permission,
|
||||
})
|
||||
|
||||
if (isErrorResponse(response)) {
|
||||
|
||||
@@ -27,7 +27,6 @@ import { VaultInviteServiceInterface } from './VaultInviteServiceInterface'
|
||||
import {
|
||||
ClientDisplayableError,
|
||||
SharedVaultInviteServerHash,
|
||||
SharedVaultPermission,
|
||||
SharedVaultUserServerHash,
|
||||
isErrorResponse,
|
||||
} from '@standardnotes/responses'
|
||||
@@ -173,7 +172,7 @@ export class VaultInviteService
|
||||
public async inviteContactToSharedVault(
|
||||
sharedVault: SharedVaultListingInterface,
|
||||
contact: TrustedContactInterface,
|
||||
permissions: SharedVaultPermission,
|
||||
permission: string,
|
||||
): Promise<Result<SharedVaultInviteServerHash>> {
|
||||
const contactsResult = await this._getVaultContacts.execute({
|
||||
sharedVaultUuid: sharedVault.sharing.sharedVaultUuid,
|
||||
@@ -194,7 +193,7 @@ export class VaultInviteService
|
||||
sharedVault,
|
||||
recipient: contact,
|
||||
sharedVaultContacts: contacts,
|
||||
permissions,
|
||||
permission,
|
||||
})
|
||||
|
||||
void this.notifyEvent(VaultInviteServiceEvent.InviteSent)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { InviteRecord } from './InviteRecord'
|
||||
import { ApplicationServiceInterface } from '../Service/ApplicationServiceInterface'
|
||||
import { SharedVaultListingInterface, TrustedContactInterface } from '@standardnotes/models'
|
||||
import { ClientDisplayableError, SharedVaultInviteServerHash, SharedVaultPermission } from '@standardnotes/responses'
|
||||
import { ClientDisplayableError, SharedVaultInviteServerHash } from '@standardnotes/responses'
|
||||
import { VaultInviteServiceEvent } from './VaultInviteServiceEvent'
|
||||
import { Result } from '@standardnotes/domain-core'
|
||||
|
||||
@@ -10,7 +10,7 @@ export interface VaultInviteServiceInterface extends ApplicationServiceInterface
|
||||
inviteContactToSharedVault(
|
||||
sharedVault: SharedVaultListingInterface,
|
||||
contact: TrustedContactInterface,
|
||||
permissions: SharedVaultPermission,
|
||||
permission: string,
|
||||
): Promise<Result<SharedVaultInviteServerHash>>
|
||||
getCachedPendingInviteRecords(): InviteRecord[]
|
||||
deleteInvite(invite: SharedVaultInviteServerHash): Promise<ClientDisplayableError | void>
|
||||
|
||||
Reference in New Issue
Block a user