Files
agentic-dev/docs/work/epics/dsr-consent-and-cookie-banner/10-auth-signup-migration/_story.md
Danijel Martinek 5abf7fe623 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`.
2026-05-19 11:55:05 +02:00

2.8 KiB

id, epic, title, type, status, feature, depends-on, blocks, created, updated
id epic title type status feature depends-on blocks created updated
10-auth-signup-migration dsr-consent-and-cookie-banner auth signUp anonymous consent migration technical-story todo auth
04-core-consent-implementation
11-documentation
2026-05-19T12:00:00Z 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.