Repository navigation
feat(wallet): session-scoped read/sign/submit permissions (#1194) - #1306
Open
robertocarlous wants to merge 1 commit into
Open
robertocarlous wants to merge 1 commit into
robertocarlous wants to merge 1 commit into
Conversation
…code#1194) Adds per-session wallet permissions that users can revoke from settings and that are enforced at every wallet choke point: - read: account/chain data fetches (connect + Freighter background refresh) - sign: all adapter signTransaction / signAuthEntry calls - submit: writes routed through useWriteGuard Permissions live in sessionStorage and the in-memory session slice, reset on disconnect/revoke, and fail closed on corrupt storage. Signing is blocked before any network/XDR work so a revoked session never reaches the wallet. Includes the settings control, hook, tests (happy/boundary/failure), and docs/security/wallet-session-permissions.md.
|
@robertocarlous is attempting to deploy a commit to the nanle-code's projects Team on Vercel. A member of the Team first needs to authorize it. |
This branch has not been deployed
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.
Closes #1194
What
Adds session-scoped read / sign / submit permissions for a connected wallet. A fresh session grants all three (preserving existing behaviour); the user can revoke any of them from Wallet → Session permissions for the rest of the browser session. Revocations are enforced end to end and reset when the session ends.
Behaviour
read— gates account/chain data fetching (wallet connect and the Freighter background account refresh).sign— enforced centrally increateAdapter(src/lib/wallet/adapters.ts), before any network or XDR work, so a revoked session never reaches the wallet. CoverssignTransactionandsignAuthEntry.submit— enforced inuseWriteGuard().guard(...), which now exposes apermissionDeniedresult instead of callingonConfirm.Permissions are stored in
sessionStorage(stellar-dash:wallet-session-permissions) and the in-memory session slice. They are deliberately not inPERSIST_KEYS, are cleared ondisconnectWallet()/revokeWalletSession(), and fail closed on corrupt storage (read kept, sign/submit denied).Files
src/lib/wallet/sessionPermissions.ts(new) — framework-free validation, persistence and enforcement core.src/lib/store.ts—walletSessionPermissions+ grant/revoke actions; reset/clear on disconnect and revoke; installs the checker.src/lib/wallet/adapters.ts— signing gate.src/lib/wallet/sessionListeners.ts— read gate for background refresh.src/hooks/useWriteGuard.ts— submit gate.src/hooks/useWalletPermissions.ts(new),src/components/settings/WalletSessionPermissions.tsx(new) — UI/hook surface.src/components/dashboard/WalletConnect.tsx— mounts the settings control.docs/security/wallet-session-permissions.md(new),SECURITY.md.Tests (happy path / boundary / failure)
src/lib/wallet/__tests__/sessionPermissions.test.ts— normalization, persistence round-trip, corrupt-JSON/shape/blocked-storage fallbacks, flag coercion boundary, throwing checker.src/lib/wallet/__tests__/sessionPermissions.store.test.ts— grant/revoke wiring and disconnect/revoke reset + storage clear.src/lib/wallet/__tests__/sessionPermissions.enforcement.test.ts— adapter signing gate forsignTransactionandsignAuthEntry, plus the granted control case.Verification (all pass):
Security, privacy, accessibility, network safety
sessionStorage.role="switch"toggles,aria-checked, reduced-motion and high-contrast support.Notes
src/components/dashboard/AuditLog.tsxhas type errors andsrc/lib/wallet/__tests__/adapters.test.tsfails onmaster(invalid test public key / unbuilt@stellar-dev-dashboard/corein this checkout); neither is related to or affected by this change.