-
Notifications
You must be signed in to change notification settings - Fork 13
feat: Add Farcaster miniapp support for identity verification flow #10 #14
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
base: main
Are you sure you want to change the base?
Changes from 27 commits
25ee077
42fc37e
9557dce
42e08a9
64d56a8
3323d82
8bff2fe
f3940b2
53564da
60eb1cb
c105e1b
e10b584
8edaca1
c34de25
f6889fd
8616d89
36dfa32
5ed0e06
5bdab21
cd6d40f
f1e9b8d
b7de6cb
304c15a
9841794
d19d211
158465a
4060809
e6ba4d0
8cf55a7
c1486dc
04ff59c
3dd1832
59484bc
f620a1c
c38476f
20d0905
9a9dbbc
7a7a921
994b4f3
75a9b45
6377bf0
359e2c2
4ad2886
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,4 +10,4 @@ | |
| <div id="app"></div> | ||
| <script type="module" src="/src/main.tsx"></script> | ||
| </body> | ||
| </html> | ||
| </html> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -52,4 +52,4 @@ | |
| "typescript": "^5.8.2", | ||
| "vite": "6.3.5" | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,45 +1,79 @@ | ||
| import React from "react" | ||
| import { Button } from "tamagui" | ||
| import React, { useState } from "react" | ||
| import { Button, Spinner } from "tamagui" | ||
| import { useIdentitySDK } from "@goodsdks/react-hooks" | ||
| import { useAccount } from "wagmi" | ||
|
|
||
| interface VerifyButtonProps { | ||
| onVerificationSuccess: () => void | ||
| // No props needed - verification success is handled by URL callback detection | ||
|
||
| } | ||
|
|
||
| export const VerifyButton: React.FC<VerifyButtonProps> = ({ | ||
| onVerificationSuccess, | ||
| }) => { | ||
| export const VerifyButton: React.FC<VerifyButtonProps> = () => { | ||
| const { address } = useAccount() | ||
| const { sdk: identitySDK } = useIdentitySDK("development") | ||
| const [isLoading, setIsLoading] = useState(false) | ||
| const [error, setError] = useState<string | null>(null) | ||
|
|
||
| const handleVerify = async () => { | ||
| if (!identitySDK || !address) return | ||
| if (!identitySDK || !address) { | ||
| setError("Wallet not connected. Please connect your wallet first.") | ||
| return | ||
| } | ||
|
|
||
| setIsLoading(true) | ||
| setError(null) | ||
|
|
||
| try { | ||
| const fvLink = await identitySDK.generateFVLink( | ||
| false, | ||
| console.log("Starting face verification process...") | ||
| console.log("Address:", address) | ||
| console.log("Callback URL:", window.location.href) | ||
|
|
||
| // Navigate to face verification - this will open in external browser in Farcaster | ||
| await identitySDK.navigateToFaceVerification( | ||
| false, // Use redirect mode for proper callback handling | ||
| window.location.href, | ||
| 42220, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why was this removed |
||
| 42220 | ||
| ) | ||
|
|
||
| window.location.href = fvLink | ||
| } catch (error) { | ||
| console.error("Verification failed:", error) | ||
| // Handle error (e.g., show toast) | ||
|
|
||
| console.log("Face verification navigation initiated successfully") | ||
| // Note: Verification success will be handled by URL callback detection in App.tsx | ||
| // when the user returns from the external verification process | ||
|
|
||
| } catch (error: any) { | ||
| console.error("Face verification navigation failed:", error) | ||
|
|
||
| // Provide specific error messages based on error type | ||
| if (error.message?.includes("Navigation not supported")) { | ||
| setError("Navigation is not supported in this environment. Please try in a different browser.") | ||
| } else if (error.message?.includes("openUrl")) { | ||
| setError("Failed to open verification page. Please check your browser settings and try again.") | ||
| } else if (error.message?.includes("signature")) { | ||
| setError("Failed to sign verification message. Please try again.") | ||
| } else { | ||
| setError(error.message || "Verification failed. Please try again.") | ||
| } | ||
| } finally { | ||
| setIsLoading(false) | ||
| } | ||
| } | ||
|
|
||
| return ( | ||
| <Button | ||
| onPress={handleVerify} | ||
| color="white" | ||
| backgroundColor="#00AEFF" | ||
| hoverStyle={{ | ||
| backgroundColor: "black", | ||
| }} | ||
| > | ||
| Verify Me | ||
| </Button> | ||
| <div> | ||
| <Button | ||
| onPress={handleVerify} | ||
| disabled={isLoading} | ||
| color="white" | ||
| backgroundColor="#00AEFF" | ||
| hoverStyle={{ | ||
| backgroundColor: "black", | ||
| }} | ||
| > | ||
| {isLoading ? <Spinner size="small" color="white" /> : "Verify Me"} | ||
| </Button> | ||
| {error && ( | ||
| <div style={{ color: "red", fontSize: "14px", marginTop: "8px" }}> | ||
| {error} | ||
| </div> | ||
| )} | ||
| </div> | ||
| ) | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,4 +31,4 @@ export default defineConfig({ | |
| "process.browser": true, | ||
| "process.env": process.env, | ||
| }, | ||
| }); | ||
| }); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
VerifyButton.tsx?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Lewis, I don't fully understand this, mind explaining deeper please?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you mean I should revert the file to how it was initially? and remove every code I added relating to the forecaster support?