magiclabs / magic-js

Magic browser/React Native JavaScript SDK is your entry-point to integrating passwordless authentication inside your application.
https://magic.link/docs/api-reference/client-side-sdks/web
Apache License 2.0
463 stars 86 forks source link

Type for OAuthExtension not working with type Magic on latest version. #680

Open rameshdon1 opened 11 months ago

rameshdon1 commented 11 months ago

✅ Prerequisites

🐛 Description

I am getting this typescript error since the latest version of both magic-sdk and @magic-ext/oauth package

image

I am getting my project's build failed due to this error. Is there anything that i am doing wrong?

Here is my package version.

image

rameshdon1 commented 11 months ago

And I am using nextjs 14 app router latest version. Here is my dependencies from package.json file

"dependencies": { "@ducanh2912/next-pwa": "^9.7.2", "@hookform/resolvers": "^3.3.2", "@libsql/client": "^0.3.6", "@magic-ext/oauth": "^15.3.1", "@magiclabs/wagmi-connector": "^1.1.3", "@nextui-org/react": "^2.2.5", "@radix-ui/react-alert-dialog": "^1.0.5", "@radix-ui/react-dialog": "^1.0.5", "@radix-ui/react-dropdown-menu": "^2.0.6", "@radix-ui/react-label": "^2.0.2", "@radix-ui/react-slot": "^1.0.2", "@radix-ui/themes": "^2.0.0", "@tanstack/react-query": "^5.4.3", "@tanstack/react-query-devtools": "^5.8.1", "@types/node": "20.4.2", "@types/react": "18.2.15", "@types/react-dom": "18.2.7", "@uidotdev/usehooks": "^2.4.1", "@wagmi/core": "^1.4.7", "@web3modal/wagmi": "^3.3.2", "autoprefixer": "10.4.14", "axios": "^1.6.0", "backblaze-b2": "^1.7.0", "browser-image-compression": "^2.0.2", "class-variance-authority": "^0.7.0", "clsx": "^2.0.0", "dotenv": "^16.3.1", "drizzle-kit": "^0.19.13", "drizzle-orm": "^0.28.6", "eslint": "8.44.0", "eslint-config-next": "13.4.10", "ethers": "^6.8.0", "framer-motion": "^10.16.4", "iron-session": "^8.0.1", "lucide-react": "^0.291.0", "magic-sdk": "^21.3.1", "next": "^14.0.2", "next-themes": "^0.2.1", "nextjs-toploader": "^1.6.4", "postcss": "8.4.26", "react": "18.2.0", "react-device-detect": "^2.2.3", "react-dom": "18.2.0", "react-hook-form": "^7.47.0", "react-icons": "^4.11.0", "react-use": "^17.4.1", "siwe": "^2.1.4", "sonner": "^1.2.0", "tailwind-merge": "^2.0.0", "tailwindcss": "3.3.3", "tailwindcss-animate": "^1.0.7", "tsx": "^3.14.0", "typescript": "5.1.6", "vaul": "^0.7.9", "viem": "^1.2.15", "wagmi": "^1.4.7", "zod": "^3.22.4" }, "devDependencies": { "@cloudflare/next-on-pages": "^1.7.2", "@types/backblaze-b2": "^1.5.6", "eslint-plugin-next-on-pages": "^1.7.2", "eslint-plugin-simple-import-sort": "^10.0.0", "tailwind-scrollbar": "^3.0.5", "vercel": "^32.5.0" }

kevinwo commented 7 months ago

@rameshdon1 Have you been able to use the OAuth extension and sign in with social regardless? I'm currently trying to move past the type issue anyway, but when trying to force running magic.oauth.loginWithRedirect({ provider: "google" }), end up getting an immediate failure with: TypeError: h.configureStorage is not a function

kevinwo commented 7 months ago

I traded emails with support and found the issue, which is not with Magic. After investigating further (I upgraded to the latest SDK versions in Magic's google-auth-demo and verified the implementation still works fine.), I found, for my case, there appears to be a conflict between the later versions of the magic-sdk and the earlier versions of the SDK that the @thirdweb-dev/wallets sdk relies on.

I've since removed the stable Thirdweb SDK and opted to use the beta version, which removes Magic as a dependency, freeing me up to use both the latest versions of magic-sdk and @magic-ext/oauth. It's possible one of the packages you list above may have a similar conflict.

walktan commented 6 months ago

@rameshdon1 I was also having the same problem, but it was resolved. The cause is the different versions of @magic-sdk/provider that magic-sdk and @magic-ext/oauth depend on.

I fixed it by specifying the following versions and reinstalling them.

"@magic-ext/oauth": "^15.4.1"
"@magic-sdk/provider": "^28.0.2",
"magic-sdk": "^28.0.3",