Repository navigation
Conversation
🛑 Files requiring codeowner reviewTo merge this PR, you'll need to get approvals from the following owners. @MetaMask/web3auth (12 files)
ℹ️ Files co-owned by
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 76a3e7d. Configure here.
76a3e7d to
3556cd6
Compare
…with the v1 version The SDK defaults the item version to v2 and then requires a data type, so a repair without a data type failed. Pass the version explicitly. Co-authored-by: Cursor <cursoragent@cursor.com>
Should a healthy backup still be re-read on every unlock?Once a repair has landed — or for the large majority of users whose backup was never broken — Per unlock, for every seedless user:
To be clear, this is not a regression from this PR: the old telemetry path also called both on every healthy unlock. But the PR changes why we're paying it, which makes it worth asking now. Previously the only output was a telemetry event, and re-checking every unlock was the measurement — it's what counted the standing affected population. Now the output is a repair, and once that has succeeded the answer is stable. Suggestion: cache only the healthy result. When primarySrpBackupHealthyCache?: {
userId: string;
authConnectionId: string;
timestamp: number;
};and skip the whole run while it's fresh. The asymmetry is the point: a Things to decide if this seems worth doing:
If the per-unlock cost is considered acceptable, that's a fine answer — but it'd be good to have it written down as a deliberate choice, since it's now a cost paid indefinitely by every seedless user rather than a time-boxed measurement. |

Explanation
A social login user can unlock a wallet whose primary SRP exists only on that device. The remote backup then has no primary SRP, so restoring on another device cannot recover the wallet. Unlock already detects this and emits an analytics event. It does not write the missing item.
submitPasswordandidentifyIncompleteMetadataBackupnow runPrimarySrpBackupRepair. The class is held by the controller and is not a public export. One run fetches the remote backup once and exports the local primary SRP once, then uses that plan for both the analytics event and the write.The write happens only when no remote mnemonic can be the primary SRP:
PrimarySrpdata type.The write runs under the controller lock, after the unlocked check, a password-sync check, and token refresh. It is aborted if the user identity changed after planning. Failures are logged and never thrown, so unlock is not blocked.
submitPassworddoes not await the repair, because the repair takes the lock thatsubmitPasswordis still holding.There is no public API change.
References
Checklist
Note
Medium Risk
Best-effort writes of the primary SRP to remote backup are security-sensitive, but guarded by identity checks, schema rules, and failure isolation that avoids blocking unlock.
Overview
Adds automatic repair when remote TOPRF metadata has no primary SRP but the local keyring does—so social-login wallets can be restored on another device after unlock.
submitPasswordandidentifyIncompleteMetadataBackupnow run a newPrimarySrpBackupRepairflow instead of telemetry-only detection. One pass usesplanPrimarySrpRepair(fetch remote items once, export local mnemonic once) for both analytics (missing / mismatch events) and, when the backup is missing, a best-effortaddSecretDataItemwrite. Mismatches are still reported only; they are not overwritten.The write respects the remote schema (v1 untagged mnemonic vs v2 with
PrimarySrp), runs under the controller lock with password sync and token refresh, aborts on identity change, and never throws so unlock is not blocked (submitPassworddoes not await repair because repair re-acquires the lock). Analytics helpertrackIncompleteMetadataBackupEventsnow accepts a precomputed plan rather than doing the comparison itself.Reviewed by Cursor Bugbot for commit 7b24b16. Bugbot is set up for automated code reviews on this repo. Configure here.