diff --git a/.prettierignore b/.prettierignore index deb421f2..ae363ce3 100644 --- a/.prettierignore +++ b/.prettierignore @@ -14,6 +14,7 @@ out coverage pnpm-* .vercel +.turbo # Ignore files for PNPM, NPM and YARN pnpm-lock.yaml diff --git a/apps/next/src/app/api/authorize/x_route.ts b/apps/next/src/app/api/authorize/x_route.ts new file mode 100644 index 00000000..aa545197 --- /dev/null +++ b/apps/next/src/app/api/authorize/x_route.ts @@ -0,0 +1,57 @@ +export async function GET() {} + +// import { type NextRequest } from 'next/server' +// import { redirect } from 'next/navigation' +// import crypto from 'crypto' +// import { kv } from '@vercel/kv' + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +// export async function GET(request: NextRequest) { +// console.log('GET /login/authorize') +// const authCodes = +// (await kv.get<{ +// [key: string]: number +// }>('auth-codes')) || {} +// console.log({ authCodes }) + +// const responseType = request.nextUrl.searchParams.get('response_type') +// const clientId = request.nextUrl.searchParams.get('client_id') +// const redirectUri = request.nextUrl.searchParams.get('redirect_uri') +// const scope = request.nextUrl.searchParams.get('scope') +// const nonce = request.nextUrl.searchParams.get('nonce') + +// console.log({ +// responseType, +// clientId, +// redirectUri, +// scope, +// nonce, +// }) + +// const code = crypto.randomBytes(16).toString('hex') +// authCodes[code] = new Date(Date.now() + 60000).getTime() +// await kv.set('auth-codes', authCodes) + +// // const codeVerifier = generateCodeVerifier() +// // const codeChallenge = base64UrlEncode( +// // crypto.createHash('sha256').update(codeVerifier).digest(), +// // ) +// // const isMatching = verifyPKCE(codeVerifier, codeChallenge) +// // // console.log({ codeVerifier, codeChallenge, isMatching }) +// // // console.log(userAgent({ headers: headers() as Headers })) +// // const authCodes = getCache<{ [key: string]: boolean }>('authCodes') +// // const found = authCodes?.[authCode] + +// // if (!found) { +// // return NextResponse.json({ +// // enteredCode: authCode, +// // error: 'not found', +// // }) +// // } + +// const params = new URLSearchParams({ +// code, +// }) + +// return redirect(`${redirectUri}?${params.toString()}`) +// } diff --git a/apps/next/src/app/login/authorize/route.tsx b/apps/next/src/app/login/authorize/route.tsx deleted file mode 100644 index afb64f4d..00000000 --- a/apps/next/src/app/login/authorize/route.tsx +++ /dev/null @@ -1,55 +0,0 @@ -import { type NextRequest } from 'next/server' -import { redirect } from 'next/navigation' -import crypto from 'crypto' -import { kv } from '@vercel/kv' - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -export async function GET(request: NextRequest) { - console.log('GET /login/authorize') - const authCodes = - (await kv.get<{ - [key: string]: number - }>('auth-codes')) || {} - console.log({ authCodes }) - - const responseType = request.nextUrl.searchParams.get('response_type') - const clientId = request.nextUrl.searchParams.get('client_id') - const redirectUri = request.nextUrl.searchParams.get('redirect_uri') - const scope = request.nextUrl.searchParams.get('scope') - const nonce = request.nextUrl.searchParams.get('nonce') - - console.log({ - responseType, - clientId, - redirectUri, - scope, - nonce, - }) - - const code = crypto.randomBytes(16).toString('hex') - authCodes[code] = new Date(Date.now() + 60000).getTime() - await kv.set('auth-codes', authCodes) - - // const codeVerifier = generateCodeVerifier() - // const codeChallenge = base64UrlEncode( - // crypto.createHash('sha256').update(codeVerifier).digest(), - // ) - // const isMatching = verifyPKCE(codeVerifier, codeChallenge) - // // console.log({ codeVerifier, codeChallenge, isMatching }) - // // console.log(userAgent({ headers: headers() as Headers })) - // const authCodes = getCache<{ [key: string]: boolean }>('authCodes') - // const found = authCodes?.[authCode] - - // if (!found) { - // return NextResponse.json({ - // enteredCode: authCode, - // error: 'not found', - // }) - // } - - const params = new URLSearchParams({ - code, - }) - - return redirect(`${redirectUri}?${params.toString()}`) -} diff --git a/apps/next/src/app/login/page.tsx b/apps/next/src/app/login/page.tsx index 7ac787c3..ea14097c 100644 --- a/apps/next/src/app/login/page.tsx +++ b/apps/next/src/app/login/page.tsx @@ -1,4 +1,4 @@ -import Image from 'next/image' +// import Image from 'next/image' import Content from '@/components/Content' import Section from '@/components/Section' @@ -6,8 +6,8 @@ export default function Page() { return (
-
@@ -31,7 +31,7 @@ export default function Page() { -
+ */}
)