store

package
v0.0.0-...-ae79bc6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 22, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

---------------------------------------------------------------------------------------------- // -- Copyright (c) 2024 Braden Hitchcock - MIT License (https://opensource.org/licenses/MIT) -- // ---------------------------------------------------------------------------------------------- //

---------------------------------------------------------------------------------------------- // -- Copyright (c) 2024 Braden Hitchcock - MIT License (https://opensource.org/licenses/MIT) -- // ---------------------------------------------------------------------------------------------- //

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConversationEntity

type ConversationEntity struct {
	Id            model.Uuid
	CreatedAt     int64
	UpdatedAt     int64
	EncryptedData []byte
}

func NewConversationEntity

func NewConversationEntity(c *types.Conversation, k crypto.Key) (ConversationEntity, error)

func (*ConversationEntity) Decrypt

func (*ConversationEntity) Update

func (e *ConversationEntity) Update(
	k crypto.Key, name, desc []byte, mods [][]byte,
) (*types.Conversation, error)

type ConversationStore

type ConversationStore interface {
	AddConversationEntity(ctx context.Context, e ConversationEntity) error
	GetConversationEntity(ctx context.Context, id model.Uuid) (ConversationEntity, error)
	UpdateConversationEntity(ctx context.Context, e ConversationEntity) error
	RemoveConversationEntity(ctx context.Context, id model.Uuid) error
	ListConversationEntities(ctx context.Context) ([]ConversationEntity, error)
}

type GroupEntity

type GroupEntity struct {
	Id            model.Uuid
	GroupHash     crypto.DataHash
	PassSalt      crypto.Salt
	PassHash      crypto.PassHash
	CreatedAt     int64
	UpdatedAt     int64
	EncryptedKey  []byte
	EncryptedData []byte
}

A GroupEntity bundles together encrypted group information and queryable metadata about the group. The metadata allows the entity to be easily fetched based on search criteria without needing to decrypt the group information.

func NewGroupEntity

func NewGroupEntity(g *types.Group, pass crypto.Password, dkey crypto.Key) (GroupEntity, error)

NewGroupEntity creates a new entity of group inforation to persist in some way. It performs the obfuscation of queryable metadata about a group, encrypts the group information, and combines the metadata with the encrypted group information.

func (*GroupEntity) Decrypt

func (e *GroupEntity) Decrypt(k crypto.Key) (*types.Group, error)

Decrypt decrypts the entity's data buffer and returns a Group object using the underlying buffer.

func (*GroupEntity) Update

func (e *GroupEntity) Update(key crypto.Key, gid, name, desc []byte) (*types.Group, error)

type GroupStore

type GroupStore interface {
	AddGroupEntity(ctx context.Context, e GroupEntity) error
	IsGroupDataSet(ctx context.Context) (bool, error)
	GetGroupEntity(ctx context.Context) (GroupEntity, error)
	UpdateGroupEntity(ctx context.Context, e GroupEntity) error
}

type ListMessageDataQuery

type ListMessageDataQuery struct {
	Author        *model.Uuid
	CreatedAfter  *int64
	CreatedBefore *int64
}

type MemberEntity

type MemberEntity struct {
	Id            model.Uuid
	UsernameHash  crypto.DataHash
	PassHash      crypto.PassHash
	CreatedAt     int64
	UpdatedAt     int64
	EncryptedData []byte
}

func NewMemberEntity

func NewMemberEntity(m *types.Member, pass crypto.Password, key crypto.Key) (MemberEntity, error)

func (*MemberEntity) Decrypt

func (e *MemberEntity) Decrypt(k crypto.Key) (*types.Member, error)

func (*MemberEntity) Update

func (e *MemberEntity) Update(k crypto.Key, uname, name []byte) (*types.Member, error)

type MemberStore

type MemberStore interface {
	AddMemberEntity(ctx context.Context, e MemberEntity) error
	GetMemberEntity(ctx context.Context, id model.Uuid) (MemberEntity, error)
	GetMemberEntityByUname(ctx context.Context, uhash crypto.DataHash) (MemberEntity, error)
	UpdateMemberEntity(ctx context.Context, e MemberEntity) error
	RemoveMemberEntity(ctx context.Context, id model.Uuid) error
	ListMemberEntities(ctx context.Context) ([]MemberEntity, error)
}

type MessageEntity

type MessageEntity struct {
	Id            model.Uuid
	Author        model.Uuid
	Conversation  model.Uuid
	CreatedAt     int64
	UpdatedAt     int64
	EncryptedData []byte
}

func NewMessageEntity

func NewMessageEntity(m *types.Message, k crypto.Key) (MessageEntity, error)

func (*MessageEntity) Decrypt

func (e *MessageEntity) Decrypt(k crypto.Key) (*types.Message, error)

func (*MessageEntity) Update

func (e *MessageEntity) Update(k crypto.Key, content []byte) (*types.Message, error)

type MessageStore

type MessageStore interface {
	AddMessageEntity(ctx context.Context, m MessageEntity) error
	GetMessageEntity(ctx context.Context, id model.Uuid) (MessageEntity, error)
	UpdateMessageEntity(ctx context.Context, m MessageEntity) error
	RemoveMessageEntity(ctx context.Context, id model.Uuid) error
	ListMessageEntities(ctx context.Context, cid model.Uuid, q ListMessageDataQuery) ([]MessageEntity, error)
}

Directories

Path Synopsis
---------------------------------------------------------------------------------------------- // -- Copyright (c) 2024 Braden Hitchcock - MIT License (https://opensource.org/licenses/MIT) -- // ---------------------------------------------------------------------------------------------- //
---------------------------------------------------------------------------------------------- // -- Copyright (c) 2024 Braden Hitchcock - MIT License (https://opensource.org/licenses/MIT) -- // ---------------------------------------------------------------------------------------------- //

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL