services

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileService

type FileService struct {
	App        *pocketbase.PocketBase
	Encryption *Service
}

FileService handles encrypted file operations

func NewFileService

func NewFileService(app *pocketbase.PocketBase, encryption *Service) *FileService

NewFileService creates a new file service

func (*FileService) DeleteEncryptedFile

func (f *FileService) DeleteEncryptedFile(phrase string) error

DeleteEncryptedFile deletes an encrypted file record (file bytes are removed by PocketBase)

func (*FileService) RetrieveDecryptedFile

func (f *FileService) RetrieveDecryptedFile(phrase string) ([]byte, string, string, error)

RetrieveDecryptedFile retrieves and decrypts a file from the file_data field

func (*FileService) StoreEncryptedFile

func (f *FileService) StoreEncryptedFile(phrase string, file multipart.File, filename, contentType string) (string, error)

StoreEncryptedFile stores an encrypted file (encrypted bytes go into the file_data field)

type Note

type Note struct {
	ID        string    `json:"id"`
	Phrase    string    `json:"phrase"`     // Encrypted identifier
	Message   string    `json:"message"`    // Encrypted note content
	ImageHash string    `json:"image_hash"` // Hash for encrypted image lookup
	Created   time.Time `json:"created"`
	Updated   time.Time `json:"updated"`
}

Note represents a secret note

type NoteService

type NoteService struct {
	App        *pocketbase.PocketBase
	Encryption *Service
}

NoteService handles note operations

func NewNoteService

func NewNoteService(app *pocketbase.PocketBase, encryption *Service) *NoteService

NewNoteService creates a new note service

func (*NoteService) DeleteNote

func (n *NoteService) DeleteNote(phrase string) error

DeleteNote deletes a note

func (*NoteService) GetOrCreateNote

func (n *NoteService) GetOrCreateNote(phrase string) (*Note, error)

GetOrCreateNote retrieves an existing note or creates a new one

func (*NoteService) UpdateNote

func (n *NoteService) UpdateNote(phrase, message string) (*Note, error)

UpdateNote updates an existing note

func (*NoteService) UpdateNoteImageHash

func (n *NoteService) UpdateNoteImageHash(phrase, imageHash string) error

UpdateNoteImageHash updates the image hash for a note

type Service

type Service struct {
	SaltSize int
	KeySize  int
}

Service provides encryption and decryption functionality

func NewEncryptionService

func NewEncryptionService() *Service

NewEncryptionService creates a new encryption service

func (*Service) DecryptData

func (s *Service) DecryptData(encryptedData []byte, phrase string) ([]byte, error)

DecryptData decrypts data using AES-256-GCM

func (*Service) DecryptString

func (s *Service) DecryptString(encryptedText string, phrase string) (string, error)

DecryptString decrypts a base64 encoded string and returns the original string

func (*Service) DeriveKey

func (s *Service) DeriveKey(phrase string, salt []byte) []byte

DeriveKey derives a key from a passphrase using PBKDF2

func (*Service) EncryptData

func (s *Service) EncryptData(data []byte, phrase string) ([]byte, error)

EncryptData encrypts data using AES-256-GCM

func (*Service) EncryptString

func (s *Service) EncryptString(text string, phrase string) (string, error)

EncryptString encrypts a string and returns a base64 encoded string

Jump to

Keyboard shortcuts

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