You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: add sign in with ethereum to signInWithWeb3 (#1082)
## What kind of change does this PR introduce?
This PR adds SIWE (Sign-In-With-Ethereum) support to auth-js, related to
[this PR on /auth](supabase/auth#2069)
## What is the current behavior?
Multiple providers & SIWS (Solana) supported
## What is the new behavior?
Add SIWE (Ethereum) support.
## Additional context
The types are inspired by the the [viem](https://viem.sh/) library,
which has minimal & modern types, but they were simplified and copied
over to the local code to remove dependency on it.
'@supabase/auth-js: Both wallet and url must be specified in non-browser environments.'
707
+
)
708
+
}
709
+
710
+
resolvedWallet=wallet
711
+
}elseif(typeofwallet==='object'){
712
+
resolvedWallet=wallet
713
+
}else{
714
+
constwindowAny=windowasany
715
+
716
+
if(
717
+
'ethereum'inwindowAny&&
718
+
typeofwindowAny.ethereum==='object'&&
719
+
'request'inwindowAny.ethereum&&
720
+
typeofwindowAny.ethereum.request==='function'
721
+
){
722
+
resolvedWallet=windowAny.ethereum
723
+
}else{
724
+
thrownewError(
725
+
`@supabase/auth-js: No compatible Ethereum wallet interface on the window object (window.ethereum) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'ethereum', wallet: resolvedUserWallet }) instead.`
@@ -673,7 +675,46 @@ export type SolanaWeb3Credentials =
673
675
}
674
676
}
675
677
676
-
exporttypeWeb3Credentials=SolanaWeb3Credentials
678
+
exporttypeEthereumWallet=EIP1193Provider
679
+
680
+
exporttypeEthereumWeb3Credentials=
681
+
|{
682
+
chain: 'ethereum'
683
+
684
+
/** Wallet interface to use. If not specified will default to `window.solana`. */
685
+
wallet?: EthereumWallet
686
+
687
+
/** Optional statement to include in the Sign in with Solana message. Must not include new line characters. Most wallets like Phantom **require specifying a statement!** */
688
+
statement?: string
689
+
690
+
options?: {
691
+
/** URL to use with the wallet interface. Some wallets do not allow signing a message for URLs different from the current page. */
692
+
url?: string
693
+
694
+
/** Verification token received when the user completes the captcha on the site. */
0 commit comments