Repository navigation
fix: harden JWT exp, 58mm print, and printer IPs - #1521
Conversation
Compute JWT exp from wall-clock Date.now() across all 7 token issuers while preserving monotonic sub-second iat for revocation ordering, apply bounded flex-wrap item rows to all 58mm browser receipt text sizes (normal, large, extra_large), and canonicalize shorthand/non-canonical IPv4 printer hosts via WHATWG URL parsing in validateNetworkPrinterTarget. Fixes #1512
…tion doc and table diff
|
ⓘ Your Qodo trial ends soon. Ask your workspace admin to set up billing to keep reviews running after the trial. Manage billing |
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
PR Summary by QodoFix JWT expiry, 58mm receipt overflow, and IPv4 printer validation
AI Description
Diagram
High-Level Assessment
Files changed (10)
|
Code Review by Qodo
1. Receipt rendering checks can be skipped
|
Fixes #1512
Intent
Verify and fix the three findings from the post-6949d359 release audit on main with regression tests and final verification for next-release readiness:
main/routes/auth.ts:301and token issuers usingnextTokenIatSeconds()): After a clock correction, the logical monotoniciatfromnextTokenIatSeconds()can remain ahead of wall-clock time, and passingexpiresIntojwt.signcomputesexprelative to that futureiatinstead of actual wall-clock time (Date.now()). A 48-hour clock correction produced a fresh "24-hour" session lasting 72 hours and still authenticating after 25 hours. Calculate expiry from actual wall-clock time across the token issuers while preservingtokens_valid_afterrevocation ordering.frontend/src/lib/printer/web-print.ts:613): IngetPaperStyles('thermal58', textSize), the bounded flex/wrapping layout rules apply only toextra_large. With the real HTML generator, "Breakfast", quantity 2, at ₹125 fitted at baseline, but the candidate's 219px container overflowed to 230px atnormalsize and 260px atlargesize, risking clipping or unwanted print scaling. Apply a bounded layout to every 58mm text size preset (normal,large, andextra_large) while preserving complete financial values, and test each preset.main/printers/thermal.ts:5063):validateNetworkPrinterTargetaccepts shorthand/non-canonical numeric IPv4 aliases such as127.1(for whichnet.isIPreturns0) that OS resolvers map to blocked local/loopback endpoints. HardenvalidateNetworkPrinterTargetso shorthand or non-canonical numeric IPv4 aliases cannot bypass local-port, loopback, unspecified/broadcast, or metadata target checks.What Changed
expclaims explicitly from wall-clockDate.now()across API (main/routes/auth.ts), KDS (main/kds-server.ts), and Server App (main/server-app.ts) token issuers while retaining monotonicnextTokenIatSeconds()iatvalues for revocation ordering.thermal58receipt text size presets (normal,large, andextra_large) ingetPaperStyles(frontend/src/lib/printer/web-print.ts) so 58mm HTML receipts do not overflow horizontally.validateNetworkPrinterTarget(main/printers/thermal.ts) so shorthand, octal, hexadecimal, and integer IPv4 forms cannot bypass loopback, local-port, broadcast/unspecified, or cloud metadata target checks.Risk Assessment
✅ Low: The changes are minimal, targeted fixes for wall-clock JWT expiry across all seven issuers, unconditional 58mm receipt row wrapping across all text sizes, and non-canonical IPv4 alias normalization in network printer target validation, with comprehensive behavioral regression tests and updated architecture documentation.
Testing
Exercised the JWT lifecycle suite across the Main API, Server App, and KDS HTTP servers, the printer API and dispatch target-validation suite, and the Chromium browser receipt suite with visual screenshots of the 58mm 'Breakfast' x2 at ₹125 receipt across normal, large, and extra_large text sizes; all scenarios passed with zero overflow and full enforcement of wall-clock session expiry and shorthand IPv4 printer target blocking.
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
✅ **Review** - passed
✅ No issues found.
✅ **Test** - passed
✅ No issues found.
npx tsx tests/jwt-logout-lifecycle.test.tsREQUIRE_VISUAL_EVIDENCE=1 EVIDENCE_DIR=~/.no-mistakes/evidence/01M6YD4PJNQGYATRN5T8E6XW6F npx tsx tests/browser-receipts.test.tsnpx tsx tests/printer-api.test.tsPlaywright Chromium rendering and screenshot capture of 58mm 'Breakfast' x2 at ₹125 receipts acrossnormal,large, andextra_largepresets✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.