diff --git a/packages/common/src/Domain/Content/ContentType.ts b/packages/common/src/Domain/Content/ContentType.ts index 36d7a5a3d..7bb3616c1 100644 --- a/packages/common/src/Domain/Content/ContentType.ts +++ b/packages/common/src/Domain/Content/ContentType.ts @@ -2,6 +2,7 @@ export enum ContentType { Any = '*', Item = 'SF|Item', + SharedItem = 'SN|SharedItem', RootKey = 'SN|RootKey|NoSync', ItemsKey = 'SN|ItemsKey', EncryptedStorage = 'SN|EncryptedStorage', diff --git a/packages/syncing-server/migrations/mysql/1683714734321-create_item_share.ts b/packages/syncing-server/migrations/mysql/1683714734321-create_item_share.ts index 3b043fb42..c9e081bf2 100644 --- a/packages/syncing-server/migrations/mysql/1683714734321-create_item_share.ts +++ b/packages/syncing-server/migrations/mysql/1683714734321-create_item_share.ts @@ -38,9 +38,10 @@ export class CreateItemShare1683714734321 implements MigrationInterface { isNullable: true, }), new TableColumn({ - name: 'public_key', - type: 'text', - isNullable: true, + name: 'permissions', + type: 'varchar', + length: '255', + isNullable: false, }), new TableColumn({ name: 'encrypted_content_key', diff --git a/packages/syncing-server/src/Controller/SharingController.ts b/packages/syncing-server/src/Controller/SharingController.ts index 0b2e53cbd..be699a752 100644 --- a/packages/syncing-server/src/Controller/SharingController.ts +++ b/packages/syncing-server/src/Controller/SharingController.ts @@ -45,7 +45,7 @@ export class SharingController extends BaseHttpController { const result = await this.shareItem.execute({ itemUuid: request.body.itemUuid, userUuid: response.locals.user.uuid, - publicKey: request.body.publicKey, + permissions: request.body.permissions, encryptedContentKey: request.body.encryptedContentKey, contentType: request.body.contentType, fileRemoteIdentifier: request.body.fileRemoteIdentifier, diff --git a/packages/syncing-server/src/Domain/ItemShare/Factory/ItemShareFactory.ts b/packages/syncing-server/src/Domain/ItemShare/Factory/ItemShareFactory.ts index 2741f5db9..d17083ca7 100644 --- a/packages/syncing-server/src/Domain/ItemShare/Factory/ItemShareFactory.ts +++ b/packages/syncing-server/src/Domain/ItemShare/Factory/ItemShareFactory.ts @@ -13,7 +13,7 @@ export class ItemShareFactory implements ItemShareFactoryInterface { newItemShare.itemUuid = dto.itemShareHash.item_uuid newItemShare.shareToken = dto.itemShareHash.share_token newItemShare.encryptedContentKey = dto.itemShareHash.encrypted_content_key - newItemShare.publicKey = dto.itemShareHash.public_key + newItemShare.permissions = dto.itemShareHash.permissions newItemShare.fileRemoteIdentifier = dto.itemShareHash.file_remote_identifier ?? null newItemShare.contentType = dto.itemShareHash.content_type newItemShare.duration = dto.itemShareHash.duration diff --git a/packages/syncing-server/src/Domain/ItemShare/Factory/ItemShareHash.ts b/packages/syncing-server/src/Domain/ItemShare/Factory/ItemShareHash.ts index ac0037275..597281f53 100644 --- a/packages/syncing-server/src/Domain/ItemShare/Factory/ItemShareHash.ts +++ b/packages/syncing-server/src/Domain/ItemShare/Factory/ItemShareHash.ts @@ -4,7 +4,7 @@ export type ItemShareHash = { uuid: string item_uuid: string share_token: string - public_key: string + permissions: string encrypted_content_key: string content_type: ContentType file_remote_identifier?: string diff --git a/packages/syncing-server/src/Domain/ItemShare/Model/ItemShare.ts b/packages/syncing-server/src/Domain/ItemShare/Model/ItemShare.ts index f5f1b4c04..c1320533f 100644 --- a/packages/syncing-server/src/Domain/ItemShare/Model/ItemShare.ts +++ b/packages/syncing-server/src/Domain/ItemShare/Model/ItemShare.ts @@ -24,11 +24,12 @@ export class ItemShare { declare contentType: ContentType | null @Column({ - name: 'public_key', - type: 'text', - nullable: true, + name: 'permissions', + type: 'varchar', + length: 255, + nullable: false, }) - declare publicKey: string | null + declare permissions: string | null @Column({ name: 'encrypted_content_key', diff --git a/packages/syncing-server/src/Domain/ItemShare/Repository/TypeORMItemShareRepository.ts b/packages/syncing-server/src/Domain/ItemShare/Repository/TypeORMItemShareRepository.ts index 39c371d61..d55e6b61d 100644 --- a/packages/syncing-server/src/Domain/ItemShare/Repository/TypeORMItemShareRepository.ts +++ b/packages/syncing-server/src/Domain/ItemShare/Repository/TypeORMItemShareRepository.ts @@ -19,9 +19,8 @@ export class TypeORMItemShareRepository implements ItemShareRepositoryInterface .update() .set({ encryptedContentKey: null, - publicKey: null, - consumed: true, fileRemoteIdentifier: null, + consumed: true, }) .where('share_token = :shareToken', { shareToken: shareToken, diff --git a/packages/syncing-server/src/Domain/ItemShare/Service/ItemShareService.ts b/packages/syncing-server/src/Domain/ItemShare/Service/ItemShareService.ts index 666f656d3..808121691 100644 --- a/packages/syncing-server/src/Domain/ItemShare/Service/ItemShareService.ts +++ b/packages/syncing-server/src/Domain/ItemShare/Service/ItemShareService.ts @@ -78,7 +78,7 @@ export class ItemShareService implements ItemShareServiceInterface { uuid, item_uuid: dto.itemUuid, share_token: shareToken, - public_key: dto.publicKey, + permissions: dto.permissions, encrypted_content_key: dto.encryptedContentKey, content_type: dto.contentType, file_remote_identifier: dto.fileRemoteIdentifier, diff --git a/packages/syncing-server/src/Domain/ItemShare/Service/ShareItemDTO.ts b/packages/syncing-server/src/Domain/ItemShare/Service/ShareItemDTO.ts index 389042600..5a6d9f068 100644 --- a/packages/syncing-server/src/Domain/ItemShare/Service/ShareItemDTO.ts +++ b/packages/syncing-server/src/Domain/ItemShare/Service/ShareItemDTO.ts @@ -3,7 +3,7 @@ import { ContentType } from '@standardnotes/common' export type ShareItemDTO = { itemUuid: string userUuid: string - publicKey: string + permissions: string encryptedContentKey: string contentType: ContentType fileRemoteIdentifier?: string