Skip to content

Conversation

@lwin-kyaw
Copy link
Contributor

@lwin-kyaw lwin-kyaw commented May 3, 2024

This PR includes -

  • check 'SHARE_DELETED' on getFactorKeyMetadata and metadata validation
  • throw error instead of logging, for rehydration fail.
  • validate current factor key before copy or create new shares

lwin-kyaw added 2 commits May 3, 2024 11:01
'SHARE_DELETED' on getMetadata when using manualSync mode
@ieow
Copy link
Contributor

ieow commented May 7, 2024

Can you elaborate the issue ?
why the need to throw on rehydrate failed?

await this.tKey.initialize({ neverInitializeNewKey: true });
const hashedFactorKey = getHashedPrivateKey(this.state.oAuthKey, this.options.hashedFactorNonce);
if ((await this.checkIfFactorKeyValid(hashedFactorKey)) && !this.options.disableHashedFactorKey) {
const isHashedFactorKeyValid = this.checkIfFactorKeyValid(hashedFactorKey);
Copy link
Contributor

Choose a reason for hiding this comment

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

checkIfFactorKeyValid is async function

@lwin-kyaw
Copy link
Contributor Author

lwin-kyaw commented May 7, 2024

Can you elaborate the issue ? why the need to throw on rehydrate failed?

Hi, we don't necessarily need to throw rehydration error as when rehydration failed, all the later steps will also fail (factor login, create factor, etc...).
However throwing error on rehydration failed, can catch some errors in early stage and prevent users proceeding to other steps.
Anyway, we have logged out the error message when there's an error during rehydration, so, I think it would be better if we could throw the error also. It will also help us to write better test cases.

Sample case on rehydration failure

  • create first core kit with manualSync:true
  • create factor (factorKey1) and don't commit the changes
  • create second core kit and init (with default params, Mpc-Corekit will rehydrate with existing factorKey1 from sessionManager)
  • during rehydrate, we try to get the metadata for factorKey1, but since we don't commit changes in first corekit, factor metadata is not available, resulting in rehydration failure

@lwin-kyaw lwin-kyaw changed the title Throw error during rehydration Factorkey validation and rehydration error May 8, 2024
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.

3 participants