services

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2026 License: AGPL-3.0, AGPL-3.0-or-later Imports: 33 Imported by: 0

Documentation

Overview

SPDX-License-Identifier: AGPL-3.0-or-later

SPDX-License-Identifier: AGPL-3.0-or-later

SPDX-License-Identifier: AGPL-3.0-or-later

SPDX-License-Identifier: AGPL-3.0-or-later

SPDX-License-Identifier: AGPL-3.0-or-later

SPDX-License-Identifier: AGPL-3.0-or-later

SPDX-License-Identifier: AGPL-3.0-or-later

SPDX-License-Identifier: AGPL-3.0-or-later

SPDX-License-Identifier: AGPL-3.0-or-later

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoAuthMethod       = errors.New("at least one authentication method must be enabled")
	ErrMagicLinkNeedsSMTP = errors.New("MagicLink requires SMTP to be configured")
	ErrOIDCNeedsURLs      = errors.New("custom OIDC provider requires auth, token, and userinfo URLs")
	ErrInvalidCategory    = errors.New("invalid configuration category")
)

Functions

This section is empty.

Types

type AdminService added in v1.2.7

type AdminService struct {
	// contains filtered or unexported fields
}

AdminService handles all admin-specific operations on documents and signers

func NewAdminService added in v1.2.7

func NewAdminService(docRepo adminDocumentRepository, signerRepo adminSignerRepository) *AdminService

NewAdminService creates a new admin service

func (*AdminService) AddExpectedSigners added in v1.2.7

func (s *AdminService) AddExpectedSigners(ctx context.Context, docID string, contacts []models.ContactInfo, addedBy string) error

func (*AdminService) CountDocuments added in v1.2.7

func (s *AdminService) CountDocuments(ctx context.Context, searchQuery string) (int, error)

func (*AdminService) DeleteDocument added in v1.2.7

func (s *AdminService) DeleteDocument(ctx context.Context, docID string) error

func (*AdminService) GetDocument added in v1.2.7

func (s *AdminService) GetDocument(ctx context.Context, docID string) (*models.Document, error)

Document operations

func (*AdminService) GetSignerStats added in v1.2.7

func (s *AdminService) GetSignerStats(ctx context.Context, docID string) (*models.DocCompletionStats, error)

func (*AdminService) ListDocuments added in v1.2.7

func (s *AdminService) ListDocuments(ctx context.Context, limit, offset int) ([]*models.Document, error)

func (*AdminService) ListExpectedSigners added in v1.2.7

func (s *AdminService) ListExpectedSigners(ctx context.Context, docID string) ([]*models.ExpectedSigner, error)

Expected signer operations

func (*AdminService) ListExpectedSignersWithStatus added in v1.2.7

func (s *AdminService) ListExpectedSignersWithStatus(ctx context.Context, docID string) ([]*models.ExpectedSignerWithStatus, error)

func (*AdminService) RemoveExpectedSigner added in v1.2.7

func (s *AdminService) RemoveExpectedSigner(ctx context.Context, docID, email string) error

func (*AdminService) SearchDocuments added in v1.2.7

func (s *AdminService) SearchDocuments(ctx context.Context, query string, limit, offset int) ([]*models.Document, error)

func (*AdminService) UpdateDocumentMetadata added in v1.2.7

func (s *AdminService) UpdateDocumentMetadata(ctx context.Context, docID string, input models.DocumentInput, updatedBy string) (*models.Document, error)

type CSVParseError added in v1.2.4

type CSVParseError struct {
	LineNumber int    `json:"lineNumber"`
	Content    string `json:"content"`
	Error      string `json:"error"`
}

CSVParseError represents an error for a specific line in the CSV

type CSVParseResult added in v1.2.4

type CSVParseResult struct {
	Signers      []CSVSignerEntry `json:"signers"`
	Errors       []CSVParseError  `json:"errors"`
	TotalLines   int              `json:"totalLines"`
	ValidCount   int              `json:"validCount"`
	InvalidCount int              `json:"invalidCount"`
	HasHeader    bool             `json:"hasHeader"`
}

CSVParseResult contains the complete result of parsing a CSV file

type CSVParser added in v1.2.4

type CSVParser struct {
	// contains filtered or unexported fields
}

CSVParser handles CSV file parsing for expected signers import

func NewCSVParser added in v1.2.4

func NewCSVParser(maxSigners int) *CSVParser

NewCSVParser creates a new CSV parser with the given configuration

func (*CSVParser) Parse added in v1.2.4

func (p *CSVParser) Parse(reader io.Reader) (*CSVParseResult, error)

Parse reads and parses a CSV file from the given reader

