Skip to content

Add secure GoodWidget integration boundary - #54

Open
L03TJ3 with Copilot wants to merge 12 commits into
mainfrom
copilot/prepare-goodwallet-for-goodwidget-integration
Open

Add secure GoodWidget integration boundary#54
L03TJ3 with Copilot wants to merge 12 commits into
mainfrom
copilot/prepare-goodwallet-for-goodwidget-integration

Conversation

Copilot AI commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Prepares GoodWallet to host reviewed GoodWidgets through authenticated bottom-sheet routes while keeping wallet authority behind a restricted runtime provider boundary.

  • Registry and routing

    • Added typed registry validation for exact versions, IDs/routes, chains, methods, and integration mode.
    • Added registered-widget-only bottom-sheet route resolution.
  • Secure provider boundary

    • Exposes a restricted EIP-1193 facade only.
    • Enforces per-widget methods, chains, active account, typed-data chain, and transaction chain.
    • Defaults signing and transactions to denied without Wallet-owned approval.
await provider.request({
  method: "personal_sign",
  params: [message, activeAccount],
})
  • Widget hosts

    • Added lazy client-side Web Component and React hosts.
    • Web Components receive provider, themeOverrides, and config as object properties and clear them on unmount.
    • Web Components remain the default; React requires explicit registry selection.
  • Dashboard

    • Integrated registry-driven widget actions without changing the six core action order or More-drawer behavior.
    • Added reusable local/system icon support.
  • Coverage

    • Added focused registry, provider-policy, host cleanup, and React resolution tests.
    • Added desktop and mobile dashboard layout assertions.

@vercel

vercel Bot commented Jul 29, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
good-wallet-v2 Ready Ready Preview Jul 31, 2026 3:48pm

Request Review

Copilot AI changed the title [WIP] Prepare GoodWallet for GoodWidget integration Add secure GoodWidget integration boundary Jul 29, 2026
Copilot AI requested a review from L03TJ3 July 29, 2026 13:35
@blueogin
blueogin marked this pull request as ready for review July 29, 2026 21:11
- Added validation for reserved widget routes and empty chain IDs in the widget registry.
- Implemented duplicate Custom Element tag checks during widget registration.
- Updated the AuthenticatedWidgetRoute and WidgetRenderer components to include widgetId as a key for better rendering.
- Enhanced the RestrictedEip1193Provider to support transaction preparation and improved error handling for signing requests.
- Introduced tests for new validation rules and widget registration logic.
@blueogin

Copy link
Copy Markdown

@copilot
review this pr

- Removed outdated comments from various files to enhance code clarity.
- Updated the widget registration logic to streamline the integration of React and web component entries.
- Adjusted tests to reflect changes in widget registration and validation processes.
- Added unit tests for session storage functionality to ensure proper handling of legacy sessions and private-key sessions.
- Refactored session management logic to clear persisted sessions and improve state handling.
- Updated session context to include masterSeed for better session management in the UI.
…dation

- Introduced reset functionality for wallet connect dialogs to ensure proper state management during user interactions.
- Updated widget registration logic to include metadata validation for package name and version, improving integration reliability.
- Enhanced tests for wallet connect dialogs and widget registration to cover new validation scenarios and reset behavior.
- Modified the login test to check for wallet actions visibility using test ID instead of text.
- Enhanced the claim verification test by clicking the GoodDollar link instead of directly navigating, ensuring better interaction simulation.
- Updated screenshots for various onboarding flows to reflect recent UI changes.
- Enhanced the claim verification test by replacing direct URL navigation with a wait for URL method, improving test stability.
- Increased timeout for visibility checks to ensure elements are properly rendered before assertions.
- Updated the home balances overflow screenshot to reflect recent UI changes.
blueogin
blueogin previously approved these changes Jul 30, 2026
@L03TJ3

L03TJ3 commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

@blueogin
Can you confirm first because I think some review points were specifically introduced by you.
So maybe it made sense to have. Why for example are we replacing session state?
that means if I have a logged in regular wallet I also have to sign in?

delegate to copilot or fix yourself whatever still needs to be done:


Please simplify and tighten this PR before it is merged.

1. Revert the session-persistence changes from this PR

