Commit Graph

169 Commits

Author SHA1 Message Date
Benjamin
bc53b3ece9 feat: add anonymous telemetry for usage metrics
- Integrate SHM SDK (v1.2.0) to collect anonymous usage statistics
- Track documents, confirmations, webhooks and reminders count
- Add ACKIFY_TELEMETRY env var (disabled by default, opt-in)
2025-12-22 19:04:32 +01:00
Benjamin
eb320cb239 fix: install script env var 2025-12-19 23:02:43 +01:00
Benjamin
32c5fef0a5 Merge branch 'main' into feat/telemetry 2025-12-18 18:02:01 +01:00
Benjamin
cd0b751966 fix: ensures the SessionService is created whenever ANY authentication method is enabled. v1.2.8 2025-12-18 11:44:10 +01:00
Benjamin
41881c02b5 wip 2025-12-18 11:43:05 +01:00
Benjamin
600d709834 fix: missing ci ackify_app role creation 2025-12-16 00:43:52 +01:00
Benjamin
19cda55de9 fix: missing ci ackify_app role creation 2025-12-16 00:25:20 +01:00
Benjamin
44431dabf4 feat(rls): move ackify_app role creation from init script to migrate tool
BREAKING CHANGE: ACKIFY_APP_PASSWORD environment variable is now required for RLS support. The migrate tool creates the ackify_app role before running migrations, ensuring compatibility with existing deployments.

Changes:
- Add ensureAppRole() in cmd/migrate to create/update ackify_app role
- Remove docker/init-scripts/01-create-app-user.sh (no longer needed)
- Update compose.yml: add ACKIFY_APP_PASSWORD, backend connects as ackify_app
- Update migration 0016: remove conditional role creation
- Add RLS documentation (docs/en/configuration/rls.md, docs/fr/configuration/rls.md)
- Update configuration docs with RLS section and security checklist

Migration path for existing deployments:
1. Set ACKIFY_APP_PASSWORD in .env
2. Run docker compose up (migrate will create the role automatically)
2025-12-15 23:59:06 +01:00
Benjamin
eca55c6bcb refactor(go): restore go.mod (and sum) on project root
and restore missing cypress tests
v1.2.6 v1.2.7
2025-12-10 16:29:00 +01:00
Benjamin
5f05ef2b7e refactor(go): rename module to github.com/btouchard/ackify-ce/backend
Enable importing backend packages in other project by aligning module path with its location in the repository.
2025-12-08 19:02:39 +01:00
Benjamin
ab6cdbb383 refactor(go): rename module to github.com/btouchard/ackify-ce/backend
Enable importing backend packages in SaaS project by aligning module
path with its location in the repository.
2025-12-08 19:01:28 +01:00
Benjamin
956192b946 fix(ci): build multi-plateforme linux/amd64,linux/arm64 QEMU 2025-12-08 16:58:29 +01:00
Benjamin
d2a4651ec7 fix(ci): go.mod moved to backend, so build is inside backend folder, not at root 2025-12-08 16:42:42 +01:00
Benjamin
9b7a289a2e fix: remove invalid coreapp from merge 2025-12-08 16:31:37 +01:00
Benjamin
02b2ed0bb5 fix(merge): resolve conflits 2025-12-08 16:13:10 +01:00
Benjamin
24e2de2922 refactor(arch): enforce strict layered architecture with private interfaces
Apply Clean Architecture principles throughout the codebase to eliminate tight coupling between layers. Handlers now depend exclusively on services through private interfaces, never directly on repositories.
Introduce a ServerBuilder pattern with pluggable capability providers.

refactor(auth): introduce injectable AuthorizerService

Replace hardcoded AdminEmails and OnlyAdminCanCreate config fields
with an injectable AuthorizerService. This improves testability and
follows the dependency injection pattern used elsewhere in the codebase.

- Create AuthorizerService in application/services/
- Define minimal Authorizer interfaces in consuming packages
- Update middleware, handlers, and router to use injected authorizer
- Update all affected tests with mock implementations

refactor(build): move go.mod to backend directory
Move Go module files from project root to backend/ directory while keeping the module name as github.com/btouchard/ackify-ce.
This improves project structure by keeping Go-specific files within the Go codebase directory.

