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

FR: Verify session on server #958

Open
carlbarrdahl opened this issue Sep 9, 2024 · 1 comment
Open

FR: Verify session on server #958

carlbarrdahl opened this issue Sep 9, 2024 · 1 comment

Comments

@carlbarrdahl
Copy link

Is your feature request related to a problem? Please describe.
It would be great if we could verify the user wallet on server-side.
I know the address can be gotten from the cookie but this could be changed by the client.

Describe the solution you would like

import { getSession } from "@account-kit/core"

async function handler(req, res) {
  const session = await getSession()
  // session.address = "0x..."
  await db.post.create({ data: {...body, owner: session.address } })
}

Describe alternatives you have considered

  • Using NextAuth and have the SmartAccount wallet sign a message to create a session.
  • Using Privy or Web3Auth that support this use-case
@moldy530
Copy link
Collaborator

Ah yea we've discussed this internally as well. Right now, you can use the signer returned from the useSigner or even the account returned from useAccount to signMessage and then verify the message signature on the server and that it matches the SCA address for your user.

The other thing we want to expose is a stampWhoAmi method on the signer itself. with that method you would be able to send the stamp to your backend and then call our whoami endpoint on the server which will return the user id + signer address for that stamp (if the stamp is valid).

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

2 participants