From c31313804ae434a1af65d3b05ac224b661d26a7a Mon Sep 17 00:00:00 2001 From: Ahmet Abdullah Gultekin Date: Wed, 3 Jun 2026 13:31:49 +0000 Subject: [PATCH 1/4] =?UTF-8?q?fix(mobile):=20pre-demo=20fixes=20=E2=80=94?= =?UTF-8?q?=20QR/approve=20swallowed-401,=20session=20expiry,=20NFC,=20hid?= =?UTF-8?q?e=20Add-card?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Four additive, reversible pre-demo fixes (demo 2026-06-03). Verified each against origin/main before changing. #1 + approve-login silent-approve swallow - QrLoginApiImpl.approveSession and ApproveLoginApiImpl.decide POSTed without reading the response, so a non-2xx (e.g. expired bearer → 401/403) was swallowed: the phone flipped to APPROVED while the server session stayed PENDING and the originating (web) login never advanced. Both now throw a ResponseException on a non-success status (status code included in the message so ErrorMapper maps it). The 401 path now also triggers the transparent refresh+retry below, so a stale-but-refreshable bearer recovers automatically. #2 session ~15-min logout - NetworkModule: the refresh-on-401 HttpResponseValidator could not re-fire the failed request (its own TODO) → first call after the 15-min access-token lifetime surfaced as a logout. Replaced it with an HttpSend interceptor (part of ktor-client-core — no new dependency; the project deliberately avoids ktor-client-auth, see desktopApp RefreshInterceptor) that refreshes under the existing rotation mutex AND retries the original request once with the fresh bearer. Refresh logic extracted to a reusable refreshAccessToken() helper. - TokenManager.isAuthenticated() checked token PRESENCE only; now tolerates an expired access token when a refresh token exists (decodes the JWT exp claim via base64url + kotlinx.serialization; fail-open for non-JWT tokens), so a returning user is not bounced to login when a silent refresh is possible. #7 NFC won't read (OS detects card, app stays "ready to scan") - Removed the foreground TECH_DISCOVERED intent-filter + nfc_tech_filter meta-data from AndroidManifest so reader mode (enableReaderMode) wins instead of competing with the system tag-dispatcher. - Relaxed AndroidNfcService.processTag: previously dropped a tap unless state was exactly WaitingForCard; now only rejects a tap while a read is already in flight (Reading), so an Idle/Completed/Error tap starts a fresh read. - NOTE: NOT verifiable without a physical device — needs on-device `adb logcat` confirmation before being trusted. Fully reversible. #8 "Add card" dead-end button - Hidden the DashboardScreen "Add card" QuickAction: CardScanScreen is a camera photo wizard that never uploads/persists anything. Screen + nav route left intact (reversible — uncomment to restore once OCR/upload backend exists). Tests: +10 (QrApproveLoginStatusCheckTest 6, TokenManagerAuthExpiryTest 4). Compile: :shared:compileDebugKotlinAndroid + :androidApp:compileDebugKotlin + processDebugMainManifest all green. Full shared unit suite: 489 tests, 0 failures. Co-Authored-By: Claude Opus 4.8 (1M context) --- androidApp/src/main/AndroidManifest.xml | 24 +- .../android/data/nfc/AndroidNfcService.kt | 12 +- .../android/ui/screen/DashboardScreen.kt | 23 +- .../shared/data/local/TokenManager.kt | 60 ++++- .../data/remote/api/ApproveLoginApiImpl.kt | 17 +- .../shared/data/remote/api/QrLoginApiImpl.kt | 22 +- .../com/fivucsas/shared/di/NetworkModule.kt | 211 ++++++++++-------- .../data/local/TokenManagerAuthExpiryTest.kt | 103 +++++++++ .../api/QrApproveLoginStatusCheckTest.kt | 108 +++++++++ 9 files changed, 471 insertions(+), 109 deletions(-) create mode 100644 shared/src/commonTest/kotlin/com/fivucsas/shared/data/local/TokenManagerAuthExpiryTest.kt create mode 100644 shared/src/commonTest/kotlin/com/fivucsas/shared/data/remote/api/QrApproveLoginStatusCheckTest.kt diff --git a/androidApp/src/main/AndroidManifest.xml b/androidApp/src/main/AndroidManifest.xml index 1f34c696..ddb5bc1b 100644 --- a/androidApp/src/main/AndroidManifest.xml +++ b/androidApp/src/main/AndroidManifest.xml @@ -47,12 +47,24 @@ - - - - +