Skip to content

Token persistence integration + password handling contracts - #676

Merged
zakkiyyat merged 2 commits into
MixMatch-Inc:devfrom
aaseenib:token-persistence-integration
Jun 29, 2026
Merged

Token persistence integration + password handling contracts#676
zakkiyyat merged 2 commits into
MixMatch-Inc:devfrom
aaseenib:token-persistence-integration

Conversation

@aaseenib

Copy link
Copy Markdown
Contributor

Summary

Closes #606, Closes #607, Closes #613, Closes #614

Token persistence (#607)

  • Backend: Fixed buildTokenResponse in auth.service.ts to include refreshToken in register/login responses (was previously discarded)
  • Shared types: Added refreshToken to AuthTokenResponse in packages/shared/src/types/auth.ts
  • API client: Added refreshAccessToken() and fetchAuthenticated() to apps/web/src/lib/api-client.ts
  • Auth context: Updated auth-context.tsx to store refreshToken, auto-refresh expired tokens on page load, and expose fetchWithAuth() that transparently refreshes on 401
  • Doc: Created apps/docs/token-persistence.md covering data flow, storage, security, and edge case handling

Token persistence edge cases (#606)

  • JWT expiry check on mount with background refresh
  • Corrupted localStorage handling (invalid JSON, missing fields)
  • Concurrent refresh protection (shared promise ref prevents duplicate refreshes)
  • SESSION_EXPIRED error when refresh fails after 401

Password handling scope and contracts (#613)

  • Added formal scope/boundary, input/output contracts, and schema contract to password-handling.md

Password handling core flow (#614)

  • Documented full lifecycle from registration through login with client-side validation

Impact

  • Shared: 14 tests pass
  • Web: 4 tests pass
  • API: 55/60 tests pass (5 pre-existing failures unrelated to this PR)
  • No new dependencies

aaseenib and others added 2 commits June 29, 2026 19:33
Integrate token persistence end-to-end (MixMatch-Inc#607):
- Include refreshToken in register/login responses (auth.service.ts)
- Add refreshToken to AuthTokenResponse shared type
- Add refreshAccessToken and fetchAuthenticated to API client
- Auto-refresh expired tokens on page load and on 401
- Store refreshToken alongside accessToken in localStorage
- Guard against concurrent refresh requests

Harden token persistence edge cases (MixMatch-Inc#606):
- Check JWT expiry on mount, background refresh if expired
- Handle corrupted localStorage gracefully
- Handle 401 after failed refresh (SESSION_EXPIRED error)
- Concurrent refresh protection via shared promise ref

Define password handling scope and contracts (MixMatch-Inc#613):
- Add formal contract: boundary, inputs, outputs, schema contract

Implement password handling core flow (MixMatch-Inc#614):
- Document full lifecycle in password-handling.md

Closes MixMatch-Inc#606
Closes MixMatch-Inc#607
Closes MixMatch-Inc#613
Closes MixMatch-Inc#614
@zakkiyyat
zakkiyyat merged commit 09cd314 into MixMatch-Inc:dev Jun 29, 2026
0 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants