mirror of
https://github.com/neynarxyz/create-farcaster-mini-app.git
synced 2025-11-15 23:58:56 -05:00
format
This commit is contained in:
parent
b366d97b53
commit
378ea65154
14
bin/init.js
14
bin/init.js
@ -1,12 +1,12 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import inquirer from 'inquirer';
|
||||
import { fileURLToPath } from 'url';
|
||||
import { dirname } from 'path';
|
||||
import { execSync } from 'child_process';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import crypto from 'crypto';
|
||||
import fs from 'fs';
|
||||
import { dirname } from 'path';
|
||||
import path from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
import inquirer from 'inquirer';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(__filename);
|
||||
@ -47,7 +47,7 @@ async function queryNeynarApp(apiKey) {
|
||||
}
|
||||
try {
|
||||
const response = await fetch(
|
||||
`https://api.neynar.com/portal/app_by_api_key?starter_kit=true`,
|
||||
'https://api.neynar.com/portal/app_by_api_key?starter_kit=true',
|
||||
{
|
||||
headers: {
|
||||
'x-api-key': apiKey,
|
||||
@ -444,7 +444,7 @@ export async function init(
|
||||
// Update package.json
|
||||
console.log('\nUpdating package.json...');
|
||||
const packageJsonPath = path.join(projectPath, 'package.json');
|
||||
let packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
||||
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
||||
|
||||
packageJson.name = finalProjectName;
|
||||
packageJson.version = '0.1.0';
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
import localtunnel from 'localtunnel';
|
||||
import { spawn } from 'child_process';
|
||||
import { createServer } from 'net';
|
||||
import dotenv from 'dotenv';
|
||||
import path from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
import dotenv from 'dotenv';
|
||||
import localtunnel from 'localtunnel';
|
||||
|
||||
// Load environment variables
|
||||
dotenv.config({ path: '.env.local' });
|
||||
@ -96,7 +96,7 @@ async function startDev() {
|
||||
? `1. Run: netstat -ano | findstr :${port}\n` +
|
||||
'2. Note the PID (Process ID) from the output\n' +
|
||||
'3. Run: taskkill /PID <PID> /F\n'
|
||||
: `On macOS/Linux, run:\nnpm run cleanup\n`) +
|
||||
: 'On macOS/Linux, run:\nnpm run cleanup\n') +
|
||||
'\nThen try running this command again.',
|
||||
);
|
||||
process.exit(1);
|
||||
|
||||
@ -8,10 +8,7 @@ export async function POST(request: Request) {
|
||||
const { token } = await request.json();
|
||||
|
||||
if (!token) {
|
||||
return NextResponse.json(
|
||||
{ error: 'Token is required' },
|
||||
{ status: 400 }
|
||||
);
|
||||
return NextResponse.json({ error: 'Token is required' }, { status: 400 });
|
||||
}
|
||||
|
||||
// Get domain from environment or request
|
||||
@ -35,10 +32,7 @@ export async function POST(request: Request) {
|
||||
} catch (e) {
|
||||
if (e instanceof Errors.InvalidTokenError) {
|
||||
console.info('Invalid token:', e.message);
|
||||
return NextResponse.json(
|
||||
{ error: 'Invalid token' },
|
||||
{ status: 401 }
|
||||
);
|
||||
return NextResponse.json({ error: 'Invalid token' }, { status: 401 });
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
@ -46,7 +40,7 @@ export async function POST(request: Request) {
|
||||
console.error('Token validation error:', error);
|
||||
return NextResponse.json(
|
||||
{ error: 'Internal server error' },
|
||||
{ status: 500 }
|
||||
{ status: 500 },
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,4 @@
|
||||
import type { Metadata } from 'next';
|
||||
|
||||
import '~/app/globals.css';
|
||||
import { Providers } from '~/app/providers';
|
||||
import { APP_NAME, APP_DESCRIPTION } from '~/lib/constants';
|
||||
|
||||
@ -16,8 +16,14 @@ export function ProfileButton({
|
||||
|
||||
useDetectClickOutside(ref, () => setShowDropdown(false));
|
||||
|
||||
const name = userData?.username && userData.username.trim() !== '' ? userData.username : `!${userData?.fid}`;
|
||||
const pfpUrl = userData?.pfpUrl && userData.pfpUrl.trim() !== '' ? userData.pfpUrl : 'https://farcaster.xyz/avatar.png';
|
||||
const name =
|
||||
userData?.username && userData.username.trim() !== ''
|
||||
? userData.username
|
||||
: `!${userData?.fid}`;
|
||||
const pfpUrl =
|
||||
userData?.pfpUrl && userData.pfpUrl.trim() !== ''
|
||||
? userData.pfpUrl
|
||||
: 'https://farcaster.xyz/avatar.png';
|
||||
|
||||
return (
|
||||
<div className="relative" ref={ref}>
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
'use client';
|
||||
|
||||
import { useCallback, useEffect, useState, useRef } from 'react';
|
||||
import { cn } from '~/lib/utils';
|
||||
import { Button } from '~/components/ui/Button';
|
||||
import { ProfileButton } from '~/components/ui/NeynarAuthButton/ProfileButton';
|
||||
import { AuthDialog } from '~/components/ui/NeynarAuthButton/AuthDialog';
|
||||
import { useMiniApp } from '@neynar/react';
|
||||
import sdk, { SignIn as SignInCore } from '@farcaster/frame-sdk';
|
||||
import { useMiniApp } from '@neynar/react';
|
||||
import { Button } from '~/components/ui/Button';
|
||||
import { AuthDialog } from '~/components/ui/NeynarAuthButton/AuthDialog';
|
||||
import { ProfileButton } from '~/components/ui/NeynarAuthButton/ProfileButton';
|
||||
import { useQuickAuth } from '~/hooks/useQuickAuth';
|
||||
import { cn } from '~/lib/utils';
|
||||
|
||||
type User = {
|
||||
fid: number;
|
||||
@ -142,7 +142,7 @@ export function NeynarAuthButton() {
|
||||
const updateSessionWithSigners = useCallback(
|
||||
async (
|
||||
signers: StoredAuthState['signers'],
|
||||
user: StoredAuthState['user'],
|
||||
_user: StoredAuthState['user'],
|
||||
) => {
|
||||
if (!useBackendFlow) return;
|
||||
|
||||
@ -392,7 +392,7 @@ export function NeynarAuthButton() {
|
||||
setMessage(result.message);
|
||||
setSignature(result.signature);
|
||||
// Use QuickAuth to sign in
|
||||
const signInResult = await quickAuthSignIn();
|
||||
await quickAuthSignIn();
|
||||
// Fetch user profile after sign in
|
||||
if (quickAuthUser?.fid) {
|
||||
const user = await fetchUserData(quickAuthUser.fid);
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
'use client';
|
||||
|
||||
import { useCallback, useState } from 'react';
|
||||
import sdk, { SignIn as SignInCore } from '@farcaster/miniapp-sdk';
|
||||
import { Button } from '../Button';
|
||||
import { SignIn as SignInCore } from '@farcaster/miniapp-sdk';
|
||||
import { useQuickAuth } from '~/hooks/useQuickAuth';
|
||||
import { Button } from '../Button';
|
||||
|
||||
/**
|
||||
* SignIn component handles Farcaster authentication using QuickAuth.
|
||||
|
||||
@ -63,7 +63,8 @@ interface UseQuickAuthReturn {
|
||||
*/
|
||||
export function useQuickAuth(): UseQuickAuthReturn {
|
||||
// Current authenticated user data
|
||||
const [authenticatedUser, setAuthenticatedUser] = useState<AuthenticatedUser | null>(null);
|
||||
const [authenticatedUser, setAuthenticatedUser] =
|
||||
useState<AuthenticatedUser | null>(null);
|
||||
// Current authentication status
|
||||
const [status, setStatus] = useState<QuickAuthStatus>('loading');
|
||||
|
||||
@ -73,7 +74,9 @@ export function useQuickAuth(): UseQuickAuthReturn {
|
||||
* @param {string} authToken - The JWT token to validate
|
||||
* @returns {Promise<AuthenticatedUser | null>} User data if valid, null otherwise
|
||||
*/
|
||||
const validateTokenWithServer = async (authToken: string): Promise<AuthenticatedUser | null> => {
|
||||
const validateTokenWithServer = async (
|
||||
authToken: string,
|
||||
): Promise<AuthenticatedUser | null> => {
|
||||
try {
|
||||
const validationResponse = await fetch('/api/auth/validate', {
|
||||
method: 'POST',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user