Skip to content

Conversation

@ieow
Copy link
Contributor

@ieow ieow commented Nov 6, 2025

Motivation and Context

Jira Link:

Description

  • Add check for valid factorKey from tkey.metadata.factorEncs which will reduce the metadata call and avoid dirty deleted factorkey metadata.

Previously we check for valid factorkey by checking the metadata availability. This could cause issue if user deleted share with factor pub only but not factorkey where it delete the metadata.

  • Add new user indication. for manual sync, new user indication is required to decide commit_changes

How has this been tested?

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • My code follows the code style of this project. (run lint)
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • My code requires a db migration.

Note

Validate factor keys against metadata.factorEncs before metadata reads and expand tests to cover MFA/device factor replacement and invalid factor inputs.

  • CoreKit (src/mpcCoreKit.ts):
    • checkIfFactorKeyValid: Early-checks factorEncs[this.tssTag][factorPubX]; returns false if missing before reading metadata.
    • inputFactorKey: Pre-validates via factorEncs; throws providedFactorKeyInvalid when absent.
  • Tests (tests/factors.spec.ts):
    • Import getPubKeyPoint; persist browserFactor across tests.
    • New "replace factor" test: create new device factor, switch to it, delete old device factor (by pub and key), and assert deleted factor cannot be used.
    • Minor adjustments in MFA test to use persisted device factor and validate invalid inputs.

Written by Cursor Bugbot for commit 8bf067d. This will update automatically on new commits. Configure here.

@ieow ieow marked this pull request as ready for review November 6, 2025 13:05
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: NewUser Flag Malfunction on Reset/Init Rehydrate

The resetState method doesn't reset the newUser flag to false. According to the comment, newUser should only be true during new user sign up and should be false after reinit or rehydration. Since resetState is called during init and logout, the flag will incorrectly remain true after these operations for users who were initially new users.

src/mpcCoreKit.ts#L1406-L1413

mpc-core-kit/src/mpcCoreKit.ts

Lines 1406 to 1413 in d28e51c

private resetState(): void {
this.ready = false;
this.tkey = null;
this.torusSp = null;
this.storageLayer = null;
this.state = { accountIndex: 0 };
}

Fix in Cursor Fix in Web


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.

2 participants