type CSVParserConfig added in v1.2.4

type CSVParserConfig struct {
	MaxSigners int
}

CSVParserConfig holds configuration for CSV parsing

type CSVSignerEntry added in v1.2.4

type CSVSignerEntry struct {
	LineNumber int    `json:"lineNumber"`
	Email      string `json:"email"`
	Name       string `json:"name"`
}

CSVSignerEntry represents a valid signer entry parsed from CSV

type ChainIntegrityResult

type ChainIntegrityResult struct {
	IsValid      bool
	TotalRecords int
	BreakAtID    *int64
	Details      string
}

type ConfigService added in v1.3.0

type ConfigService struct {
	// contains filtered or unexported fields
}

ConfigService manages application configuration with hot-reload support

func NewConfigService added in v1.3.0

func NewConfigService(repo configRepository, envConfig *config.Config, encryptionKey []byte) *ConfigService

NewConfigService creates a new configuration service

func (*ConfigService) CloseAllSubscribers added in v1.3.0

func (s *ConfigService) CloseAllSubscribers()

CloseAllSubscribers closes all subscriber channels (used during shutdown)

func (*ConfigService) GetConfig added in v1.3.0

func (s *ConfigService) GetConfig() *models.MutableConfig

GetConfig returns the current config (lock-free read)

func (*ConfigService) Initialize added in v1.3.0

func (s *ConfigService) Initialize(ctx context.Context) error

Initialize loads config from DB or seeds from ENV on first start

func (*ConfigService) ResetFromENV added in v1.3.0

func (s *ConfigService) ResetFromENV(ctx context.Context, updatedBy string) error

ResetFromENV resets config to current ENV values

func (*ConfigService) Subscribe added in v1.3.0

func (s *ConfigService) Subscribe() <-chan models.MutableConfig

Subscribe registers a channel to receive config updates

func (*ConfigService) TestOIDC added in v1.3.0

func (s *ConfigService) TestOIDC(ctx context.Context, cfg models.OIDCConfig) error

TestOIDC tests OIDC configuration by fetching the well-known endpoint

func (*ConfigService) TestS3 added in v1.3.0

func (s *ConfigService) TestS3(ctx context.Context, cfg models.StorageConfig) error

TestS3 tests S3 connection

func (*ConfigService) TestSMTP added in v1.3.0

func (s *ConfigService) TestSMTP(ctx context.Context, cfg models.SMTPConfig) error

TestSMTP tests SMTP connection

func (*ConfigService) UpdateSection added in v1.3.0

func (s *ConfigService) UpdateSection(ctx context.Context, category models.ConfigCategory, input json.RawMessage, updatedBy string) error

UpdateSection updates a specific config section

type CreateDocumentRequest

type CreateDocumentRequest struct {
	Reference string `json:"reference" validate:"required,min=1"`
	Title     string `json:"title"`
	CreatedBy string `json:"created_by,omitempty"`

	// Reader options
	ReadMode        string `json:"read_mode,omitempty"`
	AllowDownload   *bool  `json:"allow_download,omitempty"`
	RequireFullRead *bool  `json:"require_full_read,omitempty"`
	VerifyChecksum  *bool  `json:"verify_checksum,omitempty"`

	// Storage fields for uploaded files
	StorageKey        string `json:"storage_key,omitempty"`
	StorageProvider   string `json:"storage_provider,omitempty"`
	FileSize          int64  `json:"file_size,omitempty"`
	MimeType          string `json:"mime_type,omitempty"`
	Checksum          string `json:"checksum,omitempty"`
	ChecksumAlgorithm string `json:"checksum_algorithm,omitempty"`
	OriginalFilename  string `json:"original_filename,omitempty"`
}

CreateDocumentRequest represents the request to create a document

type DocumentService

type DocumentService struct {
	// contains filtered or unexported fields
}

DocumentService handles document metadata operations and unique ID generation

func NewDocumentService

func NewDocumentService(repo documentRepository, expectedSignerRepo docExpectedSignerRepository, checksumConfig *config.ChecksumConfig) *DocumentService

NewDocumentService initializes the document service with its repository dependency

func (*DocumentService) Count added in v1.2.7

func (s *DocumentService) Count(ctx context.Context, searchQuery string) (int, error)

Count returns the total number of documents matching the search query

func (*DocumentService) CountByCreatedBy added in v1.3.0

func (s *DocumentService) CountByCreatedBy(ctx context.Context, createdBy, searchQuery string) (int, error)

CountByCreatedBy returns the total number of documents created by a specific user

func (*DocumentService) CountDocs added in v1.3.0

