mirror of
https://github.com/standardnotes/server
synced 2026-07-14 00:01:54 -04:00
feat(wip): signing keypair
This commit is contained in:
@@ -67,11 +67,21 @@ export class ChangeCredentials implements UseCaseInterface {
|
||||
}
|
||||
|
||||
let userCredentialsChangedEvent: UserCredentialsChangedEvent | undefined = undefined
|
||||
|
||||
if (dto.publicKey && dto.user.publicKey !== dto.publicKey) {
|
||||
if (!dto.signingPublicKey) {
|
||||
return {
|
||||
success: false,
|
||||
errorMessage: 'Signing public key is required',
|
||||
}
|
||||
}
|
||||
|
||||
dto.user.publicKey = dto.publicKey
|
||||
dto.user.signingPublicKey = dto.signingPublicKey
|
||||
userCredentialsChangedEvent = this.domainEventFactory.createUserCredentialsChangedEvent(
|
||||
dto.user.uuid,
|
||||
dto.publicKey,
|
||||
dto.signingPublicKey,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -79,10 +89,6 @@ export class ChangeCredentials implements UseCaseInterface {
|
||||
dto.user.encryptedPrivateKey = dto.encryptedPrivateKey
|
||||
}
|
||||
|
||||
if (dto.signingPublicKey) {
|
||||
dto.user.signingPublicKey = dto.signingPublicKey
|
||||
}
|
||||
|
||||
if (dto.encryptedSigningPrivateKey) {
|
||||
dto.user.encryptedSigningPrivateKey = dto.encryptedSigningPrivateKey
|
||||
}
|
||||
|
||||
@@ -31,6 +31,12 @@ export class CreateContacts1684503299320 implements MigrationInterface {
|
||||
length: '255',
|
||||
isNullable: false,
|
||||
}),
|
||||
new TableColumn({
|
||||
name: 'contact_signing_public_key',
|
||||
type: 'varchar',
|
||||
length: '255',
|
||||
isNullable: false,
|
||||
}),
|
||||
new TableColumn({
|
||||
name: 'created_at_timestamp',
|
||||
type: 'bigint',
|
||||
|
||||
@@ -22,6 +22,11 @@ export class Contact {
|
||||
})
|
||||
declare contactPublicKey: string
|
||||
|
||||
@Column({
|
||||
name: 'contact_signing_public_key',
|
||||
})
|
||||
declare contactSigningPublicKey: string
|
||||
|
||||
@Column({
|
||||
name: 'created_at_timestamp',
|
||||
type: 'bigint',
|
||||
|
||||
@@ -16,6 +16,7 @@ export class UserCredentialsChangedEventHandler implements DomainEventHandlerInt
|
||||
|
||||
async handle(event: UserCredentialsChangedEvent): Promise<void> {
|
||||
await this.updatePublicKeyOfAllContacts(event.payload)
|
||||
|
||||
await this.nullifyPendingInboundSharedVaultInvites(event.payload)
|
||||
}
|
||||
|
||||
@@ -25,8 +26,12 @@ export class UserCredentialsChangedEventHandler implements DomainEventHandlerInt
|
||||
if (contact.contactPublicKey === payload.newPublicKey) {
|
||||
continue
|
||||
}
|
||||
|
||||
contact.contactPublicKey = payload.newPublicKey
|
||||
contact.contactSigningPublicKey = payload.newSigningPublicKey
|
||||
|
||||
contact.updatedAtTimestamp = this.timer.getTimestampInMicroseconds()
|
||||
|
||||
await this.contactRepository.save(contact)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ export class Item {
|
||||
name: 'last_edited_by_uuid',
|
||||
length: 36,
|
||||
})
|
||||
declare lastEditedByUuid: string
|
||||
declare lastEditedByUuid: string | null
|
||||
|
||||
@Column({
|
||||
name: 'created_at',
|
||||
|
||||
@@ -30,21 +30,17 @@ export class ItemFactory implements ItemFactoryInterface {
|
||||
create(dto: { userUuid: string; itemHash: ItemHash; sessionUuid: string | null }): Item {
|
||||
const newItem = new Item()
|
||||
newItem.uuid = dto.itemHash.uuid
|
||||
newItem.contentType = dto.itemHash.content_type
|
||||
newItem.updatedWithSession = dto.sessionUuid
|
||||
newItem.contentSize = 0
|
||||
newItem.userUuid = dto.userUuid
|
||||
newItem.keySystemIdentifier = dto.itemHash.key_system_identifier
|
||||
newItem.sharedVaultUuid = dto.itemHash.shared_vault_uuid
|
||||
newItem.lastEditedByUuid = dto.userUuid
|
||||
|
||||
if (dto.itemHash.content) {
|
||||
newItem.content = dto.itemHash.content
|
||||
}
|
||||
if (dto.itemHash.last_edited_by_uuid) {
|
||||
newItem.lastEditedByUuid = dto.itemHash.last_edited_by_uuid
|
||||
}
|
||||
if (dto.itemHash.content_type) {
|
||||
newItem.contentType = dto.itemHash.content_type
|
||||
}
|
||||
if (dto.itemHash.enc_item_key) {
|
||||
newItem.encItemKey = dto.itemHash.enc_item_key
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ export type ItemHash = {
|
||||
items_key_id?: string
|
||||
key_system_identifier: string | null
|
||||
shared_vault_uuid: string | null
|
||||
last_edited_by_uuid?: string | null
|
||||
created_at?: string
|
||||
created_at_timestamp?: number
|
||||
updated_at?: string
|
||||
|
||||
@@ -216,18 +216,16 @@ export class ItemService implements ItemServiceInterface {
|
||||
userUuid: dto.userUuid,
|
||||
})
|
||||
|
||||
dto.existingItem.contentType = dto.itemHash.content_type
|
||||
dto.existingItem.updatedWithSession = dto.sessionUuid
|
||||
dto.existingItem.contentSize = 0
|
||||
dto.existingItem.lastEditedByUuid = dto.userUuid
|
||||
dto.existingItem.keySystemIdentifier = dto.itemHash.key_system_identifier
|
||||
dto.existingItem.sharedVaultUuid = dto.itemHash.shared_vault_uuid
|
||||
dto.existingItem.lastEditedByUuid = dto.userUuid
|
||||
|
||||
if (dto.itemHash.content) {
|
||||
dto.existingItem.content = dto.itemHash.content
|
||||
}
|
||||
if (dto.itemHash.content_type) {
|
||||
dto.existingItem.contentType = dto.itemHash.content_type
|
||||
}
|
||||
if (dto.itemHash.deleted !== undefined) {
|
||||
dto.existingItem.deleted = dto.itemHash.deleted
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user