Skip to content

Reuse recovery config helper and document needsRecovery - #352

Merged
joalavedra merged 1 commit into
mainfrom
chore/recovery-owner-cleanups
Sep 17, 2026
Merged

joalavedra merged 1 commit into
mainfrom
chore/recovery-owner-cleanups

Conversation

@joalavedra

Copy link
Copy Markdown
Collaborator

Four small cleanups around the single-owner embedded recovery that shipped in #347, #349 and #350. Comments, docs and reuse only — no behaviour change.

1. Reuse buildClientRecoveryConfig

actions/buildClientRecoveryConfig.ts returns { walletConfig, getAccessToken, getUserId } bound to a client. That same object literal was inlined verbatim in three places; each now calls the helper instead:

  • openfort/hooks/useAutoRecovery.ts
  • hooks/openfort/auth/useConnectToWalletPostAuth.ts (the create path and the recover path)

2. Rewrite the comment on the embeddedState !== READY guard

useConnectToWalletPostAuth skips recovery when the embedded state is not READY. The comment now states why the guard holds, describing only the code as it stands: embeddedState is captured at render through the useCallback deps, so on a fresh login the guard stores the intended address and lets the provider's auto-recovery effect recover it. A failure there surfaces as recoveryError, which the CreateWallet and Recover pages read to offer a new wallet on a new device, whereas a failure inside tryUseWallet reaches its own catch and signs the user out. It also keeps the login promise from blocking on a passkey ceremony or an encryption-session fetch; the modal shows progress instead.

3. Correct the singleRecoveryPerLogin docblock

It said recovery is requested from two places on a single login. There are three: the provider's auto-recovery effect, the modal's recover page through setActive, and the post-authentication connect path (useConnectToWalletPostAuth). No test code changes.

4. Document needsRecovery

SetActiveEmbeddedWalletSuccess.needsRecovery now has JSDoc: true when activating the wallet needs a credential the caller has to collect first (a password), false once the signer holds the wallet. A wallet the signer already holds reports false without any credential being collected or validated, so setActive is not a way to verify a user's password. Wording agrees with openfort-xyz/documentation#493.

No changeset

This PR adds no behaviour. What items 2–4 describe already ships in the pending .changeset/single-owner-embedded-recovery.md for 2.1.3.

Checks

pnpm check, pnpm check:types and pnpm test:unit (890 passing, unchanged) all pass.

🤖 Generated with Claude Code

Comment, docs and reuse cleanups around the single-owner embedded
recovery; no behaviour change.

- Replace the three inlined copies of the buildRecoveryParams config
  (useAutoRecovery and both call sites in useConnectToWalletPostAuth)
  with buildClientRecoveryConfig, which returns the same object.
- Rewrite the comment on the embeddedState !== READY guard in
  useConnectToWalletPostAuth to state why the guard holds: the state is
  captured at render, a failed auto-recovery surfaces as recoveryError
  instead of signing the user out, and the login promise does not block
  on a passkey ceremony or an encryption-session fetch.
- Correct the singleRecoveryPerLogin docblock: recovery is requested
  from three places, the post-authentication connect path being the
  third.
- Add JSDoc to SetActiveEmbeddedWalletSuccess.needsRecovery, matching
  the note in openfort-xyz/documentation#493.

No changeset: the behaviour these describe ships in the pending
single-owner-embedded-recovery changeset for 2.1.3.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Sep 17, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated
playground Building Building Preview Sep 17, 2026 11:56am UTC

Request Review

@pkg-pr-new

pkg-pr-new Bot commented Sep 17, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@openfort/react@352

commit: 0b4ea88

@joalavedra
joalavedra merged commit 72a4ec6 into main Sep 17, 2026
18 of 19 checks passed
@joalavedra
joalavedra deleted the chore/recovery-owner-cleanups branch September 17, 2026 12:15

This branch was successfully deployed

1 active deployment
Preview — 0b4ea88b Deployed Sep 17, 2026 by vercel[bot]
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.

1 participant