feat(core-consent): add handlers and consentRouter tRPC router

Protocol-agnostic handlers (grant, withdraw, isGranted, getCategories)
in core-consent/handlers/ call IConsent methods and return typed results.

consentRouter uses a consent-specific tRPC context (userId + consentFactory)
so each procedure can resolve the per-user IConsent instance at call time.
Auth middleware guards all four procedures and maps UnauthenticatedError →
UNAUTHORIZED via defineErrorMiddleware from core-shared (no local duplicate).

76 tests passing; new handler and router code at 100% branch coverage.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-19 13:22:33 +00:00
parent ae4e0f2680
commit e53f35a0c5
17 changed files with 518 additions and 24 deletions

6
pnpm-lock.yaml generated
View File

@@ -592,6 +592,12 @@ importers:
"@repo/core-shared":
specifier: workspace:*
version: link:../core-shared
"@trpc/server":
specifier: ^11.0.0
version: 11.16.0(typescript@5.9.3)
zod:
specifier: ^3.24.0
version: 3.25.76
devDependencies:
"@repo/core-eslint":
specifier: workspace:*