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

[bug] Verification gets stuck on using custom auth #1497

Closed
1 task done
rivaratyr opened this issue Sep 2, 2023 · 8 comments
Closed
1 task done

[bug] Verification gets stuck on using custom auth #1497

rivaratyr opened this issue Sep 2, 2023 · 8 comments

Comments

@rivaratyr
Copy link

rivaratyr commented Sep 2, 2023

Is there an existing issue for this?

RainbowKit Version

1.0.8

wagmi Version

1.3.10

Current Behavior

When implementing a custom authentication by createAuthenticationAdapter() from RainbowKit following the docs on https://www.rainbowkit.com/docs/custom-authentication

The message to sign (login) shows perfectly, but it freezes on the verification step window even if I return true forcibly.
image

Based in the interface it needs a boolean:
export interface AuthenticationAdapter<Message> { getNonce: () => Promise<string>; createMessage: (args: { nonce: string; address: string; chainId: number; }) => Message; getMessageBody: (args: { message: Message; }) => string; verify: (args: { message: Message; signature: string; }) => Promise<boolean>; signOut: () => Promise<void>;}

What can be the issue?

Expected Behavior

Verifying continues or provides error message.

Steps To Reproduce

  1. Implement custom authentication based on https://www.rainbowkit.com/docs/custom-authentication
  2. Log in with RainbowKit
  3. Verify by signing the message generated by the sample code from https://www.rainbowkit.com/docs/custom-authentication
  4. Wait for verification answer

Link to Minimal Reproducible Example (CodeSandbox, StackBlitz, etc.)

Can provide git repository in private, also available for a 15-30 min call to showcase the issue.

Anything else?

Environment is React with create-react-app, Node 18, localhost:3000. Relevant excerpt from package.json:
"dependencies": { "@rainbow-me/rainbowkit": "^1.0.8", "axios": "^1.4.0", "dotenv": "^16.3.1", "lodash.merge": "^4.6.2", "react": "^18.2.0", "react-router": "^6.10.0", "react-router-dom": "^6.10.0", "siwe": "^2.1.4", "typescript": "^5.0.4", "viem": "^1.6.0", "wagmi": "^1.3.10" }, "devDependencies": { "react-scripts": "^5.0.1" }, "overrides": { "react-scripts": { "typescript": "^5" } }

@rivaratyr
Copy link
Author

This issue is related to https://github.com/orgs/WalletConnect/discussions/3590 as well. Seems WalletConnect is failing on calling the AuthenticationAdapter 's verify() function because of:

image

@rivaratyr
Copy link
Author

rivaratyr commented Sep 8, 2023

You can move forward a bit with this if you're using create-react-app. Add custom headers to the Webpack Dev Server to be able to frame the above domain.

Install Dependencies:
npm install react-app-rewired customize-cra --save-dev

Create a config-overrides.js file at the root of your project. This is where you'll make changes to the Webpack configuration.

const { overrideDevServer } = require('customize-cra');

module.exports = {
  devServer: overrideDevServer(
    config => ({
      ...config,
      headers: {
        'Content-Security-Policy': "frame-ancestors 'self' https://verify.walletconnect.com/;"
      }
    })
  )
};

In your package.json, update the start, build, and test scripts to use react-app-rewired:

{
  "scripts": {
    "start": "react-app-rewired start",
    "build": "react-app-rewired build",
    "test": "react-app-rewired test"
  }

Still not working sadly, however the domain https://verify.walletconnect.com finally can be reached from localhost.

@xRozzo
Copy link

xRozzo commented Sep 8, 2023

I encountered the same problem: it keeps verifying the signature indefinitely. I am using NextAuth, and the authorize function is never triggered. Thus, I assume the problem might be related to the configuration or packages. Recently, I built a similar system, and it worked just fine. We are merely migrating it to Next 13 with the server components.

@KoenRijpstra
Copy link

@xRozzo Can you check what your NEXTAUTH_URL is? I had the same problem when I was using a different URL then I specified.

@c0mm4nd
Copy link

c0mm4nd commented Oct 4, 2023

When nextjs 13.4.9 auth works, but gets frozen on verifying signature after updating to 13.5.4.

Auth dependencies:

    "@rainbow-me/rainbowkit": "^1.0.11",
    "@rainbow-me/rainbowkit-siwe-next-auth": "0.3.0",
    "next-auth": "^4.23.2",
    "viem": "^1.14.0",
    "wagmi": "^1.4.3",
    "siwe": "^2.1.4",

I see that the /api/auth/session request directly gets an empty json object, without executing CredentialsProvider's authorize method or any callback in authOptions.

@magiziz
Copy link
Contributor

magiziz commented Jan 3, 2024

Hey @rivaratyr. I can't reproduce this on my end. Are you able to tell me what wallet you're using when testing this ?

Are you able to see if you're getting any console errors from your browser ?

@magiziz
Copy link
Contributor

magiziz commented Jan 21, 2024

@rivaratyr Can't seem to reproduce this on my end. Can you look at our example code here and let me know if there was anything missing ?

Also a small reproducible example would be great. Link to codesandbox or repo would be awesome.

@magiziz
Copy link
Contributor

magiziz commented Feb 3, 2024

Going to close this issue for now since can't reproduce this on my end. Refer to this example if you wanna use next-auth 👍

@magiziz magiziz closed this as completed Feb 3, 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

No branches or pull requests

5 participants