What you'll learn: By the end of this case study you will be able to design the front end of a dashboard that shows sensitive financial data: mask and reveal fields on demand, keep full values out of the page until needed, show balances that are exact and say how old they are, design a session timer that warns, locks and wipes, ask for a fresh sign-in before risky actions, bind an approval to the one transfer the user saw, and explain each choice as a trade-off. A lab with a pure TypeScript core and a thin React layer backs the rules. This is engineering education, not financial or legal advice.
Think of a bank branch counter with a glass partition. The teller shows you your balance on a screen angled towards you, reads out only the last digits of an account number, and asks for your card again before a large withdrawal. If you walk away mid-conversation, the screen is cleared. A banking dashboard has to do the same things for a person who can walk away from a browser tab at any time, on a device that anyone might pick up.
This is an educational reference design, not the verified internal architecture of any bank or other company. It names no real institution, uses generic parts, and labels every number, time limit and threshold as illustrative. It does not say what any law or regulator requires of a bank, and it is not financial or legal advice: limits and rules for a real product come from its own risk assessment, its regulators and its lawyers. The method follows the Front-End Case Study Method lesson: requirements, constraints, architecture, deep dives, failure, decision.
The core idea
- The screen is not the authority. The server decides who is signed in, for how long, what a number is and whether a transfer is allowed. The front end presents, warns and reacts.
- Show the least, for the shortest time. Sensitive values are masked by default, fetched only when asked for, shown briefly and removed when the session ends.
- Every number carries its age and its source. A balance is a statement about a moment. The screen says which moment and never replaces the server's figure with its own arithmetic.
- Risky actions get a fresh proof, and an approval covers exactly one thing. What the user approved must be what the server executes.
Requirements and constraints
Functional. Sign in, see accounts with balances, read a transaction list with posted and pending items, reveal an account number, add a payee, make a transfer, sign out.
Non-functional (illustrative). A forgotten screen must not stay open. A shoulder-surfer or a later user of a shared machine should learn as little as possible. A figure on screen must be exactly the server's figure. A risky action must need a recent sign-in. The page must work with a keyboard and a screen reader, including its warnings.
Constraints that shape the design.
- The browser is untrusted. Anything held in it can be read by whoever uses the device, by a malicious extension, or by a script that gets in through a bug. Less data held means less exposed (Threat Modeling for Front Ends is the method).
- Time is unreliable in a tab. Timers in a background tab are throttled, a laptop can sleep, and a device clock can be wrong.
- Rules vary by product and place. Session limits, approval rules and retention are set by each organisation's risk analysis and its regulators. The lab makes them parameters for that reason.
- Accessibility. A timeout is a time limit, and time limits have accessibility rules of their own.
Architecture overview
The identity side (sign-in, tokens, per-tenant providers) is covered in Enterprise SSO, Audit and Compliance in the UI, JWTs, Single Sign-On and the Session Lifecycle and Token Storage and Secure Cookies. This case study assumes a sign-in exists and concentrates on what the dashboard does with it.
Figure 1. Dashboard front end and the services it relies on
How to read this: the left zone is everything an untrusted device can see and change. The session guard in it only decides what the screen does. The server zone enforces the real limits, asks the identity provider how recently the user signed in, and writes the audit trail.
Showing sensitive data
Mask by default, fetch on demand
An account list needs a name, a masked number and a balance. It does not need the full number. In the lab the list data carries only the last four digits; the full number is fetched by a separate call when the user asks to see it, held in a small reveal state with a deadline, and removed when the deadline passes, when the user hides it, or when the session locks. A test renders the dashboard and asserts the full number is absent from the page text until it is requested, and absent again after a lock.
This is data minimisation applied to a screen. Values never sent are values that cannot be read from a cache, a log, an extension or a screenshot of a developer tool. Which digits to show is a product decision; the last four is a common choice and the lab uses it only as an illustration.
Where else the value can leak
- HTTP caches. OWASP's Session Management Cheat Sheet says to set the cache policy on sensitive pages and to use
Cache-Control: no-storeon responses containing session identifiers or sensitive session data. MDN saysno-storetells caches of any kind, private or shared, not to store a response, and advisesprivatefor personalised content. For this dashboard, balance and account responses useno-store. See HTTP Caching for the Front End. - Sign-out. MDN documents the
Clear-Site-Dataheader as a way for a server to tell the browser to remove cookies, storage and cache data for the origin, and suggests sending it on the page that confirms a successful sign-out. It does not replace server-side session invalidation. The OWASP cheat sheet says logout must invalidate the session at least on the server side. - URLs, logs and analytics. An account number in a URL or an event payload travels to systems with other retention rules. The OWASP Logging Cheat Sheet lists data that should usually not be recorded in logs, including access tokens, authentication passwords and bank account or payment card holder data. Keep the same discipline in browser error reports and analytics (Logging, Tracing and Correlation IDs and Real User Monitoring).
- Scripts. Anything the page executes can read the page. A strict Content Security Policy and careful handling of third-party scripts reduce that risk (Content Security Policy, XSS Defenses).
- Over-the-shoulder and screen sharing. A "hide balances" switch is a cheap product feature that helps in public places. It is a convenience, not a security control.
Figure 2. Where a sensitive value lives, and when it is removed
How to read this: the value exists in the browser only between the fetch and the removal. The step-up check can refuse the request first, in which case nothing is fetched.
Numbers that are exact and say how old they are
Exact amounts
JavaScript numbers are double-precision floats. MDN documents that integers are exact only up to Number.MAX_SAFE_INTEGER (2^53 minus 1), and that Number.MAX_SAFE_INTEGER + 1 === Number.MAX_SAFE_INTEGER + 2 is true. MDN recommends BigInt for larger integers. The lab holds amounts as BigInt minor units, with these rules:
- Amounts travel as strings.
JSON.stringifyraises aTypeErrorfor anyBigIntvalue, and MDN notes aBigIntcannot be mixed with aNumberin arithmetic. The lab parses a string like"-1234.56"into-123456nand formats only at the edge. - Two decimals is a simplification. MDN's
Intl.NumberFormatexamples show the yen with no minor unit, so a real product takes the number of decimals from currency data. The lab uses one illustrative currency. - Never compute a balance in the browser and show it as the balance. The lab's
reconcilecompares the server's ledger balance with the sum of the posted rows on screen. If they differ (a page of transactions is missing, a row has not arrived), the screen reports the difference. It never overwrites the server's figure with its own.
Ledger, pending and available
A statement list has posted and pending rows. The lab's rule, which is illustrative because each institution defines its own, is: ledger is the sum of posted rows, holds is pending money out, and available is ledger plus holds. Pending money in is not counted as available. The point for the front end is to label these differently and to take them from the server. Payments and Double-Entry Ledgers explains where the figures come from.
Illustration 1: the minimal example, three numbers from one list
Four rows (salary 2,500.00 and rent -1,200.50 posted; a card payment -85.25 and a refund 40.00 pending) produce:
ledger: $1,299.50 (posted only)
holds: -$85.25 (pending money out; pending money in is not counted)
available: $1,214.25
Three numbers, three different questions. A screen that shows one "balance" invites the wrong one to be read.
Showing the age
A balance computed a minute ago is still a true statement, but a tab left open for an hour is not. Each account card shows "as of" text derived from a server timestamp (as of 5 s ago, as of 2 min ago). A screenshot, a long-open tab or a returning user can then see how old the number is. The lab's asOfText never returns a negative age. The page also refreshes the figure when the tab becomes visible again, and the server's figure wins.
The session: warn, lock, wipe
What the server enforces and what the screen does
OWASP's cheat sheet is direct: all sessions should implement an idle timeout and an absolute timeout (regardless of activity), and timeout management and expiration must be enforced server-side, because client-side tracking can be manipulated to extend a session. It gives example ranges: idle timeouts of 2 to 5 minutes for high-value applications and 15 to 30 minutes for low-risk ones, and absolute timeouts of 4 to 8 hours for a full-day office application. Treat these as examples of how such limits are discussed, not as values to copy. NIST SP 800-63B (the 800-63-4 revision, dated 26 August 2025 on the page read for this lesson) gives a different kind of reference: for authenticator assurance level 2 an overall reauthentication timeout that should be no more than 24 hours and an inactivity timeout that should be no more than 1 hour, and for level 3 an overall timeout of no more than 12 hours and an inactivity timeout that should be no more than 15 minutes. Those figures are about US federal digital identity, and your own limits come from your own risk assessment.
So the server ends the session. The screen's job is to make the end understandable and to leave nothing behind: warn the user, let them extend, lock the view, wipe fetched values, and treat any 401 from any request as the end.
Accessible warnings
A timeout is a time limit. WCAG 2.2 success criterion 2.2.1 (Timing Adjustable, level A) says that for a time limit the user can turn it off, adjust it over a wide range, or be warned before it expires and given at least 20 seconds to extend it with a simple action, at least ten times, unless the limit is essential or part of a real-time event. The lab warns when a minute remains (an illustrative value above the 20-second floor) and offers "Stay signed in" in an alertdialog. The absolute limit is the one that cannot be extended: the lab's extend renews the idle limit and never moves the absolute one, and the warning says which limit is running out.
The rules in the lab
- Activity renews the idle timer only while the screen is quiet. Once the warning shows, a stray mouse move does not count; only the explicit "Stay signed in" does. Otherwise a forgotten tab with a jittering mouse would never expire on screen.
- Every event re-checks the clock first. An activity event that arrives after a long gap is judged by the gap, not accepted.
- The server's clock is learned. A server timestamp sets a skew between the device clock and the server's, so a wrong device clock does not give the user more or less time on screen than the server will.
- A locked session stays locked. Nothing but a new sign-in changes it.
Figure 3. Session phases
How to read this: the only way back from warning is an explicit extend. locked has no exit in this model: a new sign-in starts a new session.
Timers in a tab you cannot see
A timer is not a clock. MDN says a timeout may take longer to fire than expected, and that browsers throttle timers in background tabs; it describes Chrome checking timers in the most throttled state once per minute, and Firefox for Android having a minimum timeout of 15 minutes for inactive tabs. The Page Visibility API reports visibilitychange and a hidden state for tabs in the background, minimised windows or a screen that is off. A laptop that sleeps runs no timers at all.
Therefore the lock must not depend on a timer firing on time. The lab computes the state from timestamps on every event: when the lid opens and the first event arrives, the session is evaluated against the clock and locks at once. The server's 401 backs this up, because it does not depend on the tab at all.
Illustration 2: the failure case, a laptop wakes after two hours
The demo run with the illustrative policy (idle 300 s, absolute 1,800 s, warning in the last 60 s):
a laptop wakes after 2 hours, no tick ran in between:
t= 10 s activity phase=active left=300 s (idle)
t=7200 s activity phase=locked because=idle
No tick ran between the two lines, which is what a sleeping machine looks like to the page. The first event after waking is judged by the clock and locks the view before anything is shown.
Asking again before risky actions: step-up
Viewing a balance and moving money are different risks. Step-up authentication raises the proof required for an action: NIST's document describes step-up as a way to raise a session's assurance level when a higher level is required. Enterprise SSO, Audit and Compliance in the UI shows the protocol side (prompt=login, max_age, auth_time). This case study shows the policy side in the screen.
Illustration 3: the realistic example, which actions need a fresh sign-in
The lab's decide(action, authAgeMs, policy) returns allowed or step-up-required. In the illustrative policy, viewing a balance needs nothing; revealing an account number or adding a payee needs a sign-in no older than 300 seconds; a transfer needs it only at or above a threshold amount. From the demo:
action signed in 60 s ago signed in 3600 s ago
view balance allowed allowed
reveal account number allowed step-up required
add payee allowed step-up required
transfer $120.00 allowed allowed
transfer $900.00 allowed step-up required
The screen asks first so the user is not surprised by a failure, but the server makes the same decision on every request: the screen's copy of the policy is a courtesy and can be wrong or bypassed.
Approve what you saw
A fresh sign-in proves who is acting. It does not prove what they are agreeing to. OWASP's Transaction Authorization Cheat Sheet states a "What You See Is What You Sign" principle: the authorisation method must let the user identify and acknowledge the data they are approving. It also says that all significant transaction data must be verified by the user and generated and stored on a server, that authorisation should be performed and enforced server-side, that each transaction should be authorised with unique credentials, and that a credential should be accepted once, by atomically checking that it is unused and marking it used.
The lab models those rules with a canonical text built from the transfer (amount, currency, source account, payee). The screen shows that text, the user approves it, and the request carries it. The server's ApprovalLedger.consume accepts the approval only if the text equals the canonical form of the transfer actually being executed and only once. The demo:
approved text: transfer 90000 minor USD from acct-1 to payee-7
execute as approved: true
replay the same approval: false
new approval, changed payee: false
new approval, changed amount: false
Figure 4. A transfer with step-up and a bound approval
How to read this: the step-up and the approval are two separate checks. The first is about who, the second is about what. The server repeats both; the screen only makes them visible.
CSRF and Clickjacking Defenses covers why the request itself must also be protected from being triggered by another site, and RBAC and ABAC on the UI covers hiding actions a user may not take (a convenience; the server refuses regardless).
Build it: the session, step-up and reveal core
Goal. Run the dashboard's rules as tests and as a printed trace: exact money, balance reconciliation, the session timer with warning and lock, the step-up decision, the bound approval and the revealed-value lifecycle.
Setup. The lab is banking-dashboard-session in the course's example workspace (Node 26.13.1, pnpm). The rules are pure TypeScript with an injected clock; one React component (Dashboard.tsx) is a thin layer over them and is tested in jsdom, a model of the DOM and not a browser. There is no network and no identity provider.
cd examples/frontend
pnpm install
cd labs/banking-dashboard-session
pnpm test # 30 tests
node src/demo.ts
Steps.
- Run the tests. In
test/dashboard.test.tsx, read "locks when idle, removes every account and the revealed number from the page". - Run the demo and compare it with the output below.
- In section 2, find "a stray mouse move during the warning does not count, Stay signed in does". The
activityline leaves the phase atwarning; theextendline returns it toactivewith 300 seconds left. - In section 2, follow "activity cannot move the absolute limit": the
leftvalue switches from(idle)to(absolute)and the session locks withbecause=absolute. - Optional: change
sessionReducersoactivityalways renews, watch two tests fail, then restore it.
Expected output, captured from a real run (Node 26.13.1, 2026-12-01):
Banking dashboard: numbers, session, step-up, reveal
=== 1. Numbers: minor units, balances and a reconciliation
ledger: $1,299.50 (posted only)
holds: -$85.25 (pending money out; pending money in is not counted)
available: $1,214.25
server ledger $1,299.50 against list: {"ok":true}
server ledger $1,300.50 against list: {"ok":false,"serverLedger":"130050","listLedger":"129950","difference":"100"}
JSON.stringify of a BigInt: TypeError
=== 2. Session: idle 300 s, absolute 1800 s, warning in the last 60 s (illustrative)
a user who keeps working, then stops:
t= 100 s activity phase=active left=300 s (idle)
t= 200 s activity phase=active left=300 s (idle)
t= 400 s tick phase=active left=100 s (idle)
t= 450 s tick phase=warning left=50 s (idle)
t= 500 s tick phase=locked because=idle
a stray mouse move during the warning does not count, Stay signed in does:
t= 100 s activity phase=active left=300 s (idle)
t= 345 s tick phase=warning left=55 s (idle)
t= 350 s activity phase=warning left=50 s (idle)
t= 355 s extend phase=active left=300 s (idle)
activity cannot move the absolute limit:
t= 200 s activity phase=active left=300 s (idle)
t= 400 s activity phase=active left=300 s (idle)
t= 600 s activity phase=active left=300 s (idle)
t= 800 s activity phase=active left=300 s (idle)
t=1000 s activity phase=active left=300 s (idle)
t=1200 s activity phase=active left=300 s (idle)
t=1400 s activity phase=active left=300 s (idle)
t=1600 s activity phase=active left=200 s (absolute)
t=1745 s activity phase=warning left=55 s (absolute)
t=1800 s tick phase=locked because=absolute
a laptop wakes after 2 hours, no tick ran in between:
t= 10 s activity phase=active left=300 s (idle)
t=7200 s activity phase=locked because=idle
the server says 401 while the screen thinks all is well:
t= 10 s activity phase=active left=300 s (idle)
t= 20 s server401 phase=locked because=server
the device clock is 5 s behind the server:
t= 0 s serverTime phase=active left=295 s (idle)
t= 290 s tick phase=warning left=5 s (idle)
=== 3. Step-up: what needs a recent sign-in (fresh = 300 s, transfer threshold $500.00; illustrative)
action signed in 60 s ago signed in 3600 s ago
view balance allowed allowed
reveal account number allowed step-up required
add payee allowed step-up required
transfer $120.00 allowed allowed
transfer $900.00 allowed step-up required
=== 4. One approval, one transfer, once
approved text: transfer 90000 minor USD from acct-1 to payee-7
execute as approved: true
replay the same approval: false
new approval, changed payee: false
new approval, changed amount: false
=== 5. Revealed values expire and are wiped on lock
start {}
revealed at t=0 (30 s) {"acct-1":"000123456789"}
tick at t=29 s {"acct-1":"000123456789"}
tick at t=30 s {}
after lock {}
What the lab does not show: a real browser, real background-tab throttling, a real identity provider, a real ledger, or any bank's rules.
Trade-offs
| Decision | Gain | Cost |
|---|---|---|
| Short idle timeout | Less time for a forgotten screen to be misused | More sign-ins and lost context; warnings must be accessible |
| Warn and allow extend | Meets the timing rules; fewer lost forms | A warning dialog to build, test and announce |
| Mask and reveal on demand | Less data in the page | An extra step and a server call for each reveal |
no-store on sensitive responses |
No stored copies in any cache | Back-navigation and offline use cost a refetch |
| Step-up for risky actions | Fresh proof when it matters | Redirects; the provider must report authentication age |
| Bound, single-use approval | What is approved is what runs | Server must keep approval state |
| Take balances only from the server | One number of record | A visible mismatch when the list is incomplete |
In practice: the balance that was an hour old
This is a realistic scenario, not a case history. It is a composite built from common production patterns. It describes no specific company or product, and every number in it is an illustrative assumption.
The situation
A dashboard shows balances and lets customers make transfers. A reviewer finds three things in a walkthrough: a tab left open overnight still shows balances; a full account number is present in the page's data even when masked; and the "transfer" action asks for a password only at sign-in. Support also reports customers disputing a "balance" that differed from a statement.
Starting architecture
Figure 5. Before: long-lived screen, full data in the page, no step-up
How to read this: the warning boxes are the gaps. The page holds more than it shows, the session has no short idle limit, and a transfer needs no fresh proof.
Options considered
| Option | What it fixes | What it costs | Risk |
|---|---|---|---|
| Hide the numbers with CSS | Looks masked | Nothing | The full value is still in the page and the data |
| Client-side timer that clears the screen | Looks signed out | A timer | The server session is still valid; the timer can be paused or throttled |
| Server idle and absolute limits, a screen guard, masked data, step-up and a bound approval | The actual gaps | Server work and more states | More screens to test and make accessible |
The decision
| Field | Decision record |
|---|---|
| Context | Sensitive data and risky actions on a device the bank does not control. |
| Decision | Server-enforced idle and absolute limits; the screen warns, locks and wipes and treats any 401 as the end; account data carries only masked numbers, with full values fetched on request, shown for a short time and wiped on lock; balances come from the server with an "as of" time and reconcile against the list; transfers above a threshold need a recent sign-in and a single-use approval bound to the shown transfer; sensitive responses use no-store; sign-out invalidates the session on the server. |
| Consequences, good | Less data exposed; an unattended tab ends; approvals cannot be replayed or altered. |
| Consequences, bad | More sign-ins and redirects; approval state to store; more accessible dialogs. |
| Revisit when | Risk analysis or regulation changes the limits, or the provider cannot report authentication age. |
Rollout and verification
- Test the schedules: idle then lock, warning then extend, absolute limit during activity, a wake after a long gap, a
401while the screen is active, a clock that is wrong by seconds. - Inspect what the page holds: search the rendered text and the data the page received for a full account number before and after a reveal and after a lock.
- Check headers on the account responses and the sign-out response.
- Verify accessibility of the warning with a keyboard and a screen reader (manual and in CI).
- Review audit events for a sample transfer: the step-up, the approval and the execution, and no personal data beyond what policy allows.
The 2 a.m. failure
Customers report being signed out while still active, in bursts. The server's idle limit is correct, but a new front-end release stopped sending the "keep alive" call that the activity handler used to make, so the server saw no activity while the user worked in a single long form. The screen's guard still counted activity and showed no warning.
First three checks: (1) compare the server's last-activity time with the screen's for an affected session; (2) check whether the form's interactions produce any server calls; (3) look at the release diff for the removed call. Mitigation: restore the call, or extend the session as part of saving drafts. Follow-up: the guard's "extend" should call the server so both sides agree, and a test should assert that long form work does not trigger a server timeout. The server's decision is the only one that counts, so the screen's timer should be a mirror of it, not a second clock.
The other side of this topic
The back end owns the authority: the OAuth and OpenID Connect flow (OAuth 2.0 and OpenID Connect), the audit trail (Audit Logging), privacy duties (Compliance and Privacy (GDPR)) and the ledger behind every number. The front end limits what it holds, says what it shows, and reacts correctly when the server ends a session.
Architect's notes
- Make limits parameters. Idle, absolute, warning and step-up values differ by product and are changed after reviews, so keep them out of components.
- Compute state from timestamps, not from timers. Timers are for repainting; the clock decides.
- Keep the screen a mirror. The server decides; the screen shows the decision early enough to be kind.
- Test the wipe. "The value is not in the page after lock" is a testable property.
- Do not turn UX conveniences into security claims. A hide-balances switch and a hidden button help the user and protect nothing on their own.
Common mistakes
- Masking with CSS while the full value is in the DOM or the data.
- A client-only session timer with no matching server limit.
- Relying on a timer in a background tab to lock the screen.
- Computing a balance in the browser and displaying it as the balance.
- Letting any activity renew a session that is already warning, or letting activity move the absolute limit.
- Caching sensitive responses, or leaving values in storage, caches or logs after sign-out.
- A fresh sign-in with no bound approval, so what runs can differ from what was shown.
Key takeaways
- The server enforces the session and the transaction; the screen warns, locks, wipes and reacts.
- Mask by default, fetch on request, show briefly, remove on lock.
- Hold money as exact integers, send it as strings, show the server's figure with its age.
- Compute the session state from timestamps; background timers are not reliable.
- Warn with an accessible way to extend; the absolute limit cannot be extended.
- Step up for risky actions and bind an approval to the single transfer shown.
- This lesson is engineering education: real limits come from a real risk assessment.
Practice exercises
Exercise 1: Starter (30 min). Add a test where extend is sent after the absolute limit has passed, and state the result. Add a test for a skew that is negative.
Exercise 2: Intermediate (2 hours). Add a "hide balances" switch to the dashboard that masks the amounts with a placeholder. Write down what threat it does and does not address.
Exercise 3: Advanced (half day). Make a lock in one tab lock the other tabs of the same browser (see Cross-Tab Sync With BroadcastChannel) and clear their revealed values. List the cases where tabs disagree and how the server's 401 resolves them.
Related reading
In this course:
- Enterprise SSO, Audit and Compliance in the UI: sign-in per tenant, step-up with
max_age, and audit. - JWTs, Single Sign-On and the Session Lifecycle: the clocks behind a session.
- Authentication vs Authorization in the UI and RBAC and ABAC on the UI: who you are and what you may do.
- Content Security Policy: limiting what a page can run.
- Accessibility Fundamentals and WCAG: the rules behind accessible warnings.
Official documentation
- OWASP: Session Management Cheat Sheet: idle and absolute timeouts, server-side enforcement, logout, caching.
- OWASP: Transaction Authorization Cheat Sheet: What You See Is What You Sign, single-use authorisation.
- NIST SP 800-63B: authentication assurance levels and reauthentication timing.
- W3C: Understanding SC 2.2.1 Timing Adjustable: warning and extending time limits.
- MDN: Cache-Control and MDN: Clear-Site-Data: keeping responses and data off the device.
- MDN: Page Visibility API and MDN: setTimeout: hidden tabs and late timers.
- MDN: BigInt: exact integers and their limits with JSON.
- OWASP: Logging Cheat Sheet: data to keep out of logs.