# Conflicts:
#	backend/internal/application/services/checksum_service_test.go
#	backend/internal/application/services/document_service.go
#	backend/internal/application/services/document_service_duplicate_test.go
#	backend/internal/application/services/document_service_test.go
#	backend/internal/presentation/api/documents/handler.go
#	backend/internal/presentation/api/documents/handler_test.go
#	backend/internal/presentation/api/router.go
#	backend/pkg/web/server.go
2025-12-08 16:07:03 +01:00
Benjamin
1b108ed874 refacto(backend): extract coreapp packages for DI and authorization
- Add pkg/coreapp/ with service interfaces and dependency injection
- Add DocumentAuthorizer for document access control
- Add ExpectedSignerService for expected signers management
- Simplify router and handlers by using coreapp dependencies
2025-12-04 15:19:01 +01:00
Benjamin
796d327442 feat(tenant): add tenant support
- Add instance_metadata table with unique UUID per instance
- Add tenant_id column to all business tables (documents, signatures, expected_signers, webhooks, reminder_logs, email_queue, checksum_verifications, webhook_deliveries)
- Backfill existing data with instance tenant UUID
- Create TenantProvider interface and SingleTenantProvider implementation
- Update all repositories to filter by tenant_id
- Add immutability triggers to prevent tenant_id modification after creation

Migration 0015 includes:
- Schema changes with indexes for tenant_id columns
- SQL backfill for existing data
- Trigger functions for data integrity
2025-12-03 23:46:09 +01:00
Benjamin
249849b3ed feat(tenant): add tenant support
- Add instance_metadata table with unique UUID per instance
- Add tenant_id column to all business tables (documents, signatures, expected_signers, webhooks, reminder_logs, email_queue, checksum_verifications, webhook_deliveries)
- Backfill existing data with instance tenant UUID
- Create TenantProvider interface and SingleTenantProvider implementation
- Update all repositories to filter by tenant_id
- Add immutability triggers to prevent tenant_id modification after creation

Migration 0015 includes:
- Schema changes with indexes for tenant_id columns
- SQL backfill for existing data
- Trigger functions for data integrity
2025-12-03 22:24:12 +01:00
Benjamin
6d2dd8b000 feat(e2e): fix 05-document-creation-by-url 2025-12-03 13:54:22 +01:00
Benjamin
686edc6123 feat(mail): fix mail suject alway in english, now is based on i18n 2025-12-03 12:21:44 +01:00
Benjamin
aa002f824c feat(db): improve db migrations system with force & goto command (for existing db without migration schema) 2025-12-03 11:01:23 +01:00
Benjamin
0746e8ea12 doc: update changelog v1.2.5 2025-12-01 15:11:37 +01:00
Benjamin
5261dce49e fix(oauth): add Microsoft Graph API field mapping support
Support Microsoft-specific user info fields:
  - email: check 'mail' and 'userPrincipalName' as fallbacks
  - name: check 'displayName' (camelCase) for Microsoft Graph API
2025-12-01 12:19:42 +01:00
Benjamin
bd46d6b706 fix(install): add missing env var on downloadable compose 2025-11-28 21:50:02 +01:00
Benjamin
71a479d953 feat(csv): import expected signature from CSV v1.2.4 2025-11-27 09:03:38 +01:00
Benjamin
533e62fcfe feat(csv): import expected signature from CSV 2025-11-26 23:37:21 +01:00
Benjamin
1608aad6a8 doc: update documentations & changelog
Update documentation to reflect new configuration options (rate limits, smtp, ...)
v1.2.3
2025-11-24 12:40:38 +01:00
Benjamin
4d84224548 fix(ci): configure rate limits for E2E tests
Add rate limit environment variables to prevent 429 errors during E2E tests.
Use high limits (1000) matching compose.e2e.yml configuration to allow
rapid sequential requests during test execution.
2025-11-24 11:17:28 +01:00
Benjamin
d91c40edef fix(deps): revert glob and rimraf overrides to fix nyc@15 compatibility
Remove glob and rimraf from overrides to use versions compatible with nyc@15.
This accepts deprecated warnings for glob@7 and rimraf@3, but ensures
@cypress/code-coverage works correctly for E2E test coverage.

Keep inflight override to eliminate that specific warning.
2025-11-24 11:09:40 +01:00
Benjamin
253b26511a fix(ci): patch nyc@15 to handle glob@10+ and rimraf@5+
Add postinstall script that patches nyc/index.js to handle modern versions
of glob and rimraf. These packages now export objects/named exports instead
of functions, which breaks nyc@15's promisify() calls.

This fixes the 'original argument must be of type function' error.

# Conflicts:
#	webapp/scripts/patch-nyc.cjs
2025-11-24 11:02:53 +01:00
Benjamin
825705b036 fix(ci): patch nyc@15 to fix Node.js 20+ promisify compatibility
Add postinstall script that patches nyc@15 fs-promises.js to handle
promisify errors gracefully. This fixes the 'original argument must be
of type function' error when running Cypress E2E tests with coverage.
2025-11-24 10:32:10 +01:00
Benjamin
84e7743429 fix(ci): use Node.js 20 for E2E tests to fix nyc compatibility
The @cypress/code-coverage package bundles nyc@15 which is incompatible
with Node.js 22+. Downgrade to Node.js 20 for E2E tests only to maintain
coverage collection while other workflows use Node.js 22.
2025-11-24 10:23:32 +01:00
Benjamin
ecd47fd8ec fix(ci): set locales and templates directories for E2E tests
Add ACKIFY_LOCALES_DIR and ACKIFY_TEMPLATES_DIR environment variables
to point to backend directories when running the binary from repo root.
2025-11-24 09:47:53 +01:00
Benjamin
aae9ab111a fix(build): suppress vue-i18n currentInstance warning
Add Rollup onwarn handler to filter the known MISSING_EXPORT warning
where vue-i18n accesses internal Vue APIs (currentInstance).
This is a known compatibility issue that doesn't affect runtime behavior.
2025-11-24 09:44:56 +01:00
Benjamin
f842aedf11 fix(deps): eliminate deprecated npm dependencies
Use npm overrides to force modern versions:
- glob: v7.2.3 → v10.5.0
- rimraf: v3.0.2 → v5.0.10
- inflight: replaced (no longer needed with glob v10+)

This eliminates all deprecation warnings during npm install.
2025-11-24 09:41:02 +01:00
Benjamin
050351620c fix(i18n): handle literal dots in translation keys
The check-i18n script now correctly handles keys with literal dots
(e.g., 'document.created') instead of treating them as nested paths.
2025-11-24 09:33:46 +01:00
Benjamin
f7a22efc3b fix(ci): create empty web/dist directory before backend tests
The go:embed directive in main.go requires web/dist to exist during compilation.
Backend tests don't need the actual frontend, just an empty directory to satisfy the embed directive.
2025-11-24 09:21:28 +01:00
Benjamin
41e18c914f test(frontend): add comprehensive unit tests for stores, services and components
Add business logic tests to improve frontend code coverage and reliability:
- Pinia stores: auth, signatures, ui (87 tests)
- Services: checksumCalculator (19 tests)
- Components: SignButton, NotificationToast (21 tests)

Focus on critical business flows: authentication, signature management,
notification system, and file validation. All tests passing (143 total).
2025-11-24 01:04:41 +01:00
Benjamin
a46715a2f3 fix: robust coverage calculation in test suite script
Fix bash arithmetic syntax error when calculating coverage percentages
from LCOV files. The issue occurred when grep results contained whitespace
or when values were empty strings.
2025-11-24 00:23:56 +01:00
Benjamin
a1c71a023c fix: enable Istanbul code instrumentation for E2E coverage
Fix Cypress code coverage collection by properly configuring vite-plugin-istanbul
to instrument code when CYPRESS_COVERAGE=true.
2025-11-23 23:50:19 +01:00
Benjamin
a7891618c1 feat: comprehensive CI/CD refactoring with unified code coverage
Reorganize GitHub Actions workflows into reusable components and implement
complete code coverage tracking across backend, frontend, and E2E tests.

**CI/CD Improvements:**
- Split monolithic ci.yml into 6 specialized reusable workflows
- New workflows: test-backend, test-frontend, test-e2e, build-docker, security, coverage-report
- Orchestrated execution with proper dependencies and parallel jobs
- Codecov integration with multi-flag coverage (backend/frontend/e2e)

