refactor: remove public key from share model

This commit is contained in:
Mo
2023-05-14 06:34:30 -05:00
parent 1de21a7ba9
commit d532e052d6
9 changed files with 16 additions and 14 deletions
@@ -2,6 +2,7 @@
export enum ContentType {
Any = '*',
Item = 'SF|Item',
SharedItem = 'SN|SharedItem',
RootKey = 'SN|RootKey|NoSync',
ItemsKey = 'SN|ItemsKey',
EncryptedStorage = 'SN|EncryptedStorage',
@@ -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',
@@ -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,
@@ -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
@@ -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
@@ -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',
@@ -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,
@@ -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,
@@ -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