webaverse / weba-wallet

0 stars 2 forks source link

Weba-Wallet (Login + Storage module for Webaverse App) #2

Open mujabmuneeb opened 2 years ago

mujabmuneeb commented 2 years ago

Verifies postMessage(origin) from Webaverse app and return data as per request.

Creates Weba-wallet table inside dynamoDB. Contains three routes:

  1. /validate (validates user's token & password, if verifies return login message, data and temp token, If a new user? registers in dynamoDB and return with temp token)
  2. /save-data (validates user's temp token, to store new key-value data against user)
  3. /get-key (validates user's temp token, and return respective key-value data)

New temp token will be returned on login/ or on registration.

===================

On Webaverse App: (Ref: https://github.com/webaverse/app/pull/1762)

  1. On login, a popup will be opened, along with the postMessage carrying the user's address(token). The user will enter a password. And depending on the password, one of these three responses is expected either 1) it will throw an error on the wrong password, 2) create a new user, or 3) validate the password and return the user's data.
  2. If a user is already logged in and has an address and a temp token. The app will request a wallet to get key-value data.
  3. If an app wants to save data into a wallet there is a function called sendDataToWallet(). Call this fn with a parameter of key-value pair and data will be stored in the wallet.
avaer commented 2 years ago

Creates Weba-wallet table inside dynamoDB.

Is this new code for a new table on the backend, separate from the user tables we already had?

https://github.com/webaverse/api-backend/blob/ee4618e2c2fffd5fbccb2eff7687ff9eb60f1f69/index.js#L473

avaer commented 2 years ago

Are all of the endpoints like discord going to be moved to this storage solution? What happens to all of the old accounts that already exist?

mujabmuneeb commented 2 years ago

I think I somehow failed to communicate properly earlier, but it doesn't affect any user or any user's data it only deals with the User's local storage. For better understanding let me share the flow diagram.

Creates Weba-wallet table inside dynamoDB.

Is this new code for a new table on the backend, separate from the user tables we already had?

https://github.com/webaverse/api-backend/blob/ee4618e2c2fffd5fbccb2eff7687ff9eb60f1f69/index.js#L473

mujabmuneeb commented 2 years ago
Screenshot 2021-11-26 at 8 53 01 PM
mujabmuneeb commented 2 years ago
Screenshot 2021-11-26 at 8 53 13 PM
mujabmuneeb commented 2 years ago
Screenshot 2021-11-26 at 8 53 21 PM
avaer commented 2 years ago

The backend part makes sense but this repo should not implement it, since I think it already exists.

mujabmuneeb commented 2 years ago

Update:

Removed DB from wallet's backend and now using existing DB user's table to fetch and update his data. Temp key feature has been removed, replacing it with an encrypted mnemonic. Now, user data will be fetched/update via encrypted privateKey(mnemonic) we will receive from App.