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

Waxjs manual login #172

Open
tokmak0 opened this issue Nov 13, 2023 · 3 comments
Open

Waxjs manual login #172

tokmak0 opened this issue Nov 13, 2023 · 3 comments

Comments

@tokmak0
Copy link

tokmak0 commented Nov 13, 2023

I am trying to create a login system using waxjs. Now I have succeeded in this and I can also auto-login. However, the problem is, I am using nextjs 13 and how can I verify the identity of the user on the server side? Also, how can I auto-login the user myself? An example code would be very useful to me. Thank you.
Code:

const  wax = new waxjs.WaxJS({
        rpcEndpoint: 'https://wax.greymass.com',
});

// I  need to remember the user on other pages too
const userAccount = wax.login(); 
@niksad8
Copy link
Collaborator

niksad8 commented Nov 14, 2023

for the verification part there is a verify endpoint you can use waxProof function to do this , also when you login you can pass a nonce https://github.com/worldwide-asset-exchange/waxjs/blob/develop/src/index.ts#L132
this will allow you to get a verification signature, once the user logs in you can then use the users public key to verify the signature as being acurate, you can do this check on the backend too, to be safe.

regarding the auto login, the general work flow is once the user logins to your website you store the wallet name in localstorage, or server session. you can then use that to execute transactions on behalf on the user.
usually you will need to execute the function isAutoLoginAvailable this way we can do it.

@tokmak0
Copy link
Author

tokmak0 commented Nov 18, 2023

@niksad8 Thanks for information. But I didn't understand how to verify this signature on the server. For example, can I keep the software signature on the client? Can you give sample code?

@rdewilder
Copy link

rdewilder commented Dec 29, 2023

@tokmak0 To verify the user on the serverside you can do the following:

Client
const proof = await wax.waxProof('nonce', true)

send the contents of proof to the server

Server
Validate the proof sent by client: https://github.com/worldwide-asset-exchange/waxjs?tab=readme-ov-file#manual-verification-of-signature

Make sure you use the active key from the proof.wax account when verifying the signature.

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

No branches or pull requests

3 participants