func (s *DocumentService) CountDocs(ctx context.Context) int

CountDocs returns the current count of documents

func (*DocumentService) CreateDocument

func (s *DocumentService) CreateDocument(ctx context.Context, req CreateDocumentRequest) (*models.Document, error)

CreateDocument generates a collision-resistant base36 identifier and persists document metadata

func (*DocumentService) FindByReference

func (s *DocumentService) FindByReference(ctx context.Context, ref string, refType string) (*models.Document, error)

FindByReference finds a document by its reference without creating it

func (*DocumentService) FindOrCreateDocument

func (s *DocumentService) FindOrCreateDocument(ctx context.Context, ref string, createdBy string) (*models.Document, bool, error)

FindOrCreateDocument performs smart lookup by URL/path/reference or creates new document if not found

func (*DocumentService) GetByDocID added in v1.2.7

func (s *DocumentService) GetByDocID(ctx context.Context, docID string) (*models.Document, error)

GetByDocID retrieves a document by its ID

func (*DocumentService) GetExpectedSignerStats added in v1.2.7

func (s *DocumentService) GetExpectedSignerStats(ctx context.Context, docID string) (*models.DocCompletionStats, error)

GetExpectedSignerStats retrieves completion statistics for expected signers

func (*DocumentService) List added in v1.2.7

func (s *DocumentService) List(ctx context.Context, limit, offset int) ([]*models.Document, error)

List retrieves a paginated list of documents

func (*DocumentService) ListByCreatedBy added in v1.3.0

func (s *DocumentService) ListByCreatedBy(ctx context.Context, createdBy string, limit, offset int) ([]*models.Document, error)

ListByCreatedBy retrieves a paginated list of documents created by a specific user

func (*DocumentService) ListExpectedSigners added in v1.2.7

func (s *DocumentService) ListExpectedSigners(ctx context.Context, docID string) ([]*models.ExpectedSigner, error)

ListExpectedSigners retrieves all expected signers for a document

func (*DocumentService) Search added in v1.2.7

func (s *DocumentService) Search(ctx context.Context, query string, limit, offset int) ([]*models.Document, error)

Search performs a search query across documents

func (*DocumentService) SearchByCreatedBy added in v1.3.0

func (s *DocumentService) SearchByCreatedBy(ctx context.Context, createdBy, query string, limit, offset int) ([]*models.Document, error)

SearchByCreatedBy performs a search query across documents created by a specific user

type MagicLinkRepository added in v1.2.1

type MagicLinkRepository interface {
	CreateToken(ctx context.Context, token *models.MagicLinkToken) error
	GetByToken(ctx context.Context, token string) (*models.MagicLinkToken, error)
	MarkAsUsed(ctx context.Context, token string, ip string, userAgent string) error
	DeleteExpired(ctx context.Context) (int64, error)

	LogAttempt(ctx context.Context, attempt *models.MagicLinkAuthAttempt) error
	CountRecentAttempts(ctx context.Context, email string, since time.Time) (int, error)
	CountRecentAttemptsByIP(ctx context.Context, ip string, since time.Time) (int, error)
}

MagicLinkRepository définit les opérations sur les tokens Magic Link

type MagicLinkService added in v1.2.1

type MagicLinkService struct {
	// contains filtered or unexported fields
}

MagicLinkService gère l'authentification par Magic Link

func NewMagicLinkService added in v1.2.1

func NewMagicLinkService(cfg MagicLinkServiceConfig) *MagicLinkService

func (*MagicLinkService) CleanupExpiredTokens added in v1.2.1

func (s *MagicLinkService) CleanupExpiredTokens(ctx context.Context) (int64, error)

CleanupExpiredTokens supprime les tokens expirés (à appeler périodiquement)

func (*MagicLinkService) CreateReminderAuthToken added in v1.2.1

func (s *MagicLinkService) CreateReminderAuthToken(
	ctx context.Context,
	emailAddr string,
	docID string,
) (string, error)

CreateReminderAuthToken génère un token d'authentification pour un email de reminder Ce token a une durée de validité de 24 heures (vs 15 min pour magic link classique) Il ne valide pas les domaines autorisés et n'envoie pas d'email (géré par ReminderService)

func (s *MagicLinkService) RequestMagicLink(
	ctx context.Context,
	emailAddr string,
	redirectTo string,
	ip string,
	userAgent string,
	locale string,
) error

RequestMagicLink génère et envoie un Magic Link par email

func (s *MagicLinkService) VerifyMagicLink(
	ctx context.Context,
	token string,
	ip string,
	userAgent string,
) (*models.MagicLinkToken, error)

VerifyMagicLink vérifie et consomme un token Magic Link