Restore the existing session behavior in:

  • src/login/context/SessionContext/storage.ts
  • src/login/context/SessionContext/storage.test.ts
  • src/login/hooks/context.ts
  • src/sections/Options/OptionsView.tsx

PR #54 currently deletes SIGNER_SESSION during module initialization and stops restoring or persisting sessions (storage.ts:6-14,38-48). This is a breaking login/session change that is outside the scope of the widget integration work.

If persisted seeds are considered unsafe when widgets run on the wallet origin, handle that as a separate security task with an explicit product decision, migration plan, and user-facing acceptance criteria. Do not silently change session persistence as part of PR #54.

2. Remove unused backward-compatibility code

Simplify src/components/Form/RoundButton/RoundButton.tsx to the API used by its only caller:

  • Keep icon, iconElement, text, and indicator.
  • Remove RoundButtonType, buttonType, buttonIcons, fill, and the legacy fallback branches at RoundButton.tsx:7-47,62-74.

The only current caller is src/sections/Home/components/WalletSection.tsx:250-255, and it already uses the new API. There is no repository consumer requiring the old API.

Also remove unused widget API that exists only for anticipated compatibility, unless a real consumer is added:

  • DEFAULT_WIDGET_INTEGRATION_MODE and resolveWidgetIntegrationMode in src/widgets/registry.ts:10-13,59-62
  • Unused chainId, supportedMethods, and isRevoked getters in src/widgets/provider/RestrictedEip1193Provider.ts:159-169

3. Start with the minimum provider capability set

Reduce src/widgets/provider/policy.ts:14-61 and RestrictedEip1193Provider.ts to the methods and chains required by the first concrete widget or test fixture.

Keep the provider extensible so a later reviewed registry change can add a method or chain when an actual widget needs it. Do not pre-support 25 methods, 10 chains, and transaction variants without a demonstrated consumer.

Retain the security-critical behavior:

  • Global and per-widget method allowlists
  • Per-widget chain allowlists
  • Active-account and active-chain validation
  • Wallet-owned approval before signing or sending transactions
  • Provider revocation and Web Component property cleanup
  • No signer, seed, unrestricted provider, or session object in widget props

Avoid adding generalized transaction normalization, concurrency handling, or compatibility behavior until a concrete flow and test require it.

4. Prove the actual widget flow

src/widgets/registry.ts:147 currently leaves WIDGETS empty, while tests-playwright/wallet-flows.e2e.ts:70-110 tests only the original six wallet actions.

Add a minimal test-only widget fixture and desktop/mobile coverage that proves:

  1. A registered widget opens from the dashboard.
  2. It opens from the expanded More drawer on the constrained layout.
  3. It mounts inside the authenticated bottom sheet through [widgetRoute]/page.tsx.
  4. An unregistered widget route is rejected.

@blueogin

blueogin commented Jul 31, 2026

Copy link
Copy Markdown

@L03TJ3 Confirmed - that was intentional from my side.

I removed session persistence because widgets share origin and could read SIGNER_SESSION / masterSeed from localStorage, bypassing the restricted provider.

You’re right that this also forces normal wallets to sign in again after refresh. I’ll revert storage.ts and keep the existing session behavior.

- Removed unused properties and functions from the RoundButton component to simplify its API.
- Refactored session storage logic to improve handling of local storage and session retrieval.
- Updated session context to eliminate unnecessary state variables, enhancing clarity and performance.
- Introduced a test fixture widget for improved testing capabilities and validation of widget integration.
- Enhanced wallet flow tests to include the new test fixture, ensuring comprehensive coverage of widget interactions.
- Added dynamicParams flag to disable dynamic routing for widgets.
- Implemented generateStaticParams function to create static routes based on registered widgets.
- Updated wallet flow test to check for visibility of 404 error messages for unregistered widget routes.
- Updated home balances overflow screenshot to reflect recent UI changes.
@blueogin

Copy link
Copy Markdown

@L03TJ3 Done - addressed your points:

Restored session persistence
Removed unused RoundButton / widget helpers
Reduced provider allowlist to the minimum fixture set
Added a Playwright-only test fixture with desktop/mobile coverage for open / More / mount / unregistered rejection

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[PLAN] Prepare GoodWallet for GoodWidget integration

3 participants