Skip to content

[M2.2e1b] Add typed identity transport and session state - #64

Merged
samuelmbabhazi merged 2 commits into
mainfrom
feat/m2.2e1b-web-identity-client
Nov 5, 2026
Merged

samuelmbabhazi merged 2 commits into
mainfrom
feat/m2.2e1b-web-identity-client

Conversation

@samuelmbabhazi

Copy link
Copy Markdown
Collaborator

The web app now has a typed identity client covering account, MFA and token-management endpoints, plus in-memory session state. Requests use the generated SDK, stay on the current origin, refuse redirects/bearer credentials, avoid caching, cap network waits at twenty seconds and attach only an unambiguous CSRF cookie. Mutation callers supply their retry keys so a UI can preserve a key across an uncertain result.

Session state retains only user ID, email and expiry, including when accepting a response that also contains recovery codes or an API token. A revision counter prevents stale requests from restoring signed-out state. Failed logout remains visibly unconfirmed; missing credentials and service outages have distinct states. UI errors use fixed safe messages and bounded Retry-After values.

Validation: web lint/typecheck, all 11 Angular tests and production build pass. Tests cover cookie/header behavior, cross-origin rejection, duplicate/insecure CSRF cookies, empty responses, sanitized errors and late session responses. The workspace SDK dependency is declared alongside the existing root Angular dependencies so the Angular/Vitest runner resolves it consistently.

Security: credentials remain in request bodies/headers and never enter URLs or browser storage. No new external package/version; only an existing workspace package is linked. Screens and real-browser acceptance follow in M2.2e2–e4. Stacked on #63; no merge requested.

  • M2.2e1b criteria met
  • Web checks and race/security regressions pass
  • Plan/spec current
  • No secret persisted in session state

@samuelmbabhazi samuelmbabhazi changed the title feat(web): add typed identity transport and session state [M2.2e1b] Add typed identity transport and session state Nov 4, 2026
@samuelmbabhazi
samuelmbabhazi force-pushed the fix/m2.2e1a-client-contract branch from 019269c to 486ab5b Compare November 5, 2026 12:37
@samuelmbabhazi
samuelmbabhazi changed the base branch from fix/m2.2e1a-client-contract to main November 5, 2026 12:37
@samuelmbabhazi
samuelmbabhazi force-pushed the feat/m2.2e1b-web-identity-client branch from fa1fe5c to 50fe6bd Compare November 5, 2026 12:37
@samuelmbabhazi
samuelmbabhazi merged commit 5b12898 into main Nov 5, 2026
9 checks passed
@samuelmbabhazi
samuelmbabhazi deleted the feat/m2.2e1b-web-identity-client branch November 5, 2026 12:38
samuelmbabhazi added a commit that referenced this pull request Nov 5, 2026
Identity forms now have a component-scoped mutation runner that
suppresses double submissions, preserves an unchanged request's key
after uncertain failures and discards late results after a form reset or
destruction. Retries stop after four minutes, a backward clock change or
a replay conflict, requiring an explicit restart before another
operation.

Known client rejections release the attempt; transport failures, HTTP
408 and server errors preserve it. Bounded Retry-After delays survive an
explicit restart. Native private fields prevent credential snapshots
from appearing in object serialization, and no result/secret grant is
retained by the runner.

Validation: all 18 Angular tests pass, including seven new
retry/concurrency/destruction regressions; web lint, typecheck and
production build pass. No new dependency, HTTP contract, shell
invocation or server mutation. Plan/spec describe the behavior. Stacked
on #64; no merge requested.

- [x] M2.2e2a criteria met
- [x] Retry, race, cooldown and private-state tests pass
- [x] Plan/spec updated
- [x] Credentials remain in component-lifetime memory only
samuelmbabhazi added a commit that referenced this pull request Nov 5, 2026
…rets on a timer (#98)

## Task

Review follow-up for #64, #66 and #68 (M2.2e1b, M2.2e2b, M2.2e3a). Refs
#21

## What changed

**Session state (`session-store.ts`)**
- Sign-out on an expired or revoked session: the server answers 401,
which now clears the local session instead of keeping "Signed in as …"
with an error that every retry repeats.
- A successful login always updates the session, even if its form was
left before the response arrived. The server has already set the session
cookie, so the UI no longer claims the user is signed out while the next
reload is authenticated. Form side effects (navigation) remain guarded
by the mutation runner.
- A login that fails while it superseded a pending session check re-runs
the check, so the account page no longer stays on "Checking your
session…" until reload.

**One-time secrets (`mfa-form-store.ts`, `token-form-store.ts`)**
- Recovery codes and newly created API tokens are no longer hidden by a
fixed 10-minute timer. They stay until the user acknowledges them,
leaves the page or rotates the session.
- The provisioning seed keeps its timer, which follows the real server
expiry.
- Panel texts and SPEC updated.

## Why

- The 401 sign-out trapped users in a signed-in UI until a full reload
(#64).
- The ignored login left a live server session invisible to the user
(#66).
- The server shows recovery codes and API tokens exactly once. Hiding
them after 10 minutes, with no warning or extension, fails WCAG 2.2.1
(Timing Adjustable, level A) on a core flow. A slow or screen-reader
user copying ten 32-character codes could lose them and then need a TOTP
code to regenerate them (#68).

## How it was tested

- New and updated unit tests: 401 sign-out clears the session; a failed
login that superseded a pending check settles the state; recovery codes
and API tokens are still displayed after an hour without
acknowledgement.
- `nx run-many -t lint typecheck test build -p web` in a clean worktree:
11 files, 52 tests pass; production build passes.
- Browser acceptance could not run: GitHub Actions is blocked by the
account spending limit. CI must pass before merge.

## Security considerations

- Secrets stay in memory longer only while the account page is open and
only until acknowledgement. Departure, session rotation and
acknowledgement still clear them, and they still never serialize out of
the stores.
- The signed-out state after a 401 matches the server state.

## Checklist

- [x] Lint, typecheck, tests and build pass locally
- [x] Tests added and updated
- [x] No new shell invocation and no new secret exposure path
- [x] Audit events: not applicable (client only)
- [x] SPEC updated
- [ ] CI green (blocked by billing)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant