From 6491a6409b1914584b607998f5c22dd860938139 Mon Sep 17 00:00:00 2001 From: Anouk Date: Thu, 22 Jan 2026 18:39:36 -0600 Subject: [PATCH 1/6] feat: integrate social login with Stellar Account Abstraction SDK --- apps/web/.env.example | 14 +- apps/web/package.json | 1 + .../app/dashboard/tenant-dashboard/page.tsx | 17 + apps/web/src/app/layout.tsx | 5 + apps/web/src/app/login/page.tsx | 176 +- apps/web/src/app/register/page.tsx | 25 +- apps/web/src/app/tenant-dashboard/page.tsx | 15 + .../src/components/auth/FreighterFallback.tsx | 180 ++ .../src/components/auth/SocialLoginButton.tsx | 211 +++ apps/web/src/components/layout/Navbar.tsx | 40 +- .../hooks/auth/__tests__/use-auth.test.tsx | 303 ++++ apps/web/src/hooks/auth/procted-route.tsx | 20 +- apps/web/src/hooks/auth/use-auth.tsx | 481 +++-- apps/web/src/hooks/useUserRole.tsx | 50 +- apps/web/src/lib/stellar-social-sdk.ts | 10 + apps/web/src/types/auth.ts | 107 ++ apps/web/stellar-social-sdk/package-lock.json | 1616 +++++++++++++++++ apps/web/stellar-social-sdk/package.json | 34 + .../stellar-social-sdk/package.json.backup | 16 + apps/web/stellar-social-sdk/rollup.config.js | 41 + .../src/auth/StellarSocialAccount.ts | 135 ++ apps/web/stellar-social-sdk/src/config.ts | 3 + apps/web/stellar-social-sdk/src/index.ts | 390 ++++ .../stellar-social-sdk/src/index.ts.backup | 299 +++ .../stellar-social-sdk/src/index.ts.corrupted | 390 ++++ .../src/providers/FreighterProvider.ts | 83 + .../src/providers/GoogleAuthProvider.ts | 204 +++ .../web/stellar-social-sdk/src/types/index.ts | 43 + .../stellar-social-sdk/src/utils/crypto.ts | 60 + apps/web/stellar-social-sdk/test-quick.js | 44 + apps/web/stellar-social-sdk/tsconfig.json | 17 + apps/web/tsconfig.json | 3 +- 32 files changed, 4712 insertions(+), 321 deletions(-) create mode 100644 apps/web/src/components/auth/FreighterFallback.tsx create mode 100644 apps/web/src/components/auth/SocialLoginButton.tsx create mode 100644 apps/web/src/hooks/auth/__tests__/use-auth.test.tsx create mode 100644 apps/web/src/lib/stellar-social-sdk.ts create mode 100644 apps/web/src/types/auth.ts create mode 100644 apps/web/stellar-social-sdk/package-lock.json create mode 100644 apps/web/stellar-social-sdk/package.json create mode 100644 apps/web/stellar-social-sdk/package.json.backup create mode 100644 apps/web/stellar-social-sdk/rollup.config.js create mode 100644 apps/web/stellar-social-sdk/src/auth/StellarSocialAccount.ts create mode 100644 apps/web/stellar-social-sdk/src/config.ts create mode 100644 apps/web/stellar-social-sdk/src/index.ts create mode 100644 apps/web/stellar-social-sdk/src/index.ts.backup create mode 100644 apps/web/stellar-social-sdk/src/index.ts.corrupted create mode 100644 apps/web/stellar-social-sdk/src/providers/FreighterProvider.ts create mode 100644 apps/web/stellar-social-sdk/src/providers/GoogleAuthProvider.ts create mode 100644 apps/web/stellar-social-sdk/src/types/index.ts create mode 100644 apps/web/stellar-social-sdk/src/utils/crypto.ts create mode 100644 apps/web/stellar-social-sdk/test-quick.js create mode 100644 apps/web/stellar-social-sdk/tsconfig.json diff --git a/apps/web/.env.example b/apps/web/.env.example index 4ae2ec1b..260f0128 100644 --- a/apps/web/.env.example +++ b/apps/web/.env.example @@ -1,4 +1,14 @@ -NEXT_PUBLIC_STELLAR_NETWORK= +# Stellar Network Configuration +NEXT_PUBLIC_STELLAR_NETWORK=testnet NEXT_PUBLIC_USDC_ISSUER_TESTNET= NEXT_PUBLIC_USDC_ISSUER_MAINNET= -NEXT_PUBLIC_API_URL= \ No newline at end of file + +# API Configuration +NEXT_PUBLIC_API_URL=http://localhost:3001/api + +# Stellar Social Login SDK Configuration +# Get your Google Client ID from: https://console.cloud.google.com/apis/credentials +NEXT_PUBLIC_GOOGLE_CLIENT_ID=your_google_client_id_here + +# Soroban Contract ID for Social Wallet +NEXT_PUBLIC_CONTRACT_ID=CALZGCSB3P3WEBLW3QTF5Y4WEALEVTYUYBC7KBGQ266GDINT7U4E74KW diff --git a/apps/web/package.json b/apps/web/package.json index e2af0336..8ad2fd90 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -12,6 +12,7 @@ "test:e2e:headed": "playwright test --headed" }, "dependencies": { + "stellar-social-sdk": "file:./stellar-social-sdk", "@hookform/resolvers": "^3.3.4", "@radix-ui/react-dialog": "^1.1.14", "@radix-ui/react-dropdown-menu": "^2.1.12", diff --git a/apps/web/src/app/dashboard/tenant-dashboard/page.tsx b/apps/web/src/app/dashboard/tenant-dashboard/page.tsx index 5c4af42a..eed0f86a 100644 --- a/apps/web/src/app/dashboard/tenant-dashboard/page.tsx +++ b/apps/web/src/app/dashboard/tenant-dashboard/page.tsx @@ -25,6 +25,7 @@ import { Filter, Home, Info, + LogOut, MapPin, MessageSquare, PieChart, @@ -41,8 +42,10 @@ import { XCircle, } from 'lucide-react'; import Image from 'next/image'; +import { useRouter } from 'next/navigation'; import type React from 'react'; import { useEffect, useState } from 'react'; +import { useAuth } from '~/hooks/auth/use-auth'; interface Booking { id: string; @@ -187,6 +190,8 @@ const mockTransactions = [ ]; const TenantDashboard = () => { + const router = useRouter(); + const { logout } = useAuth(); const [activeTab, setActiveTab] = useState('bookings'); const [bookings, setBookings] = useState(mockBookings); const [user, setUser] = useState(mockUser); @@ -360,6 +365,18 @@ const TenantDashboard = () => { {user.name} + diff --git a/apps/web/src/app/layout.tsx b/apps/web/src/app/layout.tsx index 2b6949d2..81018e81 100644 --- a/apps/web/src/app/layout.tsx +++ b/apps/web/src/app/layout.tsx @@ -20,6 +20,11 @@ export default function RootLayout({ + +