fix(transaction): purge persisted signed intents when wallet identity changes (#964) - #970
Merged
greatest0fallt1me merged 1 commit intoSep 29, 2026
Conversation
…dictify-org#964) - Validate stored intent records with a zod schema and drop malformed entries - Prune expired intents on read and persist the cleanup - Add clearIntentsForWallet and call it on disconnect, identity switch, and reconciliation mismatch - Drop signedXdr once a submissionHash exists
|
@AKAEMM668 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
|
@AKAEMM668 is attempting to deploy a commit to the Jagadeesh B's projects Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Signed transaction intents were persisted to
localStorage(predictify:intents:v1) for up to 24 hours with no shape validation, and the wallet lifecycle never removed them. A fully signed envelope could therefore linger on a shared device or remain reachable by any script on the origin after the wallet was disconnected or switched, and malformed/tampered records could crashuseTransaction's resume path.This PR hardens the intent store (zod validation + eager pruning), drops the signed envelope as soon as a submission hash exists, and purges intents when the wallet identity changes.
Related Issue
Closes #964
Changes
Intent store hardening —
lib/transaction/intent.tsintentRecordSchema(zod) validating every field;statusis constrained to theIntentStatusenum andwalletAddress/key/xdrHashmust be strings.safeGetStoragenow runs every parsed record throughsanitizeStore, discarding malformed or wrongly typed entries and pruning anything older than the 24h TTL, then persists the cleaned map on the first read.upsertIntentrefuses to persist an invalid merged record and never carriessignedXdrforward oncesubmissionHashis set.clearIntentsForWallet(address)removes only the records belonging to the given address.Wallet identity lifecycle —
context/WalletContext.tsxupdateIdentitypurges the previous address's intents whenever the identity actually changes (covers account switch).disconnectWalletpurges the disconnected address only aftergetKit().disconnect()succeeds.Tests
lib/transaction/__tests__/intent.test.ts— validation drops, TTL pruning on first read,signedXdrremoval, and per-wallet clearing.context/__tests__/WalletContext.test.tsx— intents purged on disconnect, on identity switch, and on reconciliation mismatch.Security & failure modes
signedXdr) is only retained for the short window between signing and submission; it is removed the momentsubmissionHashis set and stripped from legacy records on read.useTransactionresume path can no longer read unchecked fields.getKit().disconnect()throws) leaves the identity and its intents intact, preserving the ability to recover the session.debug, so a brokenlocalStoragecannot break the wallet UI.Verification Results
pnpm exec eslintis clean on all four changed files andtscreports no errors in them.Acceptance Criteria
clearIntentsForWalletcalled on successful disconnect; covered inWalletContext.test.tsxstatusorwalletAddressare discarded on readsanitizeStore; covered inintent.test.tssignedXdris removed oncesubmissionHashis setupsertIntentand stripped on read; covered inintent.test.tssafeGetStorageprunes and persists; covered inintent.test.tslib/transaction/__tests__/intent.test.tsandcontext/__tests__/WalletContext.test.tsxcover these behaviours