diff --git a/apps/dispatch/package.json b/apps/dispatch/package.json index 1712528d..f1f4e109 100644 --- a/apps/dispatch/package.json +++ b/apps/dispatch/package.json @@ -4,7 +4,7 @@ "type": "module", "private": true, "scripts": { - "dev": "next dev --turbopack", + "dev": "next dev --turbopack -p 3001", "build": "next build", "start": "next start", "lint": "next lint --max-warnings 0", diff --git a/apps/docs/package.json b/apps/docs/package.json index d1c44ffe..6c71892e 100644 --- a/apps/docs/package.json +++ b/apps/docs/package.json @@ -4,7 +4,7 @@ "type": "module", "private": true, "scripts": { - "dev": "next dev --turbopack", + "dev": "next dev --turbopack -p 4000", "build": "next build", "start": "next start", "lint": "next lint --max-warnings 0", diff --git a/apps/hub/.env.example b/apps/hub/.env.example index 6db16334..e192ae75 100644 --- a/apps/hub/.env.example +++ b/apps/hub/.env.example @@ -1,3 +1,3 @@ -NEXTAUTH_URL=http://localhost:3002 +NEXTAUTH_URL=http://localhost:3000 NEXTAUTH_SECRET=dsadsadsa DATABASE_URL=postgresql://persistant-data:persistant-data-pw@localhost:5432/var \ No newline at end of file diff --git a/apps/hub/app/(auth)/layout.tsx b/apps/hub/app/(auth)/layout.tsx new file mode 100644 index 00000000..a377d687 --- /dev/null +++ b/apps/hub/app/(auth)/layout.tsx @@ -0,0 +1,27 @@ +import { NextPage } from 'next'; +import { ReactNode } from 'react'; + +const AuthLayout: NextPage< + Readonly<{ + children: React.ReactNode; + }> +> = ({ children }) => ( +
+
+
+
+
+ {children} +
+
+
+
+); + +export default AuthLayout; diff --git a/apps/hub/app/(auth)/login/_components/Login.tsx b/apps/hub/app/(auth)/login/_components/Login.tsx index 7cc50bfe..b96b6da7 100644 --- a/apps/hub/app/(auth)/login/_components/Login.tsx +++ b/apps/hub/app/(auth)/login/_components/Login.tsx @@ -7,13 +7,12 @@ import { useForm } from 'react-hook-form'; import { Toaster, toast } from 'react-hot-toast'; import { z } from 'zod'; - export const Login = () => { const [isLoading, setIsLoading] = useState(false); const schema = z.object({ email: z.string().email(), - password: z.string().min(6), + password: z.string(), }); type schemaType = z.infer; @@ -28,29 +27,25 @@ export const Login = () => { onSubmit={form.handleSubmit(async () => { setIsLoading(true); const data = await signIn('credentials', { - redirect: false, + callbackUrl: '/', email: form.getValues('email'), password: form.getValues('password'), }); if (!data || data.error) { - toast.error("E-Mail / Passwort ist falsch!", - { - style: { - background: 'var(--fallback-b1, oklch(var(--b1) / var(--tw-bg-opacity, 1)))', - color: 'var(--fallback-nc, oklch(var(--nc) / var(--tw-text-opacity, 1)))' - } - } - ) + toast.error('E-Mail / Passwort ist falsch!', { + style: { + background: + 'var(--fallback-b1, oklch(var(--b1) / var(--tw-bg-opacity, 1)))', + color: + 'var(--fallback-nc, oklch(var(--nc) / var(--tw-text-opacity, 1)))', + }, + }); } - console.log(data); setIsLoading(false); })} >
- +

Login

@@ -60,55 +55,60 @@ export const Login = () => { +

+ {typeof form.formState.errors.email?.message === 'string' + ? form.formState.errors.email.message + : ''} +

+ + +
- -
+ + ); }; diff --git a/apps/hub/app/(auth)/login/page.tsx b/apps/hub/app/(auth)/login/page.tsx index 003ec21a..2e247e5c 100644 --- a/apps/hub/app/(auth)/login/page.tsx +++ b/apps/hub/app/(auth)/login/page.tsx @@ -2,23 +2,8 @@ import { Login } from './_components/Login'; export default async () => { return ( - <> -
-
-
-
-
- -
-
-
-
- - ); + <> + + + ); }; diff --git a/apps/hub/app/(auth)/logout/page.tsx b/apps/hub/app/(auth)/logout/page.tsx index 7b0cbbe4..8214e355 100644 --- a/apps/hub/app/(auth)/logout/page.tsx +++ b/apps/hub/app/(auth)/logout/page.tsx @@ -9,7 +9,7 @@ export default () => { }); }, []); return ( -
+

logging out...

); diff --git a/apps/hub/app/(auth)/oauth/_components/Authorize.tsx b/apps/hub/app/(auth)/oauth/_components/Authorize.tsx new file mode 100644 index 00000000..22b5085b --- /dev/null +++ b/apps/hub/app/(auth)/oauth/_components/Authorize.tsx @@ -0,0 +1,43 @@ +'use client'; +import { useSearchParams } from 'next/navigation'; +import { Service } from '../page'; +import { generateToken } from './action'; + +export const Authorize = ({ service }: { service: Service }) => { + const searchParams = useSearchParams(); + const legitimeUrl = service.approvedUrls.some((url) => + searchParams.get('redirect_uri')?.startsWith(url) + ); + if (!legitimeUrl) + return ( +
+

Unerlaubter Zugriff

+

Du greifst von einem ncith genehmigtem Server auf diese URL zu

+
+ ); + + return ( +
e.preventDefault()}> +

Zugriff zulassen

+

+ Die Anwendung {service.name} möchte auf deine Daten + zugreifen. +

+
+ + +
+
+ ); +}; diff --git a/apps/hub/app/(auth)/oauth/_components/action.ts b/apps/hub/app/(auth)/oauth/_components/action.ts new file mode 100644 index 00000000..52204e89 --- /dev/null +++ b/apps/hub/app/(auth)/oauth/_components/action.ts @@ -0,0 +1,24 @@ +'use server'; +import { getServerSession } from '../../../api/auth/[...nextauth]/auth'; +import { Service } from '../page'; +import { PrismaClient } from '@repo/db'; + +const prisma = new PrismaClient(); + +export const generateToken = async (service: Service) => { + const session = await getServerSession(); + if (!session) return null; + + const accessToken = Array.from({ length: 10 }, () => + Math.floor(Math.random() * 10) + ).join(''); + + const code = await prisma.oAuthToken.create({ + data: { + clientId: service.id, + userId: session.user.id, + accessToken: accessToken, + }, + }); + return code; +}; diff --git a/apps/hub/app/(auth)/oauth/page.tsx b/apps/hub/app/(auth)/oauth/page.tsx new file mode 100644 index 00000000..f14951cb --- /dev/null +++ b/apps/hub/app/(auth)/oauth/page.tsx @@ -0,0 +1,26 @@ +import { Authorize } from './_components/Authorize'; + +export const services = [ + { + id: '123456', + service: 'dispatch', + name: 'Leitstellendisposition', + approvedUrls: ['http://localhost:3001'], + }, +]; +export type Service = (typeof services)[number]; + +export default async ({ + searchParams, +}: { + searchParams: Promise<{ [key: string]: string | string[] | undefined }>; +}) => { + const { service: serviceId } = await searchParams; + const service = services.find((service) => service.id === serviceId); + + if (!service) { + return
Service not found
; + } + + return ; +}; diff --git a/apps/hub/app/(auth)/register/_components/Register.tsx b/apps/hub/app/(auth)/register/_components/Register.tsx index e32b815a..79eb42bc 100644 --- a/apps/hub/app/(auth)/register/_components/Register.tsx +++ b/apps/hub/app/(auth)/register/_components/Register.tsx @@ -17,8 +17,8 @@ export const Register = () => { }), firstname: z.string().min(2).max(30), lastname: z.string().min(2).max(30), - password: z.string().min(6), - passwordConfirm: z.string().min(6), + password: z.string(), + passwordConfirm: z.string(), }) .superRefine(({ password, passwordConfirm }, ctx) => { if (password !== passwordConfirm) { diff --git a/apps/hub/app/(auth)/register/page.tsx b/apps/hub/app/(auth)/register/page.tsx index fc233e56..7fbb5823 100644 --- a/apps/hub/app/(auth)/register/page.tsx +++ b/apps/hub/app/(auth)/register/page.tsx @@ -3,22 +3,7 @@ import { Register } from './_components/Register'; export default () => { return ( <> -
-
-
-
-
- -
-
-
-
+ ); }; diff --git a/apps/hub/app/api/auth/[...nextauth]/auth.ts b/apps/hub/app/api/auth/[...nextauth]/auth.ts index 8d5c2de4..adf76e45 100644 --- a/apps/hub/app/api/auth/[...nextauth]/auth.ts +++ b/apps/hub/app/api/auth/[...nextauth]/auth.ts @@ -1,4 +1,7 @@ -import { AuthOptions } from 'next-auth'; +import { + AuthOptions, + getServerSession as getNextAuthServerSession, +} from 'next-auth'; import { PrismaAdapter } from '@next-auth/prisma-adapter'; import Credentials from 'next-auth/providers/credentials'; import { PrismaClient } from '@prisma/client'; @@ -29,40 +32,28 @@ export const options: AuthOptions = { }, }), ], - secret: process.env.SECRET, + secret: process.env.NEXTAUTH_SECRET, session: { strategy: 'jwt', maxAge: 30 * 24 * 60 * 60, }, adapter: PrismaAdapter(prisma), - events: { - async signIn(message) { - console.log('Signed in!', { message }); - }, - async signOut(message) { - console.log('Signed out!', { message }); - }, - async createUser(message) { - console.log('User created!', { message }); - }, - }, callbacks: { jwt: async ({ token, user }) => { - if (user) { - token.uid = user; + if (user && 'firstname' in user) { + return { + ...token, + ...user, + }; } - return token; }, - session: async ({ session, token }: any) => { - // here we put session.useData and put inside it whatever you want to be in the session - // here try to console.log(token) and see what it will have - // sometimes the user get stored in token.uid.userData - // sometimes the user data get stored in just token.uid - session.userData = token.uid.userData; - - return session; + session: async ({ session, user, token }) => { + return { + ...session, + user: token, + }; }, }, pages: { @@ -72,3 +63,5 @@ export const options: AuthOptions = { newUser: '/register', }, } satisfies AuthOptions; + +export const getServerSession = async () => getNextAuthServerSession(options); diff --git a/apps/hub/app/layout.tsx b/apps/hub/app/layout.tsx index 704e53eb..fb573531 100644 --- a/apps/hub/app/layout.tsx +++ b/apps/hub/app/layout.tsx @@ -3,6 +3,7 @@ import { Geist, Geist_Mono } from 'next/font/google'; import './globals.css'; import { getServerSession } from 'next-auth'; import { NextAuthSessionProvider } from './_components/AuthSessionProvider'; +import { options } from './api/auth/[...nextauth]/auth'; const geistSans = Geist({ variable: '--font-geist-sans', @@ -24,8 +25,7 @@ export default async function RootLayout({ }: Readonly<{ children: React.ReactNode; }>) { - const session = await getServerSession(); - + const session = await getServerSession(options); return ( diff --git a/apps/hub/app/page.tsx b/apps/hub/app/page.tsx index 005f2119..5ebfaa09 100644 --- a/apps/hub/app/page.tsx +++ b/apps/hub/app/page.tsx @@ -1,11 +1,11 @@ 'use client'; import { useSession } from 'next-auth/react'; +import Link from 'next/link'; import { useEffect } from 'react'; export default function Home() { - const { data: session, status, update } = useSession(); - console.log(session, status); + const { data: session, update } = useSession(); useEffect(() => { update(); }, []); @@ -14,6 +14,9 @@ export default function Home() {

Hub

{!session &&

Not signed in

} {session?.user?.firstname &&

Hi, {session?.user?.firstname}

} + + +
); } diff --git a/apps/hub/package.json b/apps/hub/package.json index 5fac5fc1..fb81eb92 100644 --- a/apps/hub/package.json +++ b/apps/hub/package.json @@ -3,7 +3,7 @@ "version": "0.1.0", "private": true, "scripts": { - "dev": "next dev --turbopack", + "dev": "next dev --turbopack -p 3000", "build": "next build", "start": "next start", "lint": "next lint" diff --git a/apps/hub/types/next-auth.d.ts b/apps/hub/types/next-auth.d.ts index b3d42874..fe26fc6f 100644 --- a/apps/hub/types/next-auth.d.ts +++ b/apps/hub/types/next-auth.d.ts @@ -1,18 +1,19 @@ import NextAuth from 'next-auth'; -import { User } from '@repo/db'; +import { User as IUser } from '@repo/db'; declare module 'next-auth' { /** * Returned by `useSession`, `getSession` and received as a prop on the `SessionProvider` React Context */ interface Session { - user: User; + user: IUser; } - type User = User; + type User = IUser; } declare module 'next-auth/jwt' { interface JWT { + uid: string; firstname: string; lastname: string; email: string; diff --git a/package-lock.json b/package-lock.json index d5ce9e16..b360be6c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,6 +18,68 @@ "node": ">=18" } }, + "apps/dispatch": { + "version": "0.1.0", + "dependencies": { + "@repo/ui": "*", + "@tailwindcss/postcss": "^4.0.2", + "next": "^15.1.0", + "postcss": "^8.5.1", + "react": "^19.0.0", + "react-dom": "^19.0.0", + "tailwindcss": "^4.0.2" + }, + "devDependencies": { + "@repo/eslint-config": "*", + "@repo/typescript-config": "*", + "@types/node": "^20", + "@types/react": "18.3.1", + "@types/react-dom": "18.3.0", + "daisyui": "^5.0.0-beta.6", + "typescript": "5.5.4" + } + }, + "apps/dispatch/node_modules/daisyui": { + "version": "5.0.0-beta.6", + "resolved": "https://registry.npmjs.org/daisyui/-/daisyui-5.0.0-beta.6.tgz", + "integrity": "sha512-gwXHv6MApRBrvUayzg83vS6bfZ+y7/1VGLu0a8/cEAMviS4rXLCd4AndEdlVxhq+25wkAp0CZRkNQ7O4wIoFnQ==", + "dev": true, + "funding": { + "url": "https://github.com/saadeghi/daisyui?sponsor=1" + } + }, + "apps/dispatch/node_modules/postcss": { + "version": "8.5.1", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.1.tgz", + "integrity": "sha512-6oz2beyjc5VMn/KV1pPw8fliQkhBXrVn1Z3TVyqZxU8kZpzEKhBdmCFqI6ZbmGtamQvQGuU1sgPTk8ZrXDD7jQ==", + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "dependencies": { + "nanoid": "^3.3.8", + "picocolors": "^1.1.1", + "source-map-js": "^1.2.1" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, + "apps/dispatch/node_modules/tailwindcss": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-4.0.3.tgz", + "integrity": "sha512-ImmZF0Lon5RrQpsEAKGxRvHwCvMgSC4XVlFRqmbzTEDb/3wvin9zfEZrMwgsa3yqBbPqahYcVI6lulM2S7IZAA==" + }, "apps/docs": { "version": "0.1.0", "dependencies": { @@ -86,28 +148,10 @@ "@types/react": "^19.0.0" } }, - "apps/dispatch": { - "version": "0.1.0", - "dependencies": { - "@repo/ui": "*", - "next": "^15.1.0", - "react": "^19.0.0", - "react-dom": "^19.0.0" - }, - "devDependencies": { - "@repo/eslint-config": "*", - "@repo/typescript-config": "*", - "@types/node": "^20", - "@types/react": "18.3.1", - "@types/react-dom": "18.3.0", - "typescript": "5.5.4" - } - }, "node_modules/@alloc/quick-lru": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/@alloc/quick-lru/-/quick-lru-5.2.0.tgz", "integrity": "sha512-UrcABB+4bUrFABwbluTIBErXwvbsU/V7TZWfmbgJfbkwiBuziS9gxdODUyuiecfdGQ85jglMW6juS3+z5TsKLw==", - "dev": true, "engines": { "node": ">=10" }, @@ -1163,6 +1207,260 @@ "tslib": "^2.8.0" } }, + "node_modules/@tailwindcss/node": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/@tailwindcss/node/-/node-4.0.3.tgz", + "integrity": "sha512-QsVJokOl0pJ4AbJV33D2npvLcHGPWi5MOSZtrtE0GT3tSx+3D0JE2lokLA8yHS1x3oCY/3IyRyy7XX6tmzid7A==", + "dependencies": { + "enhanced-resolve": "^5.18.0", + "jiti": "^2.4.2", + "tailwindcss": "4.0.3" + } + }, + "node_modules/@tailwindcss/node/node_modules/jiti": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/jiti/-/jiti-2.4.2.tgz", + "integrity": "sha512-rg9zJN+G4n2nfJl5MW3BMygZX56zKPNVEYYqq7adpmMh4Jn2QNEwhvQlFy6jPVdcod7txZtKHWnyZiA3a0zP7A==", + "bin": { + "jiti": "lib/jiti-cli.mjs" + } + }, + "node_modules/@tailwindcss/node/node_modules/tailwindcss": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-4.0.3.tgz", + "integrity": "sha512-ImmZF0Lon5RrQpsEAKGxRvHwCvMgSC4XVlFRqmbzTEDb/3wvin9zfEZrMwgsa3yqBbPqahYcVI6lulM2S7IZAA==" + }, + "node_modules/@tailwindcss/oxide": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide/-/oxide-4.0.3.tgz", + "integrity": "sha512-FFcp3VNvRjjmFA39ORM27g2mbflMQljhvM7gxBAujHxUy4LXlKa6yMF9wbHdTbPqTONiCyyOYxccvJyVyI/XBg==", + "engines": { + "node": ">= 10" + }, + "optionalDependencies": { + "@tailwindcss/oxide-android-arm64": "4.0.3", + "@tailwindcss/oxide-darwin-arm64": "4.0.3", + "@tailwindcss/oxide-darwin-x64": "4.0.3", + "@tailwindcss/oxide-freebsd-x64": "4.0.3", + "@tailwindcss/oxide-linux-arm-gnueabihf": "4.0.3", + "@tailwindcss/oxide-linux-arm64-gnu": "4.0.3", + "@tailwindcss/oxide-linux-arm64-musl": "4.0.3", + "@tailwindcss/oxide-linux-x64-gnu": "4.0.3", + "@tailwindcss/oxide-linux-x64-musl": "4.0.3", + "@tailwindcss/oxide-win32-arm64-msvc": "4.0.3", + "@tailwindcss/oxide-win32-x64-msvc": "4.0.3" + } + }, + "node_modules/@tailwindcss/oxide-android-arm64": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-android-arm64/-/oxide-android-arm64-4.0.3.tgz", + "integrity": "sha512-S8XOTQuMnpijZRlPm5HBzPJjZ28quB+40LSRHjRnQF6rRYKsvpr1qkY7dfwsetNdd+kMLOMDsvmuT8WnqqETvg==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@tailwindcss/oxide-darwin-arm64": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-darwin-arm64/-/oxide-darwin-arm64-4.0.3.tgz", + "integrity": "sha512-smrY2DpzhXvgDhZtQlYAl8+vxJ04lv2/64C1eiRxvsRT2nkw/q+zA1/eAYKvUHat6cIuwqDku3QucmrUT6pCeg==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@tailwindcss/oxide-darwin-x64": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-darwin-x64/-/oxide-darwin-x64-4.0.3.tgz", + "integrity": "sha512-NTz8x/LcGUjpZAWUxz0ZuzHao90Wj9spoQgomwB+/hgceh5gcJDfvaBYqxLFpKzVglpnbDSq1Fg0p0zI4oa5Pg==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@tailwindcss/oxide-freebsd-x64": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-freebsd-x64/-/oxide-freebsd-x64-4.0.3.tgz", + "integrity": "sha512-yQc9Q0JCOp3kkAV8gKgDctXO60IkQhHpqGB+KgOccDtD5UmN6Q5+gd+lcsDyQ7N8dRuK1fAud51xQpZJgKfm7g==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@tailwindcss/oxide-linux-arm-gnueabihf": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-arm-gnueabihf/-/oxide-linux-arm-gnueabihf-4.0.3.tgz", + "integrity": "sha512-e1ivVMLSnxTOU1O3npnxN16FEyWM/g3SuH2pP6udxXwa0/SnSAijRwcAYRpqIlhVKujr158S8UeHxQjC4fGl4w==", + "cpu": [ + "arm" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@tailwindcss/oxide-linux-arm64-gnu": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-arm64-gnu/-/oxide-linux-arm64-gnu-4.0.3.tgz", + "integrity": "sha512-PLrToqQqX6sdJ9DmMi8IxZWWrfjc9pdi9AEEPTrtMts3Jm9HBi1WqEeF1VwZZ2aW9TXloE5OwA35zuuq1Bhb/Q==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@tailwindcss/oxide-linux-arm64-musl": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-arm64-musl/-/oxide-linux-arm64-musl-4.0.3.tgz", + "integrity": "sha512-YlzRxx7N1ampfgSKzEDw0iwDkJXUInR4cgNEqmR4TzHkU2Vhg59CGPJrTI7dxOBofD8+O35R13Nk9Ytyv0JUFg==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@tailwindcss/oxide-linux-x64-gnu": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-x64-gnu/-/oxide-linux-x64-gnu-4.0.3.tgz", + "integrity": "sha512-Xfc3z/li6XkuD7Hs+Uk6pjyCXnfnd9zuQTKOyDTZJ544xc2yoMKUkuDw6Et9wb31MzU2/c0CIUpTDa71lL9KHw==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@tailwindcss/oxide-linux-x64-musl": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-x64-musl/-/oxide-linux-x64-musl-4.0.3.tgz", + "integrity": "sha512-ugKVqKzwa/cjmqSQG17aS9DYrEcQ/a5NITcgmOr3JLW4Iz64C37eoDlkC8tIepD3S/Td/ywKAolTQ8fKbjEL4g==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@tailwindcss/oxide-win32-arm64-msvc": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-win32-arm64-msvc/-/oxide-win32-arm64-msvc-4.0.3.tgz", + "integrity": "sha512-qHPDMl+UUwsk1RMJMgAXvhraWqUUT+LR/tkXix5RA39UGxtTrHwsLIN1AhNxI5i2RFXAXfmFXDqZCdyQ4dWmAQ==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@tailwindcss/oxide-win32-x64-msvc": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-win32-x64-msvc/-/oxide-win32-x64-msvc-4.0.3.tgz", + "integrity": "sha512-+ujwN4phBGyOsPyLgGgeCyUm4Mul+gqWVCIGuSXWgrx9xVUnf6LVXrw0BDBc9Aq1S2qMyOTX4OkCGbZeoIo8Qw==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@tailwindcss/postcss": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/@tailwindcss/postcss/-/postcss-4.0.3.tgz", + "integrity": "sha512-qUyxuhuI2eTgRJ+qfCQRAr69Cw7BdSz+PoNFUNoRuhPjikNC8+sxK+Mi/chaXAXewjv/zbf6if6z6ItVLh+e9Q==", + "dependencies": { + "@alloc/quick-lru": "^5.2.0", + "@tailwindcss/node": "^4.0.3", + "@tailwindcss/oxide": "^4.0.3", + "lightningcss": "^1.29.1", + "postcss": "^8.4.41", + "tailwindcss": "4.0.3" + } + }, + "node_modules/@tailwindcss/postcss/node_modules/postcss": { + "version": "8.5.1", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.1.tgz", + "integrity": "sha512-6oz2beyjc5VMn/KV1pPw8fliQkhBXrVn1Z3TVyqZxU8kZpzEKhBdmCFqI6ZbmGtamQvQGuU1sgPTk8ZrXDD7jQ==", + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "dependencies": { + "nanoid": "^3.3.8", + "picocolors": "^1.1.1", + "source-map-js": "^1.2.1" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, + "node_modules/@tailwindcss/postcss/node_modules/tailwindcss": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-4.0.3.tgz", + "integrity": "sha512-ImmZF0Lon5RrQpsEAKGxRvHwCvMgSC4XVlFRqmbzTEDb/3wvin9zfEZrMwgsa3yqBbPqahYcVI6lulM2S7IZAA==" + }, "node_modules/@tootallnate/quickjs-emscripten": { "version": "0.23.0", "resolved": "https://registry.npmjs.org/@tootallnate/quickjs-emscripten/-/quickjs-emscripten-0.23.0.tgz", @@ -2658,6 +2956,10 @@ "node": ">=8" } }, + "node_modules/dispatch": { + "resolved": "apps/dispatch", + "link": true + }, "node_modules/dlv": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/dlv/-/dlv-1.1.3.tgz", @@ -2728,7 +3030,6 @@ "version": "5.18.0", "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.18.0.tgz", "integrity": "sha512-0/r0MySGYG8YqlayBZ6MuCfECmHFdJ5qyPh8s8wa5Hnm6SaFLSK1VYCbj+NKp090Nm1caZhD+QTnmxO7esYGyQ==", - "dev": true, "dependencies": { "graceful-fs": "^4.2.4", "tapable": "^2.2.0" @@ -4086,8 +4387,7 @@ "node_modules/graceful-fs": { "version": "4.2.11", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", - "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==", - "dev": true + "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==" }, "node_modules/gradient-string": { "version": "2.0.2", @@ -5247,6 +5547,234 @@ "node": ">= 0.8.0" } }, + "node_modules/lightningcss": { + "version": "1.29.1", + "resolved": "https://registry.npmjs.org/lightningcss/-/lightningcss-1.29.1.tgz", + "integrity": "sha512-FmGoeD4S05ewj+AkhTY+D+myDvXI6eL27FjHIjoyUkO/uw7WZD1fBVs0QxeYWa7E17CUHJaYX/RUGISCtcrG4Q==", + "dependencies": { + "detect-libc": "^1.0.3" + }, + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + }, + "optionalDependencies": { + "lightningcss-darwin-arm64": "1.29.1", + "lightningcss-darwin-x64": "1.29.1", + "lightningcss-freebsd-x64": "1.29.1", + "lightningcss-linux-arm-gnueabihf": "1.29.1", + "lightningcss-linux-arm64-gnu": "1.29.1", + "lightningcss-linux-arm64-musl": "1.29.1", + "lightningcss-linux-x64-gnu": "1.29.1", + "lightningcss-linux-x64-musl": "1.29.1", + "lightningcss-win32-arm64-msvc": "1.29.1", + "lightningcss-win32-x64-msvc": "1.29.1" + } + }, + "node_modules/lightningcss-darwin-arm64": { + "version": "1.29.1", + "resolved": "https://registry.npmjs.org/lightningcss-darwin-arm64/-/lightningcss-darwin-arm64-1.29.1.tgz", + "integrity": "sha512-HtR5XJ5A0lvCqYAoSv2QdZZyoHNttBpa5EP9aNuzBQeKGfbyH5+UipLWvVzpP4Uml5ej4BYs5I9Lco9u1fECqw==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-darwin-x64": { + "version": "1.29.1", + "resolved": "https://registry.npmjs.org/lightningcss-darwin-x64/-/lightningcss-darwin-x64-1.29.1.tgz", + "integrity": "sha512-k33G9IzKUpHy/J/3+9MCO4e+PzaFblsgBjSGlpAaFikeBFm8B/CkO3cKU9oI4g+fjS2KlkLM/Bza9K/aw8wsNA==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-freebsd-x64": { + "version": "1.29.1", + "resolved": "https://registry.npmjs.org/lightningcss-freebsd-x64/-/lightningcss-freebsd-x64-1.29.1.tgz", + "integrity": "sha512-0SUW22fv/8kln2LnIdOCmSuXnxgxVC276W5KLTwoehiO0hxkacBxjHOL5EtHD8BAXg2BvuhsJPmVMasvby3LiQ==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-arm-gnueabihf": { + "version": "1.29.1", + "resolved": "https://registry.npmjs.org/lightningcss-linux-arm-gnueabihf/-/lightningcss-linux-arm-gnueabihf-1.29.1.tgz", + "integrity": "sha512-sD32pFvlR0kDlqsOZmYqH/68SqUMPNj+0pucGxToXZi4XZgZmqeX/NkxNKCPsswAXU3UeYgDSpGhu05eAufjDg==", + "cpu": [ + "arm" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-arm64-gnu": { + "version": "1.29.1", + "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-gnu/-/lightningcss-linux-arm64-gnu-1.29.1.tgz", + "integrity": "sha512-0+vClRIZ6mmJl/dxGuRsE197o1HDEeeRk6nzycSy2GofC2JsY4ifCRnvUWf/CUBQmlrvMzt6SMQNMSEu22csWQ==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-arm64-musl": { + "version": "1.29.1", + "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-musl/-/lightningcss-linux-arm64-musl-1.29.1.tgz", + "integrity": "sha512-UKMFrG4rL/uHNgelBsDwJcBqVpzNJbzsKkbI3Ja5fg00sgQnHw/VrzUTEc4jhZ+AN2BvQYz/tkHu4vt1kLuJyw==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-x64-gnu": { + "version": "1.29.1", + "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-gnu/-/lightningcss-linux-x64-gnu-1.29.1.tgz", + "integrity": "sha512-u1S+xdODy/eEtjADqirA774y3jLcm8RPtYztwReEXoZKdzgsHYPl0s5V52Tst+GKzqjebkULT86XMSxejzfISw==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-x64-musl": { + "version": "1.29.1", + "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-musl/-/lightningcss-linux-x64-musl-1.29.1.tgz", + "integrity": "sha512-L0Tx0DtaNUTzXv0lbGCLB/c/qEADanHbu4QdcNOXLIe1i8i22rZRpbT3gpWYsCh9aSL9zFujY/WmEXIatWvXbw==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-win32-arm64-msvc": { + "version": "1.29.1", + "resolved": "https://registry.npmjs.org/lightningcss-win32-arm64-msvc/-/lightningcss-win32-arm64-msvc-1.29.1.tgz", + "integrity": "sha512-QoOVnkIEFfbW4xPi+dpdft/zAKmgLgsRHfJalEPYuJDOWf7cLQzYg0DEh8/sn737FaeMJxHZRc1oBreiwZCjog==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-win32-x64-msvc": { + "version": "1.29.1", + "resolved": "https://registry.npmjs.org/lightningcss-win32-x64-msvc/-/lightningcss-win32-x64-msvc-1.29.1.tgz", + "integrity": "sha512-NygcbThNBe4JElP+olyTI/doBNGJvLs3bFCRPdvuCcxZCcCZ71B858IHpdm7L1btZex0FvCmM17FK98Y9MRy1Q==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss/node_modules/detect-libc": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-1.0.3.tgz", + "integrity": "sha512-pGjwhsmsp4kL2RTz08wcOlGN83otlqHeD/Z5T8GXZB+/YcpQ/dgo+lbU8ZsGxV0HIvqqxo9l7mqYwyYMD9bKDg==", + "bin": { + "detect-libc": "bin/detect-libc.js" + }, + "engines": { + "node": ">=0.10" + } + }, "node_modules/lilconfig": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/lilconfig/-/lilconfig-3.1.3.tgz", @@ -7738,7 +8266,6 @@ "version": "2.2.1", "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.2.1.tgz", "integrity": "sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ==", - "dev": true, "engines": { "node": ">=6" } @@ -8244,10 +8771,6 @@ "defaults": "^1.0.3" } }, - "node_modules/dispatch": { - "resolved": "apps/dispatch", - "link": true - }, "node_modules/which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", diff --git a/packages/database/.env b/packages/database/.env new file mode 100644 index 00000000..919cff11 --- /dev/null +++ b/packages/database/.env @@ -0,0 +1 @@ +DATABASE_URL=postgresql://persistant-data:persistant-data-pw@localhost:5432/var \ No newline at end of file diff --git a/packages/database/package.json b/packages/database/package.json index 9d9d34ae..c42584b9 100644 --- a/packages/database/package.json +++ b/packages/database/package.json @@ -5,7 +5,7 @@ "main": "index.js", "scripts": { "db:generate": "npx prisma generate", - "db:migrate": "npx prisma migrate dev --skip-generate", + "db:migrate": "npx prisma migrate dev", "db:deploy": "npx prisma migrate deploy" }, "exports": { diff --git a/packages/database/prisma/migrations/20250202182447_oauth_token/migration.sql b/packages/database/prisma/migrations/20250202182447_oauth_token/migration.sql new file mode 100644 index 00000000..3f92185b --- /dev/null +++ b/packages/database/prisma/migrations/20250202182447_oauth_token/migration.sql @@ -0,0 +1,14 @@ +-- CreateTable +CREATE TABLE "oauth_tokens" ( + "id" SERIAL NOT NULL, + "user_id" INTEGER NOT NULL, + "client_id" TEXT NOT NULL, + "access_token" TEXT NOT NULL, + "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updated_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + + CONSTRAINT "oauth_tokens_pkey" PRIMARY KEY ("id") +); + +-- CreateIndex +CREATE UNIQUE INDEX "oauth_tokens_access_token_key" ON "oauth_tokens"("access_token"); diff --git a/packages/database/prisma/migrations/20250202183237_token/migration.sql b/packages/database/prisma/migrations/20250202183237_token/migration.sql new file mode 100644 index 00000000..0b97f97d --- /dev/null +++ b/packages/database/prisma/migrations/20250202183237_token/migration.sql @@ -0,0 +1,2 @@ +-- AlterTable +ALTER TABLE "oauth_tokens" ALTER COLUMN "user_id" SET DATA TYPE TEXT; diff --git a/packages/database/prisma/schema/auth.prisma b/packages/database/prisma/schema/auth.prisma index ccd6fc73..e5503b18 100644 --- a/packages/database/prisma/schema/auth.prisma +++ b/packages/database/prisma/schema/auth.prisma @@ -34,3 +34,14 @@ model VerificationRequest { @@map(name: "verification_requests") } + +model OAuthToken { + id Int @id @default(autoincrement()) + userId String @map(name: "user_id") + clientId String @map(name: "client_id") + accessToken String @unique @map(name: "access_token") + createdAt DateTime @default(now()) @map(name: "created_at") + updatedAt DateTime @default(now()) @map(name: "updated_at") + + @@map(name: "oauth_tokens") +}