chore(work): decompose dsr-consent-and-cookie-banner epic

Generated 1 epic + 11 stories under docs/work/epics/ from the approved
PRD docs/work/prds/dsr-consent-and-cookie-banner.prd.md. Stories cover
subject-linkage types, ADR-018 audit enum amendment, core-consent
foundation + impl + react, core-dsr (4 interfaces), core-api router
composition, core-ui scaffold + CookieConsentBanner, auth signup
migration, and documentation. Ready for `pnpm work dispatch --execute`.
This commit is contained in:
2026-05-19 11:55:05 +02:00
parent ae886a4499
commit 5abf7fe623
13 changed files with 806 additions and 3 deletions

View File

@@ -0,0 +1,43 @@
---
id: 10-auth-signup-migration
epic: dsr-consent-and-cookie-banner
title: auth signUp anonymous consent migration
type: technical-story
status: todo
feature: auth
depends-on: [04-core-consent-implementation]
blocks: [11-documentation]
created: 2026-05-19T12:00:00Z
updated: 2026-05-19T09:55:07.020Z
---
## Goal
Extend the template's `auth.signUp` use case to call `extractAnonymousConsent` + `migrateAnonymousConsent` when a `__consent_state` cookie is present, so a user's pre-signup banner choices persist into their account automatically.
## Why
Without this integration, anonymous users who consented via the banner before signing up would lose their consent state at account creation — forcing them to re-consent or leaving analytics gated incorrectly. The migration call is the canonical example for downstream consumers implementing the same pattern in their own `signUp` use cases.
## Done when
- `auth.signUp` use case calls `extractAnonymousConsent(cookieHeader)` after user-record creation; if a `__consent_state` cookie is present, calls `migrateAnonymousConsent({ userId, cookieState, bannerVersion, policyVersion })`.
- Response includes `Set-Cookie: __consent_state=; Max-Age=0` to clear the anonymous cookie after migration.
- `auth.signUp.use-case.test.ts` covers: mock cookie header present → `migrateAnonymousConsent` called with correct args → audit entry has `method: "signup-migration"` → response cookie cleared; no cookie present → `migrateAnonymousConsent` not called.
- `RecordingConsent` from `core-testing` is used for assertions (not a raw mock).
- `pnpm typecheck && pnpm lint && pnpm test && pnpm conformance && pnpm fallow:audit && pnpm coverage:diff` all pass.
## In scope
- `packages/auth/src/use-cases/sign-up.use-case.ts` — add `extractAnonymousConsent` + `migrateAnonymousConsent` calls.
- `packages/auth/src/use-cases/sign-up.use-case.test.ts` — extend with migration scenarios.
- Auth feature's DI binders — inject `IConsent` dependency when present (guard with `?.` for consumers who haven't installed `core-consent`).
## Out of scope
- Anonymous consent storage in `users.consentState` directly from the banner — anonymous state lives in the cookie until this migration.
- Post-migration analytics re-initialization — consumer's responsibility via `onConsentChange` callback.
## Tasks
- [ ] Extend `auth.signUp` use case to call `extractAnonymousConsent(cookieHeader)` + `migrateAnonymousConsent({ userId, cookieState, bannerVersion, policyVersion })` when a `__consent_state` cookie is present, set `Set-Cookie: __consent_state=; Max-Age=0` in the response, and inject `IConsent` into the use case deps (optional, guarded with `?.`); extend `sign-up.use-case.test.ts` with `RecordingConsent` to assert migration call shape, audit entry `method: "signup-migration"`, and cookie-clear; all gates pass.