func (*MagicLinkService) VerifyReminderAuthToken added in v1.2.1

func (s *MagicLinkService) VerifyReminderAuthToken(
	ctx context.Context,
	token string,
	ip string,
	userAgent string,
) (*models.MagicLinkToken, error)

VerifyReminderAuthToken vérifie et consomme un token de reminder auth

type MagicLinkServiceConfig added in v1.2.1

type MagicLinkServiceConfig struct {
	Repository        MagicLinkRepository
	EmailSender       emailSender
	I18n              i18nTranslator
	BaseURL           string
	AppName           string
	AllowedDomains    []string
	TokenValidity     time.Duration // Défaut: 15 minutes
	RateLimitPerEmail int           // Défaut: 3
	RateLimitPerIP    int           // Défaut: 10
	RateLimitWindow   time.Duration // Défaut: 1 heure
}

MagicLinkServiceConfig pour le service Magic Link

type ReferenceType

type ReferenceType string
const (
	ReferenceTypeURL       ReferenceType = "url"
	ReferenceTypePath      ReferenceType = "path"
	ReferenceTypeReference ReferenceType = "reference"
)

type ReminderAsyncService

type ReminderAsyncService struct {
	// contains filtered or unexported fields
}

ReminderAsyncService manages email notifications using asynchronous queue

func NewReminderAsyncService

func NewReminderAsyncService(
	expectedSignerRepo asyncExpectedSignerRepository,
	reminderRepo asyncReminderRepository,
	queueRepo emailQueueRepository,
	magicLinkService asyncMagicLinkService,
	i18nService translator,
	baseURL string,
) *ReminderAsyncService

NewReminderAsyncService initializes async reminder service with queue support

func (*ReminderAsyncService) CountSent added in v1.3.0

func (s *ReminderAsyncService) CountSent(ctx context.Context) int

CountSent returns the number of sent reminders for a document

func (*ReminderAsyncService) EnableAsync

func (s *ReminderAsyncService) EnableAsync(enabled bool)

EnableAsync enables or disables async queue processing

func (*ReminderAsyncService) GetQueueStats

func (s *ReminderAsyncService) GetQueueStats(ctx context.Context) (*models.EmailQueueStats, error)

GetQueueStats returns current email queue statistics

func (*ReminderAsyncService) GetReminderHistory

func (s *ReminderAsyncService) GetReminderHistory(ctx context.Context, docID string) ([]*models.ReminderLog, error)

GetReminderHistory retrieves complete email send log with success/failure tracking

func (*ReminderAsyncService) GetReminderStats

func (s *ReminderAsyncService) GetReminderStats(ctx context.Context, docID string) (*models.ReminderStats, error)

GetReminderStats retrieves aggregated reminder metrics for monitoring dashboard

func (*ReminderAsyncService) SendReminders

func (s *ReminderAsyncService) SendReminders(
	ctx context.Context,
	docID string,
	sentBy string,
	specificEmails []string,
	docURL string,
	locale string,
) (*models.ReminderSendResult, error)

SendReminders is a compatibility method that calls SendRemindersAsync This allows the service to work with existing interfaces expecting SendReminders

func (*ReminderAsyncService) SendRemindersAsync

func (s *ReminderAsyncService) SendRemindersAsync(
	ctx context.Context,
	docID string,
	sentBy string,
	specificEmails []string,
	docURL string,
	locale string,
) (*models.ReminderSendResult, error)

SendRemindersAsync dispatches email notifications to queue for async processing

type SignatureService

type SignatureService struct {
	// contains filtered or unexported fields
}

SignatureService orchestrates signature creation with Ed25519 cryptography and hash chain linking

func NewSignatureService

func NewSignatureService(repo repository, docRepo documentRepository, signer cryptoSigner) *SignatureService

NewSignatureService initializes the signature service with repository and cryptographic signer dependencies

func (*SignatureService) CheckUserSignature

func (s *SignatureService) CheckUserSignature(ctx context.Context, docID, userIdentifier string) (bool, error)

CheckUserSignature verifies signature existence using flexible identifier matching (email or OAuth subject)

func (*SignatureService) CountSigns added in v1.3.0

func (s *SignatureService) CountSigns(ctx context.Context) int

CountSigns returns the current count of signatures in the database

func (*SignatureService) CreateSignature

func (s *SignatureService) CreateSignature(ctx context.Context, request *models.SignatureRequest) error

CreateSignature validates user authorization, generates cryptographic proof, and chains to previous signature

func (*SignatureService) GetDocumentSignatures

func (s *SignatureService) GetDocumentSignatures(ctx context.Context, docID string) ([]*models.Signature, error)

