feat(auth): migrate anonymous consent on signUp when cc_consent cookie present

Adds ConsentFactoryProtocol / ConsentGrantMeta / ConsentProtocol to
core-shared/di/bind-protocols so feature binders can wire per-user
consent without a hard dep on the optional @repo/core-consent package.
BindContext gains an optional consentFactory? field following the same
pattern as bus?, auditLog?, etc.

signUpUseCase gains a 4th optional dep (consentFactory). When present
and the input includes a cookieHeader containing cc_consent=<categories>,
the use case calls consent.grant for each category with
method:"signup-migration" and returns a clearCookie payload (Max-Age:0)
so the anonymous cookie is cleared on the HTTP response.

Tests use RecordingConsent from @repo/core-testing to assert migration
call shape and cookie-clear; no-cookie and no-factory branches are also
covered. All coverage bands hold at 100% for use-cases.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-19 21:52:08 +00:00
parent 5151454783
commit 6b66064386
11 changed files with 272 additions and 54 deletions

View File

@@ -1,33 +1,33 @@
{
"generatedAt": "2026-05-19T21:36:08.521Z",
"commit": "cbe7412",
"generatedAt": "2026-05-19T21:51:40.371Z",
"commit": "5151454",
"repo": {
"statements": 97.38,
"branches": 92.08,
"functions": 97.09,
"branches": 92.19,
"functions": 97.1,
"lines": 97.38,
"counts": {
"lf": 5758,
"lh": 5607,
"brf": 1149,
"brh": 1058,
"fnf": 344,
"fnh": 334
"lf": 5801,
"lh": 5649,
"brf": 1165,
"brh": 1074,
"fnf": 345,
"fnh": 335
}
},
"byPackage": {
"@repo/auth": {
"statements": 93.81,
"branches": 90.82,
"statements": 94,
"branches": 92.11,
"functions": 100,
"lines": 93.81,
"lines": 94,
"counts": {
"lf": 791,
"lh": 742,
"brf": 98,
"brh": 89,
"fnf": 44,
"fnh": 44
"lf": 834,
"lh": 784,
"brf": 114,
"brh": 105,
"fnf": 45,
"fnh": 45
}
},
"@repo/blog": {