**Frontend Testing:**
- Add Vitest for unit testing with coverage-v8 provider
- Create test setup with window mocks for Ackify globals
- Add 34 unit tests for titleExtractor, referenceDetector, and http utils
- Configure Istanbul instrumentation for E2E coverage collection
- Integrate @cypress/code-coverage for E2E test coverage

**Test Infrastructure:**
- Create run-tests-suite.sh for local comprehensive test execution
- Proper Docker Compose orchestration for integration and E2E tests
- Automatic cleanup handlers with trap for test environments
- Coverage summary aggregation across all test types

**Bug Fixes:**
- Fix backend config tests after OAuth/MagicLink validation changes
- Update tests from panic expectations to error checking
- Ensure OAUTH_COOKIE_SECRET is properly configured in tests

**Configuration:**
- Add .codecov.yml for coverage reporting with flags
- Add .nycrc.json for E2E LCOV generation
- Update .gitignore for test artifacts and coverage reports
- Configure Vite for test environment and code instrumentation
2025-11-23 23:36:02 +01:00
Benjamin
5cd91654e0 feat: configurable rate limiting and comprehensive E2E test suite
Rate Limiting Configuration:
- Add ACKIFY_AUTH_MAGICLINK_RATE_LIMIT_EMAIL (default: 3/hour)
- Add ACKIFY_AUTH_MAGICLINK_RATE_LIMIT_IP (default: 10/hour)
- Add ACKIFY_AUTH_RATE_LIMIT (default: 5/min)
- Add ACKIFY_DOCUMENT_RATE_LIMIT (default: 10/min)
- Add ACKIFY_GENERAL_RATE_LIMIT (default: 100/min)

E2E Test Suite:
- 01-signature-workflow: Complete signature flow validation
- 02-signature-uniqueness: Constraint enforcement and duplicate prevention
- 03-admin-signers-management: Expected signers CRUD operations
- 04-admin-email-reminders: SMTP reminder functionality
- 05-document-creation-by-url: URL-based document initialization
- 06-my-signatures-page: User signature list and navigation
- 07-admin-document-deletion: Cascade deletion verification
- 08-admin-route-protection: Access control validation
- 09-complete-workflow: End-to-end multi-user scenario
- 10-unexpected-signatures: Handling of non-expected signers
2025-11-23 22:27:55 +01:00
Benjamin
779aada760 fix(test): fix configuration for e2e tests and improve en var loading for gracefull stop on error 2025-11-23 11:44:41 +01:00
Benjamin
e885c63f92 test: remove trivial and redundant tests for better maintainability 2025-11-23 11:23:41 +01:00
Benjamin
c579e95a67 feat(frontend): enable TypeScript strict mode for better type safety
Enable strict TypeScript compilation options in the Vue 3 frontend
to catch more potential bugs at compile time and improve code quality.
2025-11-23 01:06:44 +01:00
Benjamin
eecb2565bc refactor(checksum): propagate context for HTTP request cancellation
Add context.Context parameter to checksum computation functions
to enable request cancellation, timeout propagation, and better
observability for remote document downloads.
2025-11-23 01:01:40 +01:00
Benjamin
ddb44df7d0 refactor(crypto): propagate context.Context for observability support
Add context.Context parameter to cryptographic signature operations
to enable distributed tracing, timeout propagation, and cancellation
handling throughout the signature creation pipeline.

This is a breaking change for the cryptoSigner interface but
maintains backward compatibility at the API level.
2025-11-23 00:50:18 +01:00
Benjamin
353b720453 feat(email): add jitter to retry logic to prevent thundering herd
Improve the email retry mechanism by adding 0-30% random jitter
to the exponential backoff calculation. This prevents multiple
failed emails from retrying at exactly the same time, which could
cause load spikes on the SMTP server.

Example retry times (with jitter):
- 1st retry: 1.0-1.3 minutes
- 2nd retry: 2.0-2.6 minutes
- 3rd retry: 4.0-5.2 minutes
2025-11-23 00:43:54 +01:00
Benjamin
3811741401 feat(database): configure PostgreSQL connection pool settings
Add connection pool configuration to optimize database performance and resource usage
2025-11-23 00:37:34 +01:00