Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration on new mpc service + firestore + relayer #51

Merged
merged 7 commits into from Sep 26, 2023
Merged

Conversation

hcho112
Copy link
Collaborator

@hcho112 hcho112 commented Sep 19, 2023

This PR contains following implementation:

  • Integration on new mpc endpoint
  • Integration on firestore
  • Integration on relayer
  • Able to create new Account with above
  • Able to signin with existing account with above
  • Able to delete existing keys and continue signin with above

There are more work need on following:

  • UI/messaging around the is the meaning of exceeded maximum keys
  • Lack of verification on mpc_service against claim_oidc token
  • Lack of UI on device tab
  • Pull out relayer, firestore configuration and make it customizable

Firestore permission setting:

  • User can perform GET, POST, UPDATE, DELETE on their own collection only

To test this branch locally, need to run near discovery locally by pull down and run following:

git checkout fast-auth-iframe-wallet
pnpm install && pnpm dev -p 3001

Then checkout to this branch and run following:

yarn && yarn start

High level description on authentication flow:

On create account:
-> create new account through firebase
-> hit /new_account endpoint on mpc service
-> create new firestore record that contains one FAK and one LAK
-> back to app

On Signin to a browser that has setup passKey
-> use webauthn key to get recovery key
-> attempt to create new LAK and delete old LAK associated to webauthn key
(If fail due to too much key, it will redirect to /devices endpoint, will be described later)
-> update firestore collection with only new LAK
-> back to app

On Signin to a browser that has no passkey setup yet
-> use webauthn to check if browser has key
-> if no key, create a new webAuthN key and LAK
(If fail due to too much key, it will redirect to /devices endpoint, will be described later)
-> create new firestore record that contains one FAK and one LAK
-> back to app

On Signin to a browser that has passkey but no longer on chain (deleted by /devices page)
-> use webauthn to check if browser has key
-> if it has key, but doesn't exist on chain, create a new webAuthN key and LAK
(If fail due to too much key, it will redirect to /devices endpoint, will be described later)
-> create new firestore record that contains one FAK and one LAK
-> back to app

On Redirected to a /devices page
-> Get list of device records from firestore
-> User select and delete firestore record
-> Also delete FAK and LAK associated to deleted firestore record
-> create new WebAuthN FAK and LAK
-> create new firestore record that contains one FAK and one LAK
-> back to app


export const useAuthState = () => {
const [authenticated, setAuthenticated] = useState(undefined);
Copy link
Collaborator

Choose a reason for hiding this comment

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

This needs to start as undefined because we need to identify when the user has not authenticated yet vs failed authentication in some cases

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

On that exact reason, I used controllerState which already does it inside the code and export it:

https://github.com/near/fast-auth-signer/pull/51/files#diff-e32098d15337091eba6e38cf673f428139718632e81710d1e180d58836cae11bR12?plain=1

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

so I have updated the logic on Sign component

Copy link
Collaborator

@esaminu esaminu left a comment

Choose a reason for hiding this comment

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

LGTM ✅

@hcho112 hcho112 merged commit cd6c8c3 into main Sep 26, 2023
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.

None yet

2 participants