GetDocumentSignatures retrieves all cryptographic signatures associated with a document for public verification

func (*SignatureService) GetSignatureByDocAndUser

func (s *SignatureService) GetSignatureByDocAndUser(ctx context.Context, docID string, user *models.User) (*models.Signature, error)

GetSignatureByDocAndUser retrieves a specific signature record for verification or display purposes

func (*SignatureService) GetSignatureStatus

func (s *SignatureService) GetSignatureStatus(ctx context.Context, docID string, user *models.User) (*models.SignatureStatus, error)

GetSignatureStatus checks if a user has already signed a document and returns signature timestamp if exists

func (*SignatureService) GetUserSignatures

func (s *SignatureService) GetUserSignatures(ctx context.Context, user *models.User) ([]*models.Signature, error)

GetUserSignatures retrieves all documents signed by a specific user for personal dashboard display

func (*SignatureService) RebuildChain

func (s *SignatureService) RebuildChain(ctx context.Context) error

RebuildChain recalculates and updates prev_hash pointers for existing signatures during migration

func (*SignatureService) SetChecksumConfig

func (s *SignatureService) SetChecksumConfig(cfg *config.ChecksumConfig)

SetChecksumConfig sets the checksum configuration for document verification

func (*SignatureService) VerifyChainIntegrity

func (s *SignatureService) VerifyChainIntegrity(ctx context.Context) (*ChainIntegrityResult, error)

VerifyChainIntegrity validates the cryptographic hash chain across all signatures for tamper detection

type WebhookPublisher

type WebhookPublisher struct {
	// contains filtered or unexported fields
}

WebhookPublisher publishes events to active webhooks via delivery queue

func NewWebhookPublisher

func NewWebhookPublisher(repo webhookRepo, deliveries webhookDeliveryRepo) *WebhookPublisher

func (*WebhookPublisher) Publish

func (p *WebhookPublisher) Publish(ctx context.Context, eventType string, payload map[string]interface{}) error

Publish enqueues deliveries for all webhooks subscribed to the event

type WebhookService added in v1.2.7

type WebhookService struct {
	// contains filtered or unexported fields
}

WebhookService handles webhook management and delivery operations

func NewWebhookService added in v1.2.7

func NewWebhookService(webhookRepo webhookRepository, deliveryRepo webhookDeliveryRepository) *WebhookService

NewWebhookService creates a new webhook service

func (*WebhookService) CountWebhooks added in v1.3.0

func (s *WebhookService) CountWebhooks(ctx context.Context) int

CountWebhooks returns the total number of webhooks

func (*WebhookService) CreateWebhook added in v1.2.7

func (s *WebhookService) CreateWebhook(ctx context.Context, input models.WebhookInput) (*models.Webhook, error)

CreateWebhook creates a new webhook

func (*WebhookService) DeleteWebhook added in v1.2.7

func (s *WebhookService) DeleteWebhook(ctx context.Context, id int64) error

DeleteWebhook deletes a webhook

func (*WebhookService) EnqueueDelivery added in v1.2.7

EnqueueDelivery enqueues a webhook delivery

func (*WebhookService) GetWebhookByID added in v1.2.7

func (s *WebhookService) GetWebhookByID(ctx context.Context, id int64) (*models.Webhook, error)

GetWebhookByID retrieves a webhook by ID

func (*WebhookService) ListActiveWebhooksByEvent added in v1.2.7

func (s *WebhookService) ListActiveWebhooksByEvent(ctx context.Context, event string) ([]*models.Webhook, error)

ListActiveWebhooksByEvent retrieves active webhooks for a specific event

func (*WebhookService) ListDeliveries added in v1.2.7

func (s *WebhookService) ListDeliveries(ctx context.Context, webhookID int64, limit, offset int) ([]*models.WebhookDelivery, error)

ListDeliveries retrieves delivery history for a webhook

func (*WebhookService) ListWebhooks added in v1.2.7

func (s *WebhookService) ListWebhooks(ctx context.Context, limit, offset int) ([]*models.Webhook, error)

ListWebhooks retrieves all webhooks with pagination

func (*WebhookService) SetWebhookActive added in v1.2.7

func (s *WebhookService) SetWebhookActive(ctx context.Context, id int64, active bool) error

SetWebhookActive enables or disables a webhook

func (*WebhookService) UpdateWebhook added in v1.2.7

func (s *WebhookService) UpdateWebhook(ctx context.Context, id int64, input models.WebhookInput) (*models.Webhook, error)

UpdateWebhook updates an existing webhook

Jump to

Keyboard shortcuts

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