Skip to content

Taylor/test policy #23

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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,10 @@ TURNKEY_API_PUBLIC_KEY=
TURNKEY_API_PRIVATE_KEY=

# Use any randomly generated alphanumeric string
FACEBOOK_SECRET_SALT=
FACEBOOK_SECRET_SALT=


WARCHEST_PRIVATE_KEY_ID=""
TURNKEY_WARCHEST_ORGANIZATION_ID=""
TURNKEY_WARCHEST_API_PUBLIC_KEY=""
TURNKEY_WARCHEST_API_PRIVATE_KEY=""
79 changes: 79 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Development Commands

- `pnpm dev` - Start development server
- `pnpm build` - Build production bundle
- `pnpm start` - Start production server
- `pnpm lint` - Run ESLint
- `pnpm format` - Format code with Prettier
- `pnpm format:check` - Check code formatting

## Architecture Overview

This is a Next.js 14+ demo application showcasing Turnkey's embedded wallet functionality with multiple authentication methods.

### Core Technologies
- **Framework**: Next.js 14 with App Router
- **Authentication**: Turnkey SDK for wallet-based auth, OAuth (Google, Apple, Facebook), email auth, passkeys
- **Blockchain**: Ethereum (Sepolia testnet) via Viem and Alchemy
- **UI**: shadcn/ui components with Radix UI primitives and Tailwind CSS
- **Type Safety**: TypeScript with Zod schema validation

### Key Architecture Patterns

**Provider Hierarchy** (`src/providers/index.tsx`):
```
ThemeProvider > TurnkeyProvider > AuthProvider
```

**Authentication Flow**:
1. Multiple auth methods funnel through `AuthProvider` context
2. Creates Turnkey sub-organizations for users via server actions
3. Manages sessions and wallet state globally
4. Supports passkeys, OAuth providers, email magic links, and wallet imports

**Server Actions Pattern** (`src/actions/`):
- `turnkey.ts` - Core Turnkey operations (user creation, auth, wallet management)
- `web3.ts` - Blockchain interactions (transactions, balance queries)
- All use "use server" directive for secure server-side operations

**Environment Configuration** (`src/env.mjs`):
- Uses `@t3-oss/env-nextjs` for type-safe environment variables
- Separates client/server environment variables
- Validates all required Turnkey, OAuth, and blockchain API keys

### Turnkey Integration Details

**Configuration** (`src/config/turnkey.ts`):
- Manages iframe URLs for auth, export, and import flows
- Configures passkey settings with RP ID
- Sets up Ethereum RPC via Alchemy

**Key Components**:
- Sub-organization creation per user with embedded wallets
- Warchest system for funding new wallets (0.01 ETH via `fundWallet`)
- Support for multiple authenticator types (passkeys, OAuth, API keys)
- Session management with expiry warnings

**Wallet Operations**:
- Default Ethereum accounts created automatically
- Transaction history via Alchemy SDK
- Support for wallet export/import flows
- Address validation and balance checking

### App Router Structure

**Route Groups**:
- `(landing)` - Unauthenticated pages (login, OAuth callbacks)
- `(dashboard)` - Authenticated pages (wallet dashboard, settings)

**Key Pages**:
- `/` - Landing page with authentication options
- `/dashboard` - Main wallet interface
- `/settings` - User settings and account management
- `/auth-client` - Standalone auth demonstration

The application demonstrates a complete embedded wallet solution with multiple authentication methods, automatic wallet funding, and a polished user interface.
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@
"@radix-ui/react-tooltip": "^1.1.2",
"@react-oauth/google": "^0.12.1",
"@t3-oss/env-nextjs": "^0.9.2",
"@turnkey/crypto": "^2.3.0",
"@turnkey/encoding": "^0.4.0",
"@turnkey/http": "^2.17.2",
"@turnkey/sdk-browser": "^1.11.1",
"@turnkey/sdk-react": "^2.0.3",
"@turnkey/sdk-server": "^1.7.2",
"@turnkey/viem": "^0.6.8",
"@turnkey/wallet-stamper": "^1.0.2",
"@turnkey/crypto": "^2.4.0",
"@turnkey/encoding": "^0.5.0",
"@turnkey/http": "^3.4.2",
"@turnkey/sdk-browser": "^5.2.1",
"@turnkey/sdk-react": "^5.2.1",
"@turnkey/sdk-server": "^4.1.1",
"@turnkey/viem": "^0.9.7",
"@turnkey/wallet-stamper": "^1.0.4",
"@types/jsonwebtoken": "^9.0.7",
"alchemy-sdk": "^3.4.1",
"class-variance-authority": "^0.7.0",
Expand All @@ -53,7 +53,7 @@
"tailwindcss-animate": "^1.0.7",
"usehooks-ts": "^3.1.0",
"vaul": "^0.9.4",
"viem": "^2.20.0",
"viem": "^2.31.1",
"zod": "^3.23.4"
},
"devDependencies": {
Expand Down
Loading