Skip to content

Commit b780f76

Browse files
authored
add privy login support (#537)
1 parent bd6b5a6 commit b780f76

File tree

86 files changed

+4202
-172
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+4202
-172
lines changed

.changeset/config.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@
77
"access": "public",
88
"baseBranch": "main",
99
"updateInternalDependencies": "patch",
10-
"ignore": ["events", "next-example", "docs", "hypergraph-vite-react-template", "hypergraph-template-nextjs"],
10+
"ignore": [
11+
"events",
12+
"privy-login-example",
13+
"next-example",
14+
"docs",
15+
"hypergraph-vite-react-template",
16+
"hypergraph-template-nextjs"
17+
],
1118
"prettier": false
1219
}

.changeset/silver-bikes-lie.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
"@graphprotocol/hypergraph-react": patch
3+
"@graphprotocol/hypergraph": patch
4+
"connect": patch
5+
"server": patch
6+
---
7+
8+
add privy authentication functionality for internal apps
9+

CLAUDE.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Hypergraph is a local-first framework for building web3 consumer applications th
1212
```bash
1313
# Run specific apps
1414
cd apps/events && pnpm dev # Events demo app
15+
cd apps/privy-login-example && pnpm dev # Privy login example app
1516
cd apps/server && pnpm dev # Backend sync server
1617
cd apps/connect && pnpm dev # Geo Connect auth app
1718
```
@@ -52,6 +53,7 @@ pnpm clean # Clean all build artifacts
5253
- **apps/** - Complete applications
5354
- `server/` - Backend sync server (Express + Prisma + SQLite/PostgreSQL)
5455
- `events/` - Demo app showcasing the framework (Vite + React)
56+
- `privy-login-example/` - Privy login example app (Vite + React)
5557
- `connect/` - Geo Connect authentication app
5658
- `next-example/` - Next.js integration example
5759
- **docs/** - Docusaurus documentation site

apps/connect/src/routes/authenticate.tsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -336,8 +336,6 @@ function AuthenticateComponent() {
336336

337337
const newAppIdentity = Connect.createAppIdentity();
338338

339-
console.log('creating smart session');
340-
console.log('public spaces data', publicSpacesData);
341339
const spaces =
342340
publicSpacesData
343341
// .filter((space) => selectedPublicSpaces.has(space.id))
@@ -348,10 +346,8 @@ function AuthenticateComponent() {
348346
: (space.mainVotingAddress as `0x${string}`),
349347
type: space.type as 'personal' | 'public',
350348
})) ?? [];
351-
console.log('spaces', spaces);
352349

353350
const localAccount = privateKeyToAccount(keys.signaturePrivateKey as `0x${string}`);
354-
console.log('local account', localAccount.address);
355351
// TODO: add additional actions (must be passed from the app)
356352
const permissionId = await Connect.createSmartSession(
357353
localAccount,
@@ -365,17 +361,14 @@ function AuthenticateComponent() {
365361
additionalActions: [],
366362
},
367363
);
368-
console.log('smart session created');
369364
const smartAccountClient = await Connect.getSmartAccountWalletClient({
370365
owner: localAccount,
371366
address: accountAddress,
372367
chain: CHAIN,
373368
rpcUrl: import.meta.env.VITE_HYPERGRAPH_RPC_URL,
374369
});
375370

376-
console.log('encrypting app identity');
377371
const { ciphertext } = await Connect.encryptAppIdentity({ ...newAppIdentity, permissionId }, keys);
378-
console.log('proving ownership');
379372
const { accountProof, keyProof } = await Identity.proveIdentityOwnership(
380373
smartAccountClient,
381374
accountAddress,

apps/privy-login-example/README.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# React + TypeScript + Vite
2+
3+
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
4+
5+
Currently, two official plugins are available:
6+
7+
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
8+
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
9+
10+
## Expanding the ESLint configuration
11+
12+
If you are developing a production application, we recommend updating the configuration to enable type aware lint rules:
13+
14+
- Configure the top-level `parserOptions` property like this:
15+
16+
```js
17+
export default tseslint.config({
18+
languageOptions: {
19+
// other options...
20+
parserOptions: {
21+
project: ['./tsconfig.node.json', './tsconfig.app.json'],
22+
tsconfigRootDir: import.meta.dirname,
23+
},
24+
},
25+
})
26+
```
27+
28+
- Replace `tseslint.configs.recommended` to `tseslint.configs.recommendedTypeChecked` or `tseslint.configs.strictTypeChecked`
29+
- Optionally add `...tseslint.configs.stylisticTypeChecked`
30+
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and update the config:
31+
32+
```js
33+
// eslint.config.js
34+
import react from 'eslint-plugin-react'
35+
36+
export default tseslint.config({
37+
// Set the react version
38+
settings: { react: { version: '18.3' } },
39+
plugins: {
40+
// Add the react plugin
41+
react,
42+
},
43+
rules: {
44+
// other rules...
45+
// Enable its recommended rules
46+
...react.configs.recommended.rules,
47+
...react.configs['jsx-runtime'].rules,
48+
},
49+
})
50+
```
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"$schema": "https://ui.shadcn.com/schema.json",
3+
"style": "new-york",
4+
"rsc": false,
5+
"tsx": true,
6+
"tailwind": {
7+
"config": "tailwind.config.js",
8+
"css": "src/index.css",
9+
"baseColor": "neutral",
10+
"cssVariables": true,
11+
"prefix": ""
12+
},
13+
"aliases": {
14+
"components": "@/components",
15+
"utils": "@/lib/utils",
16+
"ui": "@/components/ui",
17+
"lib": "@/lib",
18+
"hooks": "@/hooks"
19+
}
20+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>Vite + React + TS</title>
8+
</head>
9+
<body>
10+
<div id="root"></div>
11+
<script type="module" src="/src/main.tsx"></script>
12+
</body>
13+
</html>
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"name": "privy-login-example",
3+
"private": true,
4+
"version": "0.0.0",
5+
"type": "module",
6+
"scripts": {
7+
"dev": "vite --force",
8+
"preview": "vite preview",
9+
"typesync": "hypergraph typesync"
10+
},
11+
"dependencies": {
12+
"@graphprotocol/grc-20": "^0.24.1",
13+
"@graphprotocol/hypergraph": "workspace:*",
14+
"@graphprotocol/hypergraph-react": "workspace:*",
15+
"@noble/hashes": "^1.8.0",
16+
"@privy-io/react-auth": "^2.21.4",
17+
"@radix-ui/react-avatar": "^1.1.10",
18+
"@radix-ui/react-icons": "^1.3.2",
19+
"@radix-ui/react-label": "^2.1.7",
20+
"@radix-ui/react-slot": "^1.2.3",
21+
"@tanstack/react-query": "^5.85.5",
22+
"@tanstack/react-router": "^1.131.27",
23+
"@tanstack/react-router-devtools": "^1.131.27",
24+
"@xstate/store": "^3.9.2",
25+
"class-variance-authority": "^0.7.1",
26+
"clsx": "^2.1.1",
27+
"effect": "^3.17.9",
28+
"framer-motion": "^12.23.12",
29+
"graphql-request": "^7.2.0",
30+
"isomorphic-ws": "^5.0.0",
31+
"lucide-react": "^0.541.0",
32+
"react": "^19.1.1",
33+
"react-dom": "^19.1.1",
34+
"react-select": "^5.10.2",
35+
"siwe": "^3.0.0",
36+
"tailwind-merge": "^3.3.1",
37+
"tailwindcss-animate": "^1.0.7",
38+
"uuid": "^11.1.0",
39+
"viem": "^2.34.0",
40+
"vite": "^7.1.3"
41+
},
42+
"devDependencies": {
43+
"@biomejs/biome": "2.2.0",
44+
"@tailwindcss/vite": "^4.1.12",
45+
"@tanstack/router-plugin": "^1.131.27",
46+
"@types/node": "^24.3.0",
47+
"@types/react": "^19.1.10",
48+
"@types/react-dom": "^19.1.7",
49+
"@types/uuid": "^10.0.0",
50+
"@vitejs/plugin-react": "^5.0.1",
51+
"globals": "^16.3.0",
52+
"tailwindcss": "^4.1.12"
53+
}
54+
}
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { HypergraphAppProvider } from '@graphprotocol/hypergraph-react';
2+
import { PrivyProvider } from '@privy-io/react-auth';
3+
import { createRouter, RouterProvider } from '@tanstack/react-router';
4+
import { mapping } from './mapping.js';
5+
import { routeTree } from './routeTree.gen';
6+
7+
// Create a new router instance
8+
const router = createRouter({ routeTree });
9+
10+
// Register the router instance for type safety
11+
declare module '@tanstack/react-router' {
12+
interface Register {
13+
router: typeof router;
14+
}
15+
}
16+
17+
export function Boot() {
18+
return (
19+
<PrivyProvider
20+
appId={import.meta.env.VITE_PRIVY_APP_ID}
21+
config={{
22+
loginMethods: ['email', 'google'],
23+
appearance: {
24+
theme: 'light',
25+
accentColor: '#6833ff',
26+
},
27+
embeddedWallets: {
28+
createOnLogin: 'users-without-wallets',
29+
},
30+
}}
31+
>
32+
<HypergraphAppProvider
33+
syncServerUri="http://localhost:3030"
34+
mapping={mapping}
35+
appId="93bb8907-085a-4a0e-83dd-62b0dc98e793"
36+
>
37+
<RouterProvider router={router} />
38+
</HypergraphAppProvider>
39+
</PrivyProvider>
40+
);
41+
}

0 commit comments

Comments
 (0)