From 09645780b284adeea062aacc8d460dac3c3ff482 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20Orb=C3=A1n?= Date: Tue, 20 Jun 2023 17:22:04 +0200 Subject: [PATCH 01/26] chore: upgrade `next-auth` --- auth.ts | 1 - package.json | 2 +- pnpm-lock.yaml | 37 ++++++++++--------------------------- 3 files changed, 11 insertions(+), 29 deletions(-) diff --git a/auth.ts b/auth.ts index e422771..86beb34 100644 --- a/auth.ts +++ b/auth.ts @@ -15,7 +15,6 @@ export const { auth, CSRF_experimental } = NextAuth({ - // @ts-expect-error providers: [GitHub], callbacks: { jwt: async ({ token, profile }) => { diff --git a/package.json b/package.json index 32fda5a..918200c 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "focus-trap-react": "^10.1.1", "nanoid": "^4.0.2", "next": "13.4.7-canary.1", - "next-auth": "0.0.0-manual.f414f2f5", + "next-auth": "0.0.0-manual.e65faa1c", "next-themes": "^0.2.1", "openai-edge": "^0.5.1", "react": "^18.2.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index bdf496a..a655dae 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -63,8 +63,8 @@ dependencies: specifier: 13.4.7-canary.1 version: 13.4.7-canary.1(react-dom@18.2.0)(react@18.2.0) next-auth: - specifier: 0.0.0-manual.f414f2f5 - version: 0.0.0-manual.f414f2f5(next@13.4.7-canary.1)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.0-manual.e65faa1c + version: 0.0.0-manual.e65faa1c(next@13.4.7-canary.1)(react-dom@18.2.0)(react@18.2.0) next-themes: specifier: ^0.2.1 version: 0.2.1(next@13.4.7-canary.1)(react-dom@18.2.0)(react@18.2.0) @@ -165,8 +165,8 @@ packages: engines: {node: '>=10'} dev: true - /@auth/core@0.0.0-manual.527fff6c: - resolution: {integrity: sha512-NYWuH+6VAAMV05juyarbMm6rCDUGvS5vPFsE+V13NIfbvbwbEZPj3JfcHVv7vMDrUrPtJ4EhTh00Svejp1Moqg==} + /@auth/core@0.0.0-manual.8fcd46b0: + resolution: {integrity: sha512-KuhvZ0hHz6NvMAgAi+su0dJOD0YAiOWGaLswyfGK5RsG/cdhqyyiII9HOTaZbWZAKir0UGYb8SlN+owhV30JXg==} peerDependencies: nodemailer: ^6.8.0 peerDependenciesMeta: @@ -181,29 +181,13 @@ packages: preact-render-to-string: 5.2.3(preact@10.11.3) dev: false - /@auth/core@0.8.2: - resolution: {integrity: sha512-swqJ7tKFlqiYIl1znFGrrawUv1F6rwL+/f3DoeWDaZLnr2phiHFaZsvNvLK7WBJhnJbel78Vd3GznuR31AnFUw==} - peerDependencies: - nodemailer: ^6.8.0 - peerDependenciesMeta: - nodemailer: - optional: true - dependencies: - '@panva/hkdf': 1.1.1 - cookie: 0.5.0 - jose: 4.14.4 - oauth4webapi: 2.3.0 - preact: 10.11.3 - preact-render-to-string: 5.2.3(preact@10.11.3) - dev: false - - /@auth/nextjs@0.0.0-manual.de744368(next@13.4.7-canary.1)(react@18.2.0): - resolution: {integrity: sha512-jLjKasLTKH5YLiK2i0NQWbsQS1pMveidyFT/ibwZ6c5UAcqDsC6ZGvvVxOaiAmiA6iFA1WMqNBVEcy+NhGgXVQ==} + /@auth/nextjs@0.0.0-manual.b53ca00b(next@13.4.7-canary.1)(react@18.2.0): + resolution: {integrity: sha512-g0XvlP+3MSXPX512K6Hu0mGOkb1QPCkXkaA0Zr9i+bmTEDU9TtYTTNmX2EyvLeTfmrEEU/CMS92aWTmiki1KVA==} peerDependencies: next: ^13.4.6 react: ^18.2.0 dependencies: - '@auth/core': 0.8.2 + '@auth/core': 0.0.0-manual.8fcd46b0 next: 13.4.7-canary.1(react-dom@18.2.0)(react@18.2.0) react: 18.2.0 transitivePeerDependencies: @@ -4033,8 +4017,8 @@ packages: resolution: {integrity: sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==} dev: true - /next-auth@0.0.0-manual.f414f2f5(next@13.4.7-canary.1)(react-dom@18.2.0)(react@18.2.0): - resolution: {integrity: sha512-qJmSX4QUV8V2JOQavl0fQyJymt0fte7eDQsMGTpx8ZRU2Qvx8uh+xrvXlHt3dXf603OB3QkWaj77ipIEt62Hfg==} + /next-auth@0.0.0-manual.e65faa1c(next@13.4.7-canary.1)(react-dom@18.2.0)(react@18.2.0): + resolution: {integrity: sha512-I51GvhZhZEf/gzhiTKivYPAIyZ74sCF3YXAMMuZ/bjahybeehPEu7opcPEA+H0Uxrvmo2G8/BQ7mT+TiFdM9IQ==} peerDependencies: next: ^13.4.5 nodemailer: ^6.6.5 @@ -4044,8 +4028,7 @@ packages: nodemailer: optional: true dependencies: - '@auth/core': 0.0.0-manual.527fff6c - '@auth/nextjs': 0.0.0-manual.de744368(next@13.4.7-canary.1)(react@18.2.0) + '@auth/nextjs': 0.0.0-manual.b53ca00b(next@13.4.7-canary.1)(react@18.2.0) next: 13.4.7-canary.1(react-dom@18.2.0)(react@18.2.0) react: 18.2.0 react-dom: 18.2.0(react@18.2.0) From 7c7f0fac971c5e92d9e7483d188bc44137de80f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20Orb=C3=A1n?= Date: Tue, 20 Jun 2023 16:50:12 +0100 Subject: [PATCH 02/26] fix(ts): add back `DefaultSession` types --- auth.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/auth.ts b/auth.ts index 86beb34..a73db04 100644 --- a/auth.ts +++ b/auth.ts @@ -1,4 +1,4 @@ -import NextAuth from 'next-auth' +import NextAuth, { type DefaultSession } from 'next-auth' import GitHub from 'next-auth/providers/github' declare module 'next-auth' { @@ -6,7 +6,7 @@ declare module 'next-auth' { user: { /** The user's id. */ id: string - } + } & DefaultSession['user'] } } From 26143d6bacdea28cfcd7c95d6443bdeb34641fa5 Mon Sep 17 00:00:00 2001 From: jphyqr <34660850+jphyqr@users.noreply.github.com> Date: Tue, 20 Jun 2023 13:24:03 -0600 Subject: [PATCH 03/26] Update .env.example update with help to turn on billing account as if you start project without one you don't get proper error messaging --- .env.example | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.env.example b/.env.example index 3c45061..8ffdeff 100644 --- a/.env.example +++ b/.env.example @@ -1,4 +1,5 @@ -## Get your OpenAI API Key +## Get your OpenAI API Key here: https://platform.openai.com/account/api-keys +##You must activate a Billing Account here: https://platform.openai.com/account/billing/overview OPENAI_API_KEY=XXXXXXXX ## Generate a random secret: https://generate-secret.vercel.app/32 From 805639dba4fafd1d45020d7e33912e2d99d47b3a Mon Sep 17 00:00:00 2001 From: UrNas Date: Wed, 21 Jun 2023 02:01:22 +0300 Subject: [PATCH 04/26] check chats length before run kv.pipeline() otherwise get empty pipeline --- app/actions.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/actions.ts b/app/actions.ts index 90c6973..2c8a5dd 100644 --- a/app/actions.ts +++ b/app/actions.ts @@ -74,7 +74,9 @@ export async function clearChats() { } const chats: string[] = await kv.zrange(`user:chat:${session.user.id}`, 0, -1) - + if (!chats.length) { + return redirect('/') + } const pipeline = kv.pipeline() for (const chat of chats) { From 476c696dae62128ff40441a6b0fe8ba64456e989 Mon Sep 17 00:00:00 2001 From: Ethan Liu Date: Wed, 21 Jun 2023 09:39:54 +0800 Subject: [PATCH 05/26] fix: Repeated tailwind extend fontFamily --- tailwind.config.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/tailwind.config.js b/tailwind.config.js index 93289bd..e16dd0f 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -56,9 +56,6 @@ module.exports = { md: `calc(var(--radius) - 2px)`, sm: 'calc(var(--radius) - 4px)' }, - fontFamily: { - sans: ['var(--font-sans)', ...fontFamily.sans] - }, keyframes: { 'accordion-down': { from: { height: 0 }, From 25361c847b32f248fd65114a94e39d11a5f98590 Mon Sep 17 00:00:00 2001 From: Ethan Liu Date: Wed, 21 Jun 2023 12:20:49 +0800 Subject: [PATCH 06/26] fix: Reduce ineffective triggering of the clipboard --- components/chat-message-actions.tsx | 11 ++++++----- components/ui/codeblock.tsx | 7 ++++++- lib/hooks/use-copy-to-clipboard.tsx | 10 +++++----- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/components/chat-message-actions.tsx b/components/chat-message-actions.tsx index 2905f8a..d4e4b40 100644 --- a/components/chat-message-actions.tsx +++ b/components/chat-message-actions.tsx @@ -18,6 +18,11 @@ export function ChatMessageActions({ }: ChatMessageActionsProps) { const { isCopied, copyToClipboard } = useCopyToClipboard({ timeout: 2000 }) + const onCopy = () => { + if (isCopied) return + copyToClipboard(message.content) + } + return (
- diff --git a/components/ui/codeblock.tsx b/components/ui/codeblock.tsx index 438c42c..aabda4e 100644 --- a/components/ui/codeblock.tsx +++ b/components/ui/codeblock.tsx @@ -84,6 +84,11 @@ const CodeBlock: FC = memo(({ language, value }) => { URL.revokeObjectURL(url) } + const onCopy = () => { + if (isCopied) return + copyToClipboard(value) + } + return (
@@ -102,7 +107,7 @@ const CodeBlock: FC = memo(({ language, value }) => { variant="ghost" size="icon" className="text-xs hover:bg-zinc-800 focus-visible:ring-1 focus-visible:ring-slate-700 focus-visible:ring-offset-0" - onClick={() => copyToClipboard(value)} + onClick={onCopy} > {isCopied ? : } Copy code diff --git a/lib/hooks/use-copy-to-clipboard.tsx b/lib/hooks/use-copy-to-clipboard.tsx index 9f9b8e3..62f7156 100644 --- a/lib/hooks/use-copy-to-clipboard.tsx +++ b/lib/hooks/use-copy-to-clipboard.tsx @@ -12,11 +12,11 @@ export function useCopyToClipboard({ const [isCopied, setIsCopied] = React.useState(false) const copyToClipboard = (value: string) => { - if ( - typeof window === 'undefined' || - !navigator.clipboard || - !navigator.clipboard.writeText - ) { + if (typeof window === 'undefined' || !navigator.clipboard?.writeText) { + return + } + + if (!value) { return } From 62de89520ae66932516e34c73f9f9b0b66ea8b69 Mon Sep 17 00:00:00 2001 From: Ethan Liu Date: Wed, 21 Jun 2023 12:24:50 +0800 Subject: [PATCH 07/26] fix: Do not send empty messages. --- components/prompt-form.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/prompt-form.tsx b/components/prompt-form.tsx index 75258c8..8d36838 100644 --- a/components/prompt-form.tsx +++ b/components/prompt-form.tsx @@ -15,7 +15,7 @@ import { IconArrowElbow, IconPlus } from '@/components/ui/icons' export interface PromptProps extends Pick { - onSubmit: (value: string) => void + onSubmit: (value: string) => Promise isLoading: boolean } @@ -38,7 +38,7 @@ export function PromptForm({
{ e.preventDefault() - if (input === '') { + if (!input?.trim()) { return } setInput('') From 71eaefe724b4cd8414ff587d4129d3dc50c631ae Mon Sep 17 00:00:00 2001 From: Jared Palmer Date: Wed, 21 Jun 2023 08:11:38 -0700 Subject: [PATCH 08/26] Update .env.example MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Tomás --- .env.example | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.env.example b/.env.example index 8ffdeff..643a5cb 100644 --- a/.env.example +++ b/.env.example @@ -1,5 +1,5 @@ -## Get your OpenAI API Key here: https://platform.openai.com/account/api-keys -##You must activate a Billing Account here: https://platform.openai.com/account/billing/overview +## You must first activate a Billing Account here: https://platform.openai.com/account/billing/overview +## Then get your OpenAI API Key here: https://platform.openai.com/account/api-keys OPENAI_API_KEY=XXXXXXXX ## Generate a random secret: https://generate-secret.vercel.app/32 From 41e3b69c1c3c5deabdee6af025677ece97713518 Mon Sep 17 00:00:00 2001 From: Anibal Date: Wed, 21 Jun 2023 17:13:04 +0200 Subject: [PATCH 09/26] fix: Adds max height to form box (#51) --- components/prompt-form.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/prompt-form.tsx b/components/prompt-form.tsx index 8d36838..d053842 100644 --- a/components/prompt-form.tsx +++ b/components/prompt-form.tsx @@ -46,7 +46,7 @@ export function PromptForm({ }} ref={formRef} > -
+
Date: Wed, 21 Jun 2023 23:13:25 +0800 Subject: [PATCH 10/26] fix: Fix metadata title generation in chat pages (#41) --- app/chat/[id]/page.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/chat/[id]/page.tsx b/app/chat/[id]/page.tsx index d7ad6d6..25d6c30 100644 --- a/app/chat/[id]/page.tsx +++ b/app/chat/[id]/page.tsx @@ -25,7 +25,7 @@ export async function generateMetadata({ const chat = await getChat(params.id, session.user.id) return { - title: chat?.title.slice(0, 50) ?? 'Chat' + title: chat?.title.toString().slice(0, 50) ?? 'Chat' } } From 96a386b9d6a6a9721ffbc86066b48f10eae30090 Mon Sep 17 00:00:00 2001 From: Ikko Eltociear Ashimine Date: Thu, 22 Jun 2023 00:13:37 +0900 Subject: [PATCH 11/26] Update README.md (#50) --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index cb32307..1105e31 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ - [Next.js](https://nextjs.org) App Router - React Server Components (RSCs), Suspense, and Server Actions - [Vercel AI SDK](https://sdk.vercel.ai/docs) for streaming chat UI -- Support for OpenAI (default), Anthropic, HuggingFace, or custom AI chat models and/or LangChain +- Support for OpenAI (default), Anthropic, Hugging Face, or custom AI chat models and/or LangChain - Edge runtime-ready - [shadcn/ui](https://ui.shadcn.com) - Styling with [Tailwind CSS](https://tailwindcss.com) @@ -32,7 +32,7 @@ ## Model Providers -This template ships with OpenAI `gpt-3.5-turbo` as the default. However, thanks to the [Vercel AI SDK](https://sdk.vercel.ai/docs), you can switch LLM providers to [Anthropic](https://anthropic.com), [HuggingFace](https://huggingface.co), or using [LangChain](https://js.langchain.com) with just a few lines of code. +This template ships with OpenAI `gpt-3.5-turbo` as the default. However, thanks to the [Vercel AI SDK](https://sdk.vercel.ai/docs), you can switch LLM providers to [Anthropic](https://anthropic.com), [Hugging Face](https://huggingface.co), or using [LangChain](https://js.langchain.com) with just a few lines of code. ## Deploy Your Own From f326b47f6ee68532ac3c74672de7e6a4bb27d86e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=BF=B7=E6=B8=A1?= Date: Wed, 21 Jun 2023 23:19:38 +0800 Subject: [PATCH 12/26] fix: send message on Enter keypress only when not in input method mode (#63) --- lib/hooks/use-enter-submit.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/hooks/use-enter-submit.tsx b/lib/hooks/use-enter-submit.tsx index 5091ddf..d66b2d3 100644 --- a/lib/hooks/use-enter-submit.tsx +++ b/lib/hooks/use-enter-submit.tsx @@ -9,7 +9,11 @@ export function useEnterSubmit(): { const handleKeyDown = ( event: React.KeyboardEvent ): void => { - if (event.key === 'Enter' && !event.shiftKey) { + if ( + event.key === 'Enter' && + !event.shiftKey && + !event.nativeEvent.isComposing + ) { formRef.current?.requestSubmit() event.preventDefault() } From 1b3dc4a404d3acb4b89857e2cbb574ee2128b142 Mon Sep 17 00:00:00 2001 From: Jared Palmer Date: Wed, 21 Jun 2023 08:23:16 -0700 Subject: [PATCH 13/26] Fix share header --- app/share/[id]/page.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/share/[id]/page.tsx b/app/share/[id]/page.tsx index 3ec3f3e..4ee6620 100644 --- a/app/share/[id]/page.tsx +++ b/app/share/[id]/page.tsx @@ -35,9 +35,9 @@ export default async function SharePage({ params }: SharePageProps) { return ( <>
-
-
-
+
+
+

{chat.title}

{formatDate(chat.createdAt)} · {chat.messages.length} messages From 3bcaa6fe6e8dd7f3dec586e1a2a8d2c2e224af6e Mon Sep 17 00:00:00 2001 From: Jared Palmer Date: Wed, 21 Jun 2023 11:07:22 -0700 Subject: [PATCH 14/26] Fix next-auth in lockfile --- pnpm-lock.yaml | 179 ++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 163 insertions(+), 16 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a655dae..e6d3739 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,7 +1,7 @@ -lockfileVersion: '6.1' +lockfileVersion: '6.0' settings: - autoInstallPeers: false + autoInstallPeers: true excludeLinksFromLockfile: false dependencies: @@ -43,7 +43,7 @@ dependencies: version: 0.5.7 ai: specifier: ^2.1.2 - version: 2.1.2(react@18.2.0) + version: 2.1.2(react@18.2.0)(svelte@3.59.2)(vue@3.3.4) body-scroll-lock: specifier: 4.0.0-beta.0 version: 4.0.0-beta.0 @@ -55,7 +55,7 @@ dependencies: version: 1.2.1 focus-trap-react: specifier: ^10.1.1 - version: 10.1.1(react-dom@18.2.0)(react@18.2.0) + version: 10.1.1(prop-types@15.8.1)(react-dom@18.2.0)(react@18.2.0) nanoid: specifier: ^4.0.2 version: 4.0.2 @@ -79,7 +79,7 @@ dependencies: version: 18.2.0(react@18.2.0) react-hot-toast: specifier: ^2.4.1 - version: 2.4.1(react-dom@18.2.0)(react@18.2.0) + version: 2.4.1(csstype@3.1.2)(react-dom@18.2.0)(react@18.2.0) react-intersection-observer: specifier: ^9.4.4 version: 9.4.4(react@18.2.0) @@ -194,12 +194,39 @@ packages: - nodemailer dev: false + /@babel/helper-string-parser@7.22.5: + resolution: {integrity: sha512-mM4COjgZox8U+JcXQwPijIZLElkgEpO5rsERVDJTc2qfCDfERyob6k5WegS14SX18IIjv+XD+GrqNumY5JRCDw==} + engines: {node: '>=6.9.0'} + dev: false + + /@babel/helper-validator-identifier@7.22.5: + resolution: {integrity: sha512-aJXu+6lErq8ltp+JhkJUfk1MTGyuA4v7f3pA+BJ5HLfNC6nAQ0Cpi9uOquUj8Hehg0aUiHzWQbOVJGao6ztBAQ==} + engines: {node: '>=6.9.0'} + dev: false + + /@babel/parser@7.22.5: + resolution: {integrity: sha512-DFZMC9LJUG9PLOclRC32G63UXwzqS2koQC8dkx+PLdmt1xSePYpbT/NbsrJy8Q/muXz7o/h/d4A7Fuyixm559Q==} + engines: {node: '>=6.0.0'} + hasBin: true + dependencies: + '@babel/types': 7.22.5 + dev: false + /@babel/runtime@7.21.5: resolution: {integrity: sha512-8jI69toZqqcsnqGGqwGS4Qb1VwLOEp4hz+CXPywcvjs60u3B4Pom/U/7rm4W8tMOYEB+E9wgD0mW1l3r8qlI9Q==} engines: {node: '>=6.9.0'} dependencies: regenerator-runtime: 0.13.11 + /@babel/types@7.22.5: + resolution: {integrity: sha512-zo3MIHGOkPOfoRXitsgHLjEXmlDaD/5KU1Uzuc9GNiZPhSqVxVRtxuPaSBZDsYZ9qV88AjtMtWW7ww98loJ9KA==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/helper-string-parser': 7.22.5 + '@babel/helper-validator-identifier': 7.22.5 + to-fast-properties: 2.0.0 + dev: false + /@esbuild/android-arm@0.15.18: resolution: {integrity: sha512-5GT+kcs2WVGjVs7+boataCkO5Fg0y4kCjzkB5bAip7H4jfnOS3dA6KPiww9W1OEKTKeAcUVhdZGvgI65OXmUnw==} engines: {node: '>=12'} @@ -321,7 +348,6 @@ packages: /@jridgewell/sourcemap-codec@1.4.15: resolution: {integrity: sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==} - dev: true /@jridgewell/trace-mapping@0.3.18: resolution: {integrity: sha512-w+niJYzMHdd7USdiH2U6869nqhD2nbfZXND5Yp93qIbEmnDNk7PD48o+YchRVpzMU7M6jVCbenTR7PA1FLQ9pA==} @@ -1358,6 +1384,89 @@ packages: yoga-wasm-web: 0.3.3 dev: false + /@vue/compiler-core@3.3.4: + resolution: {integrity: sha512-cquyDNvZ6jTbf/+x+AgM2Arrp6G4Dzbb0R64jiG804HRMfRiFXWI6kqUVqZ6ZR0bQhIoQjB4+2bhNtVwndW15g==} + dependencies: + '@babel/parser': 7.22.5 + '@vue/shared': 3.3.4 + estree-walker: 2.0.2 + source-map-js: 1.0.2 + dev: false + + /@vue/compiler-dom@3.3.4: + resolution: {integrity: sha512-wyM+OjOVpuUukIq6p5+nwHYtj9cFroz9cwkfmP9O1nzH68BenTTv0u7/ndggT8cIQlnBeOo6sUT/gvHcIkLA5w==} + dependencies: + '@vue/compiler-core': 3.3.4 + '@vue/shared': 3.3.4 + dev: false + + /@vue/compiler-sfc@3.3.4: + resolution: {integrity: sha512-6y/d8uw+5TkCuzBkgLS0v3lSM3hJDntFEiUORM11pQ/hKvkhSKZrXW6i69UyXlJQisJxuUEJKAWEqWbWsLeNKQ==} + dependencies: + '@babel/parser': 7.22.5 + '@vue/compiler-core': 3.3.4 + '@vue/compiler-dom': 3.3.4 + '@vue/compiler-ssr': 3.3.4 + '@vue/reactivity-transform': 3.3.4 + '@vue/shared': 3.3.4 + estree-walker: 2.0.2 + magic-string: 0.30.0 + postcss: 8.4.23 + source-map-js: 1.0.2 + dev: false + + /@vue/compiler-ssr@3.3.4: + resolution: {integrity: sha512-m0v6oKpup2nMSehwA6Uuu+j+wEwcy7QmwMkVNVfrV9P2qE5KshC6RwOCq8fjGS/Eak/uNb8AaWekfiXxbBB6gQ==} + dependencies: + '@vue/compiler-dom': 3.3.4 + '@vue/shared': 3.3.4 + dev: false + + /@vue/reactivity-transform@3.3.4: + resolution: {integrity: sha512-MXgwjako4nu5WFLAjpBnCj/ieqcjE2aJBINUNQzkZQfzIZA4xn+0fV1tIYBJvvva3N3OvKGofRLvQIwEQPpaXw==} + dependencies: + '@babel/parser': 7.22.5 + '@vue/compiler-core': 3.3.4 + '@vue/shared': 3.3.4 + estree-walker: 2.0.2 + magic-string: 0.30.0 + dev: false + + /@vue/reactivity@3.3.4: + resolution: {integrity: sha512-kLTDLwd0B1jG08NBF3R5rqULtv/f8x3rOFByTDz4J53ttIQEDmALqKqXY0J+XQeN0aV2FBxY8nJDf88yvOPAqQ==} + dependencies: + '@vue/shared': 3.3.4 + dev: false + + /@vue/runtime-core@3.3.4: + resolution: {integrity: sha512-R+bqxMN6pWO7zGI4OMlmvePOdP2c93GsHFM/siJI7O2nxFRzj55pLwkpCedEY+bTMgp5miZ8CxfIZo3S+gFqvA==} + dependencies: + '@vue/reactivity': 3.3.4 + '@vue/shared': 3.3.4 + dev: false + + /@vue/runtime-dom@3.3.4: + resolution: {integrity: sha512-Aj5bTJ3u5sFsUckRghsNjVTtxZQ1OyMWCr5dZRAPijF/0Vy4xEoRCwLyHXcj4D0UFbJ4lbx3gPTgg06K/GnPnQ==} + dependencies: + '@vue/runtime-core': 3.3.4 + '@vue/shared': 3.3.4 + csstype: 3.1.2 + dev: false + + /@vue/server-renderer@3.3.4(vue@3.3.4): + resolution: {integrity: sha512-Q6jDDzR23ViIb67v+vM1Dqntu+HUexQcsWKhhQa4ARVzxOY2HbC7QRW/ggkDBd5BU+uM1sV6XOAP0b216o34JQ==} + peerDependencies: + vue: 3.3.4 + dependencies: + '@vue/compiler-ssr': 3.3.4 + '@vue/shared': 3.3.4 + vue: 3.3.4 + dev: false + + /@vue/shared@3.3.4: + resolution: {integrity: sha512-7OjdcV8vQ74eiz1TZLzZP4JwqM5fA94K6yntPS5Z25r9HDuGNzaGdgvwKYq6S+MxwF0TFRwe50fIR/MYnakdkQ==} + dev: false + /acorn-jsx@5.3.2(acorn@8.8.2): resolution: {integrity: sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==} peerDependencies: @@ -1372,7 +1481,7 @@ packages: hasBin: true dev: true - /ai@2.1.2(react@18.2.0): + /ai@2.1.2(react@18.2.0)(svelte@3.59.2)(vue@3.3.4): resolution: {integrity: sha512-WhyGH95Pv/gpgVMQT5eCyKXJh7irozr+bmpJ94somfRYBcAN2U270ii/OOHzGLrPM3liTbBilGQL2Ds7/5sz9Q==} engines: {node: '>=14.6'} peerDependencies: @@ -1390,9 +1499,11 @@ packages: eventsource-parser: 1.0.0 nanoid: 3.3.6 react: 18.2.0 - sswr: 1.10.0 + sswr: 1.10.0(svelte@3.59.2) + svelte: 3.59.2 swr: 2.1.5(react@18.2.0) - swrv: 1.0.3 + swrv: 1.0.3(vue@3.3.4) + vue: 3.3.4 dev: false /ajv@6.12.6: @@ -2644,6 +2755,10 @@ packages: engines: {node: '>=4.0'} dev: true + /estree-walker@2.0.2: + resolution: {integrity: sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==} + dev: false + /esutils@2.0.3: resolution: {integrity: sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==} engines: {node: '>=0.10.0'} @@ -2774,7 +2889,7 @@ packages: resolution: {integrity: sha512-5nqDSxl8nn5BSNxyR3n4I6eDmbolI6WT+QqR547RwxQapgjQBmtktdP+HTBb/a/zLsbzERTONyUB5pefh5TtjQ==} dev: true - /focus-trap-react@10.1.1(react-dom@18.2.0)(react@18.2.0): + /focus-trap-react@10.1.1(prop-types@15.8.1)(react-dom@18.2.0)(react@18.2.0): resolution: {integrity: sha512-OtLeSIQPKFzMzbLHkGtfZYwGLMhTRHd3CDhfyd0DDx8tvXzlgpseClDiuiKoiIHZtdjsbXTfTmUuuLKaxrwSyQ==} peerDependencies: prop-types: ^15.8.1 @@ -2782,6 +2897,7 @@ packages: react-dom: '>=16.3.0' dependencies: focus-trap: 7.4.0 + prop-types: 15.8.1 react: 18.2.0 react-dom: 18.2.0(react@18.2.0) tabbable: 6.1.2 @@ -2967,10 +3083,12 @@ packages: slash: 4.0.0 dev: true - /goober@2.1.13: + /goober@2.1.13(csstype@3.1.2): resolution: {integrity: sha512-jFj3BQeleOoy7t93E9rZ2de+ScC4lQICLwiAQmKMg9F6roKGaLSHoCDYKkWlSafg138jejvq/mTdvmnwDQgqoQ==} peerDependencies: csstype: ^3.0.10 + dependencies: + csstype: 3.1.2 dev: false /gopd@1.0.1: @@ -3515,6 +3633,13 @@ packages: es5-ext: 0.10.62 dev: true + /magic-string@0.30.0: + resolution: {integrity: sha512-LA+31JYDJLs82r2ScLrlz1GjSgu66ZV518eyWT+S8VhyQn/JL0u9MeBOvQMGYiPk1DBiSN9DDMOcXvigJZaViQ==} + engines: {node: '>=12'} + dependencies: + '@jridgewell/sourcemap-codec': 1.4.15 + dev: false + /markdown-table@3.0.3: resolution: {integrity: sha512-Z1NL3Tb1M9wH4XESsCDEksWoKTdlUafKc4pt0GRwjUyXaCFZ+dc3g2erqB6zm3szA2IUSi7VnPI+o/9jnxh9hw==} dev: false @@ -4428,7 +4553,6 @@ packages: nanoid: 3.3.6 picocolors: 1.0.0 source-map-js: 1.0.2 - dev: true /preact-render-to-string@5.2.3(preact@10.11.3): resolution: {integrity: sha512-aPDxUn5o3GhWdtJtW0svRC2SS/l8D9MAgo2+AWml+BhDImb27ALf04Q2d+AHqUUOc6RdSXFIBVa2gxzgMKgtZA==} @@ -4504,14 +4628,14 @@ packages: scheduler: 0.23.0 dev: false - /react-hot-toast@2.4.1(react-dom@18.2.0)(react@18.2.0): + /react-hot-toast@2.4.1(csstype@3.1.2)(react-dom@18.2.0)(react@18.2.0): resolution: {integrity: sha512-j8z+cQbWIM5LY37pR6uZR6D4LfseplqnuAO4co4u8917hBUvXlEqyP1ZzqVLcqoyUesZZv/ImreoCeHVDpE5pQ==} engines: {node: '>=10'} peerDependencies: react: '>=16' react-dom: '>=16' dependencies: - goober: 2.1.13 + goober: 2.1.13(csstype@3.1.2) react: 18.2.0 react-dom: 18.2.0(react@18.2.0) transitivePeerDependencies: @@ -4866,11 +4990,12 @@ packages: resolution: {integrity: sha512-PEGlAwrG8yXGXRjW32fGbg66JAlOAwbObuqVoJpv/mRgoWDQfgH1wDPvtzWyUSNAXBGSk8h755YDbbcEy3SH2Q==} dev: false - /sswr@1.10.0: + /sswr@1.10.0(svelte@3.59.2): resolution: {integrity: sha512-nLWAJSQy3h8t7rrbTXanRyVHuQPj4PwKIVGe4IMlxJFdhyaxnN/JGACnvQKGDeWiTGYIZIx/jRuUsPEF0867Pg==} peerDependencies: svelte: ^3.29.0 dependencies: + svelte: 3.59.2 swrev: 3.0.0 dev: false @@ -5004,6 +5129,11 @@ packages: engines: {node: '>= 0.4'} dev: true + /svelte@3.59.2: + resolution: {integrity: sha512-vzSyuGr3eEoAtT/A6bmajosJZIUWySzY2CzB3w2pgPvnkUjGqlDnsNnA0PMO+mMAhuyMul6C2uuZzY6ELSkzyA==} + engines: {node: '>= 8'} + dev: false + /swr@2.1.5(react@18.2.0): resolution: {integrity: sha512-/OhfZMcEpuz77KavXST5q6XE9nrOBOVcBLWjMT+oAE/kQHyE3PASrevXCtQDZ8aamntOfFkbVJp7Il9tNBQWrw==} peerDependencies: @@ -5017,10 +5147,12 @@ packages: resolution: {integrity: sha512-QJuZiptdOmbDY45pECBRVEgnoBlOKjeT2MWVz04wKHpWX15hM3P7EjcIbHDg5yLoPCMQ7to3349MEE+l9QF5HA==} dev: false - /swrv@1.0.3: + /swrv@1.0.3(vue@3.3.4): resolution: {integrity: sha512-sl+eLEE+aPPjhP1E8gQ75q3RPRyw5Gd/kROnrTFo3+LkCeLskv7F+uAl5W97wgJkzitobL6FLsRPVm0DgIgN8A==} peerDependencies: vue: '>=3.2.26 < 4' + dependencies: + vue: 3.3.4 dev: false /synckit@0.8.5: @@ -5117,6 +5249,11 @@ packages: engines: {node: '>=12'} dev: true + /to-fast-properties@2.0.0: + resolution: {integrity: sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog==} + engines: {node: '>=4'} + dev: false + /to-regex-range@5.0.1: resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==} engines: {node: '>=8.0'} @@ -5391,6 +5528,16 @@ packages: vfile-message: 3.1.4 dev: false + /vue@3.3.4: + resolution: {integrity: sha512-VTyEYn3yvIeY1Py0WaYGZsXnz3y5UnGi62GjVEqvEGPl6nxbOrCXbVOTQWBEJUqAyTUk2uJ5JLVnYJ6ZzGbrSw==} + dependencies: + '@vue/compiler-dom': 3.3.4 + '@vue/compiler-sfc': 3.3.4 + '@vue/runtime-dom': 3.3.4 + '@vue/server-renderer': 3.3.4(vue@3.3.4) + '@vue/shared': 3.3.4 + dev: false + /watchpack@2.4.0: resolution: {integrity: sha512-Lcvm7MGST/4fup+ifyKi2hjyIAwcdI4HRgtvTpIUxBRhB+RFtUh8XtDOxUfctVCnhVi+QQj49i91OyvzkJl6cg==} engines: {node: '>=10.13.0'} From e8003b2c2270c4ccfe8f7394d2dda775450b1a78 Mon Sep 17 00:00:00 2001 From: Jared Palmer Date: Wed, 21 Jun 2023 11:17:59 -0700 Subject: [PATCH 15/26] Fix deployment to Vercel --- app/api/chat/route.ts | 16 ++++++++++------ auth.ts | 1 + package.json | 2 +- pnpm-lock.yaml | 8 ++++---- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/app/api/chat/route.ts b/app/api/chat/route.ts index 4f63d1e..3a9f472 100644 --- a/app/api/chat/route.ts +++ b/app/api/chat/route.ts @@ -7,6 +7,12 @@ import { nanoid } from '@/lib/utils' export const runtime = 'edge' +const configuration = new Configuration({ + apiKey: process.env.OPENAI_API_KEY +}) + +const openai = new OpenAIApi(configuration) + export async function POST(req: Request) { const json = await req.json() const { messages, previewToken } = json @@ -18,11 +24,9 @@ export async function POST(req: Request) { } } - const configuration = new Configuration({ - apiKey: previewToken || process.env.OPENAI_API_KEY - }) - - const openai = new OpenAIApi(configuration) + if (previewToken) { + configuration.apiKey = previewToken + } const res = await openai.createChatCompletion({ model: 'gpt-3.5-turbo', @@ -34,7 +38,7 @@ export async function POST(req: Request) { const stream = OpenAIStream(res, { async onCompletion(completion) { const title = json.messages[0].content.substring(0, 100) - const userId = session?.user.id + const userId = session?.user?.id if (userId) { const id = json.id ?? nanoid() const createdAt = Date.now() diff --git a/auth.ts b/auth.ts index a73db04..0b714d6 100644 --- a/auth.ts +++ b/auth.ts @@ -15,6 +15,7 @@ export const { auth, CSRF_experimental } = NextAuth({ + // @ts-ignore providers: [GitHub], callbacks: { jwt: async ({ token, profile }) => { diff --git a/package.json b/package.json index 918200c..ebd936c 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "@vercel/analytics": "^1.0.0", "@vercel/kv": "^0.2.1", "@vercel/og": "^0.5.7", - "ai": "^2.1.2", + "ai": "^2.1.6", "body-scroll-lock": "4.0.0-beta.0", "class-variance-authority": "^0.4.0", "clsx": "^1.2.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e6d3739..a16fd5b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -42,8 +42,8 @@ dependencies: specifier: ^0.5.7 version: 0.5.7 ai: - specifier: ^2.1.2 - version: 2.1.2(react@18.2.0)(svelte@3.59.2)(vue@3.3.4) + specifier: ^2.1.6 + version: 2.1.6(react@18.2.0)(svelte@3.59.2)(vue@3.3.4) body-scroll-lock: specifier: 4.0.0-beta.0 version: 4.0.0-beta.0 @@ -1481,8 +1481,8 @@ packages: hasBin: true dev: true - /ai@2.1.2(react@18.2.0)(svelte@3.59.2)(vue@3.3.4): - resolution: {integrity: sha512-WhyGH95Pv/gpgVMQT5eCyKXJh7irozr+bmpJ94somfRYBcAN2U270ii/OOHzGLrPM3liTbBilGQL2Ds7/5sz9Q==} + /ai@2.1.6(react@18.2.0)(svelte@3.59.2)(vue@3.3.4): + resolution: {integrity: sha512-YFCy7KEUDvuNGNuD8Bz7BynXB/eW2jJRAxAIM8Hb5/gpppZJs6/nTSdpocROxoGESJchtkFgYdygieG/wciEEQ==} engines: {node: '>=14.6'} peerDependencies: react: ^18.0.0 From b5f61e75f2d5939b50efb965314f8a73a0b68b6d Mon Sep 17 00:00:00 2001 From: Jared Palmer Date: Wed, 21 Jun 2023 13:32:05 -0700 Subject: [PATCH 16/26] Revert next-auth upgrade --- package.json | 2 +- pnpm-lock.yaml | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index ebd936c..fedf98d 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "focus-trap-react": "^10.1.1", "nanoid": "^4.0.2", "next": "13.4.7-canary.1", - "next-auth": "0.0.0-manual.e65faa1c", + "next-auth": "0.0.0-manual.f414f2f5", "next-themes": "^0.2.1", "openai-edge": "^0.5.1", "react": "^18.2.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a16fd5b..480d1bf 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -63,8 +63,8 @@ dependencies: specifier: 13.4.7-canary.1 version: 13.4.7-canary.1(react-dom@18.2.0)(react@18.2.0) next-auth: - specifier: 0.0.0-manual.e65faa1c - version: 0.0.0-manual.e65faa1c(next@13.4.7-canary.1)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.0-manual.f414f2f5 + version: 0.0.0-manual.f414f2f5(next@13.4.7-canary.1)(react-dom@18.2.0)(react@18.2.0) next-themes: specifier: ^0.2.1 version: 0.2.1(next@13.4.7-canary.1)(react-dom@18.2.0)(react@18.2.0) @@ -4142,8 +4142,8 @@ packages: resolution: {integrity: sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==} dev: true - /next-auth@0.0.0-manual.e65faa1c(next@13.4.7-canary.1)(react-dom@18.2.0)(react@18.2.0): - resolution: {integrity: sha512-I51GvhZhZEf/gzhiTKivYPAIyZ74sCF3YXAMMuZ/bjahybeehPEu7opcPEA+H0Uxrvmo2G8/BQ7mT+TiFdM9IQ==} + /next-auth@0.0.0-manual.f414f2f5(next@13.4.7-canary.1)(react-dom@18.2.0)(react@18.2.0): + resolution: {integrity: sha512-qJmSX4QUV8V2JOQavl0fQyJymt0fte7eDQsMGTpx8ZRU2Qvx8uh+xrvXlHt3dXf603OB3QkWaj77ipIEt62Hfg==} peerDependencies: next: ^13.4.5 nodemailer: ^6.6.5 @@ -4153,6 +4153,7 @@ packages: nodemailer: optional: true dependencies: + '@auth/core': 0.0.0-manual.8fcd46b0 '@auth/nextjs': 0.0.0-manual.b53ca00b(next@13.4.7-canary.1)(react@18.2.0) next: 13.4.7-canary.1(react-dom@18.2.0)(react@18.2.0) react: 18.2.0 From 9d63e761a8774db3bc8dc5656bae33fa9ddb265e Mon Sep 17 00:00:00 2001 From: Jared Palmer Date: Wed, 21 Jun 2023 14:01:05 -0700 Subject: [PATCH 17/26] Only ask for tokens on preview --- app/api/chat/route.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/api/chat/route.ts b/app/api/chat/route.ts index 3a9f472..b39b26c 100644 --- a/app/api/chat/route.ts +++ b/app/api/chat/route.ts @@ -18,7 +18,7 @@ export async function POST(req: Request) { const { messages, previewToken } = json const session = await auth() - if (process.env.VERCEL_ENV !== 'preview') { + if (process.env.VERCEL_ENV === 'preview') { if (session == null) { return new Response('Unauthorized', { status: 401 }) } From b9c111b38944c0098293a51c881c13041f9ce545 Mon Sep 17 00:00:00 2001 From: Jared Palmer Date: Wed, 21 Jun 2023 14:05:00 -0700 Subject: [PATCH 18/26] Bump next-auth --- package.json | 2 +- pnpm-lock.yaml | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index fedf98d..ebd936c 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "focus-trap-react": "^10.1.1", "nanoid": "^4.0.2", "next": "13.4.7-canary.1", - "next-auth": "0.0.0-manual.f414f2f5", + "next-auth": "0.0.0-manual.e65faa1c", "next-themes": "^0.2.1", "openai-edge": "^0.5.1", "react": "^18.2.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 480d1bf..a16fd5b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -63,8 +63,8 @@ dependencies: specifier: 13.4.7-canary.1 version: 13.4.7-canary.1(react-dom@18.2.0)(react@18.2.0) next-auth: - specifier: 0.0.0-manual.f414f2f5 - version: 0.0.0-manual.f414f2f5(next@13.4.7-canary.1)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.0-manual.e65faa1c + version: 0.0.0-manual.e65faa1c(next@13.4.7-canary.1)(react-dom@18.2.0)(react@18.2.0) next-themes: specifier: ^0.2.1 version: 0.2.1(next@13.4.7-canary.1)(react-dom@18.2.0)(react@18.2.0) @@ -4142,8 +4142,8 @@ packages: resolution: {integrity: sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==} dev: true - /next-auth@0.0.0-manual.f414f2f5(next@13.4.7-canary.1)(react-dom@18.2.0)(react@18.2.0): - resolution: {integrity: sha512-qJmSX4QUV8V2JOQavl0fQyJymt0fte7eDQsMGTpx8ZRU2Qvx8uh+xrvXlHt3dXf603OB3QkWaj77ipIEt62Hfg==} + /next-auth@0.0.0-manual.e65faa1c(next@13.4.7-canary.1)(react-dom@18.2.0)(react@18.2.0): + resolution: {integrity: sha512-I51GvhZhZEf/gzhiTKivYPAIyZ74sCF3YXAMMuZ/bjahybeehPEu7opcPEA+H0Uxrvmo2G8/BQ7mT+TiFdM9IQ==} peerDependencies: next: ^13.4.5 nodemailer: ^6.6.5 @@ -4153,7 +4153,6 @@ packages: nodemailer: optional: true dependencies: - '@auth/core': 0.0.0-manual.8fcd46b0 '@auth/nextjs': 0.0.0-manual.b53ca00b(next@13.4.7-canary.1)(react@18.2.0) next: 13.4.7-canary.1(react-dom@18.2.0)(react@18.2.0) react: 18.2.0 From aa1b55b4256131d167623cbb8a986e909b87496b Mon Sep 17 00:00:00 2001 From: Jared Palmer Date: Wed, 21 Jun 2023 14:10:32 -0700 Subject: [PATCH 19/26] Revert next-auth --- package.json | 7 ++++++- pnpm-lock.yaml | 24 ++++++++++++++---------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index ebd936c..8dbc372 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "focus-trap-react": "^10.1.1", "nanoid": "^4.0.2", "next": "13.4.7-canary.1", - "next-auth": "0.0.0-manual.e65faa1c", + "next-auth": "0.0.0-manual.4cd21ea5", "next-themes": "^0.2.1", "openai-edge": "^0.5.1", "react": "^18.2.0", @@ -67,5 +67,10 @@ "tailwindcss-animate": "^1.0.5", "typescript": "^5.1.3" }, + "pnpm": { + "overrides": { + "@auth/nextjs": "0.0.0-manual.de744368" + } + }, "packageManager": "pnpm@8.6.1" } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a16fd5b..6a32dfb 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -4,6 +4,9 @@ settings: autoInstallPeers: true excludeLinksFromLockfile: false +overrides: + '@auth/nextjs': 0.0.0-manual.de744368 + dependencies: '@radix-ui/react-alert-dialog': specifier: ^1.0.4 @@ -63,8 +66,8 @@ dependencies: specifier: 13.4.7-canary.1 version: 13.4.7-canary.1(react-dom@18.2.0)(react@18.2.0) next-auth: - specifier: 0.0.0-manual.e65faa1c - version: 0.0.0-manual.e65faa1c(next@13.4.7-canary.1)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.0-manual.4cd21ea5 + version: 0.0.0-manual.4cd21ea5(next@13.4.7-canary.1)(react-dom@18.2.0)(react@18.2.0) next-themes: specifier: ^0.2.1 version: 0.2.1(next@13.4.7-canary.1)(react-dom@18.2.0)(react@18.2.0) @@ -165,8 +168,8 @@ packages: engines: {node: '>=10'} dev: true - /@auth/core@0.0.0-manual.8fcd46b0: - resolution: {integrity: sha512-KuhvZ0hHz6NvMAgAi+su0dJOD0YAiOWGaLswyfGK5RsG/cdhqyyiII9HOTaZbWZAKir0UGYb8SlN+owhV30JXg==} + /@auth/core@0.8.2: + resolution: {integrity: sha512-swqJ7tKFlqiYIl1znFGrrawUv1F6rwL+/f3DoeWDaZLnr2phiHFaZsvNvLK7WBJhnJbel78Vd3GznuR31AnFUw==} peerDependencies: nodemailer: ^6.8.0 peerDependenciesMeta: @@ -181,13 +184,13 @@ packages: preact-render-to-string: 5.2.3(preact@10.11.3) dev: false - /@auth/nextjs@0.0.0-manual.b53ca00b(next@13.4.7-canary.1)(react@18.2.0): - resolution: {integrity: sha512-g0XvlP+3MSXPX512K6Hu0mGOkb1QPCkXkaA0Zr9i+bmTEDU9TtYTTNmX2EyvLeTfmrEEU/CMS92aWTmiki1KVA==} + /@auth/nextjs@0.0.0-manual.de744368(next@13.4.7-canary.1)(react@18.2.0): + resolution: {integrity: sha512-jLjKasLTKH5YLiK2i0NQWbsQS1pMveidyFT/ibwZ6c5UAcqDsC6ZGvvVxOaiAmiA6iFA1WMqNBVEcy+NhGgXVQ==} peerDependencies: next: ^13.4.6 react: ^18.2.0 dependencies: - '@auth/core': 0.0.0-manual.8fcd46b0 + '@auth/core': 0.8.2 next: 13.4.7-canary.1(react-dom@18.2.0)(react@18.2.0) react: 18.2.0 transitivePeerDependencies: @@ -4142,8 +4145,8 @@ packages: resolution: {integrity: sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==} dev: true - /next-auth@0.0.0-manual.e65faa1c(next@13.4.7-canary.1)(react-dom@18.2.0)(react@18.2.0): - resolution: {integrity: sha512-I51GvhZhZEf/gzhiTKivYPAIyZ74sCF3YXAMMuZ/bjahybeehPEu7opcPEA+H0Uxrvmo2G8/BQ7mT+TiFdM9IQ==} + /next-auth@0.0.0-manual.4cd21ea5(next@13.4.7-canary.1)(react-dom@18.2.0)(react@18.2.0): + resolution: {integrity: sha512-qzsrs2xeopmIYUz1C+FbudBIoNI7xSTd1xWeECr/Qa4NFzbCt8Dr9tb2Yocpa5jnRpk0xN96HwsJqimOYVjtRg==} peerDependencies: next: ^13.4.5 nodemailer: ^6.6.5 @@ -4153,7 +4156,8 @@ packages: nodemailer: optional: true dependencies: - '@auth/nextjs': 0.0.0-manual.b53ca00b(next@13.4.7-canary.1)(react@18.2.0) + '@auth/core': 0.8.2 + '@auth/nextjs': 0.0.0-manual.de744368(next@13.4.7-canary.1)(react@18.2.0) next: 13.4.7-canary.1(react-dom@18.2.0)(react@18.2.0) react: 18.2.0 react-dom: 18.2.0(react@18.2.0) From 6f51b016216b9e61ebb4a8505ea4a4b0245c954a Mon Sep 17 00:00:00 2001 From: Jared Palmer Date: Wed, 21 Jun 2023 14:12:59 -0700 Subject: [PATCH 20/26] Revert next-auth --- package.json | 2 +- pnpm-lock.yaml | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 8dbc372..353f59f 100644 --- a/package.json +++ b/package.json @@ -69,7 +69,7 @@ }, "pnpm": { "overrides": { - "@auth/nextjs": "0.0.0-manual.de744368" + "@auth/nextjs": "0.0.0-manual.223c6467" } }, "packageManager": "pnpm@8.6.1" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6a32dfb..79eced8 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -5,7 +5,7 @@ settings: excludeLinksFromLockfile: false overrides: - '@auth/nextjs': 0.0.0-manual.de744368 + '@auth/nextjs': 0.0.0-manual.223c6467 dependencies: '@radix-ui/react-alert-dialog': @@ -184,10 +184,10 @@ packages: preact-render-to-string: 5.2.3(preact@10.11.3) dev: false - /@auth/nextjs@0.0.0-manual.de744368(next@13.4.7-canary.1)(react@18.2.0): - resolution: {integrity: sha512-jLjKasLTKH5YLiK2i0NQWbsQS1pMveidyFT/ibwZ6c5UAcqDsC6ZGvvVxOaiAmiA6iFA1WMqNBVEcy+NhGgXVQ==} + /@auth/nextjs@0.0.0-manual.223c6467(next@13.4.7-canary.1)(react@18.2.0): + resolution: {integrity: sha512-nO6TMZ67ysq5lwpffQofxVLlTDHBLYX2x6VNXCXqbOoapofAk1qKyJ57lelHQdgV3py6qqWej/bTa4fDL19IDw==} peerDependencies: - next: ^13.4.6 + next: ^13.4.2 react: ^18.2.0 dependencies: '@auth/core': 0.8.2 @@ -4157,7 +4157,7 @@ packages: optional: true dependencies: '@auth/core': 0.8.2 - '@auth/nextjs': 0.0.0-manual.de744368(next@13.4.7-canary.1)(react@18.2.0) + '@auth/nextjs': 0.0.0-manual.223c6467(next@13.4.7-canary.1)(react@18.2.0) next: 13.4.7-canary.1(react-dom@18.2.0)(react@18.2.0) react: 18.2.0 react-dom: 18.2.0(react@18.2.0) From 8841f5570f8e5bd327e685b39e1c9b27071195b6 Mon Sep 17 00:00:00 2001 From: Jared Palmer Date: Wed, 21 Jun 2023 14:19:13 -0700 Subject: [PATCH 21/26] Revert all next-auth changes --- auth.ts | 15 ++++----------- next-auth.d.ts | 13 +++++++++++++ tsconfig.json | 1 + 3 files changed, 18 insertions(+), 11 deletions(-) create mode 100644 next-auth.d.ts diff --git a/auth.ts b/auth.ts index 0b714d6..5c7c1dd 100644 --- a/auth.ts +++ b/auth.ts @@ -1,25 +1,18 @@ -import NextAuth, { type DefaultSession } from 'next-auth' +import NextAuth from 'next-auth' import GitHub from 'next-auth/providers/github' -declare module 'next-auth' { - interface Session { - user: { - /** The user's id. */ - id: string - } & DefaultSession['user'] - } -} - export const { handlers: { GET, POST }, auth, CSRF_experimental + // @ts-ignore } = NextAuth({ // @ts-ignore providers: [GitHub], callbacks: { + // @ts-ignore jwt: async ({ token, profile }) => { - if (profile) { + if (profile?.id) { token.id = profile.id token.image = profile.picture } diff --git a/next-auth.d.ts b/next-auth.d.ts new file mode 100644 index 0000000..918e14d --- /dev/null +++ b/next-auth.d.ts @@ -0,0 +1,13 @@ +import NextAuth, { DefaultSession } from 'next-auth' + +declare module 'next-auth' { + /** + * Returned by `useSession`, `getSession` and received as a prop on the `SessionProvider` React Context + */ + interface Session { + user: { + /** The user's postal address. */ + id: string + } & DefaultSession['user'] + } +} diff --git a/tsconfig.json b/tsconfig.json index 9be1cf1..9f91b9b 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -26,6 +26,7 @@ }, "include": [ "next-env.d.ts", + "next-auth.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts" From 28f62d80cf90cb24beb837932c308f3a14bb5230 Mon Sep 17 00:00:00 2001 From: Jared Palmer Date: Wed, 21 Jun 2023 14:24:27 -0700 Subject: [PATCH 22/26] Remove auth at edge --- app/api/auth/[...nextauth]/route.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/app/api/auth/[...nextauth]/route.ts b/app/api/auth/[...nextauth]/route.ts index 883210b..35e9719 100644 --- a/app/api/auth/[...nextauth]/route.ts +++ b/app/api/auth/[...nextauth]/route.ts @@ -1,2 +1 @@ export { GET, POST } from '@/auth' -export const runtime = 'edge' From f2ae20d26b3d0f22c5aa78a67436449a6a07a590 Mon Sep 17 00:00:00 2001 From: Jared Palmer Date: Wed, 21 Jun 2023 14:29:19 -0700 Subject: [PATCH 23/26] Fix next-auth --- auth.ts | 16 +++++++++++++--- next-auth.d.ts | 13 ------------- package.json | 7 +------ pnpm-lock.yaml | 26 +++++++++++--------------- tsconfig.json | 8 +------- 5 files changed, 26 insertions(+), 44 deletions(-) delete mode 100644 next-auth.d.ts diff --git a/auth.ts b/auth.ts index 5c7c1dd..6b806b4 100644 --- a/auth.ts +++ b/auth.ts @@ -1,16 +1,26 @@ -import NextAuth from 'next-auth' +import NextAuth, { type DefaultSession } from 'next-auth' import GitHub from 'next-auth/providers/github' +declare module 'next-auth' { + /** + * Returned by `useSession`, `getSession` and received as a prop on the `SessionProvider` React Context + */ + interface Session { + user: { + /** The user's postal address. */ + id: string + } & DefaultSession['user'] + } +} + export const { handlers: { GET, POST }, auth, CSRF_experimental - // @ts-ignore } = NextAuth({ // @ts-ignore providers: [GitHub], callbacks: { - // @ts-ignore jwt: async ({ token, profile }) => { if (profile?.id) { token.id = profile.id diff --git a/next-auth.d.ts b/next-auth.d.ts deleted file mode 100644 index 918e14d..0000000 --- a/next-auth.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -import NextAuth, { DefaultSession } from 'next-auth' - -declare module 'next-auth' { - /** - * Returned by `useSession`, `getSession` and received as a prop on the `SessionProvider` React Context - */ - interface Session { - user: { - /** The user's postal address. */ - id: string - } & DefaultSession['user'] - } -} diff --git a/package.json b/package.json index 353f59f..ebd936c 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "focus-trap-react": "^10.1.1", "nanoid": "^4.0.2", "next": "13.4.7-canary.1", - "next-auth": "0.0.0-manual.4cd21ea5", + "next-auth": "0.0.0-manual.e65faa1c", "next-themes": "^0.2.1", "openai-edge": "^0.5.1", "react": "^18.2.0", @@ -67,10 +67,5 @@ "tailwindcss-animate": "^1.0.5", "typescript": "^5.1.3" }, - "pnpm": { - "overrides": { - "@auth/nextjs": "0.0.0-manual.223c6467" - } - }, "packageManager": "pnpm@8.6.1" } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 79eced8..a16fd5b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -4,9 +4,6 @@ settings: autoInstallPeers: true excludeLinksFromLockfile: false -overrides: - '@auth/nextjs': 0.0.0-manual.223c6467 - dependencies: '@radix-ui/react-alert-dialog': specifier: ^1.0.4 @@ -66,8 +63,8 @@ dependencies: specifier: 13.4.7-canary.1 version: 13.4.7-canary.1(react-dom@18.2.0)(react@18.2.0) next-auth: - specifier: 0.0.0-manual.4cd21ea5 - version: 0.0.0-manual.4cd21ea5(next@13.4.7-canary.1)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.0-manual.e65faa1c + version: 0.0.0-manual.e65faa1c(next@13.4.7-canary.1)(react-dom@18.2.0)(react@18.2.0) next-themes: specifier: ^0.2.1 version: 0.2.1(next@13.4.7-canary.1)(react-dom@18.2.0)(react@18.2.0) @@ -168,8 +165,8 @@ packages: engines: {node: '>=10'} dev: true - /@auth/core@0.8.2: - resolution: {integrity: sha512-swqJ7tKFlqiYIl1znFGrrawUv1F6rwL+/f3DoeWDaZLnr2phiHFaZsvNvLK7WBJhnJbel78Vd3GznuR31AnFUw==} + /@auth/core@0.0.0-manual.8fcd46b0: + resolution: {integrity: sha512-KuhvZ0hHz6NvMAgAi+su0dJOD0YAiOWGaLswyfGK5RsG/cdhqyyiII9HOTaZbWZAKir0UGYb8SlN+owhV30JXg==} peerDependencies: nodemailer: ^6.8.0 peerDependenciesMeta: @@ -184,13 +181,13 @@ packages: preact-render-to-string: 5.2.3(preact@10.11.3) dev: false - /@auth/nextjs@0.0.0-manual.223c6467(next@13.4.7-canary.1)(react@18.2.0): - resolution: {integrity: sha512-nO6TMZ67ysq5lwpffQofxVLlTDHBLYX2x6VNXCXqbOoapofAk1qKyJ57lelHQdgV3py6qqWej/bTa4fDL19IDw==} + /@auth/nextjs@0.0.0-manual.b53ca00b(next@13.4.7-canary.1)(react@18.2.0): + resolution: {integrity: sha512-g0XvlP+3MSXPX512K6Hu0mGOkb1QPCkXkaA0Zr9i+bmTEDU9TtYTTNmX2EyvLeTfmrEEU/CMS92aWTmiki1KVA==} peerDependencies: - next: ^13.4.2 + next: ^13.4.6 react: ^18.2.0 dependencies: - '@auth/core': 0.8.2 + '@auth/core': 0.0.0-manual.8fcd46b0 next: 13.4.7-canary.1(react-dom@18.2.0)(react@18.2.0) react: 18.2.0 transitivePeerDependencies: @@ -4145,8 +4142,8 @@ packages: resolution: {integrity: sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==} dev: true - /next-auth@0.0.0-manual.4cd21ea5(next@13.4.7-canary.1)(react-dom@18.2.0)(react@18.2.0): - resolution: {integrity: sha512-qzsrs2xeopmIYUz1C+FbudBIoNI7xSTd1xWeECr/Qa4NFzbCt8Dr9tb2Yocpa5jnRpk0xN96HwsJqimOYVjtRg==} + /next-auth@0.0.0-manual.e65faa1c(next@13.4.7-canary.1)(react-dom@18.2.0)(react@18.2.0): + resolution: {integrity: sha512-I51GvhZhZEf/gzhiTKivYPAIyZ74sCF3YXAMMuZ/bjahybeehPEu7opcPEA+H0Uxrvmo2G8/BQ7mT+TiFdM9IQ==} peerDependencies: next: ^13.4.5 nodemailer: ^6.6.5 @@ -4156,8 +4153,7 @@ packages: nodemailer: optional: true dependencies: - '@auth/core': 0.8.2 - '@auth/nextjs': 0.0.0-manual.223c6467(next@13.4.7-canary.1)(react@18.2.0) + '@auth/nextjs': 0.0.0-manual.b53ca00b(next@13.4.7-canary.1)(react@18.2.0) next: 13.4.7-canary.1(react-dom@18.2.0)(react@18.2.0) react: 18.2.0 react-dom: 18.2.0(react@18.2.0) diff --git a/tsconfig.json b/tsconfig.json index 9f91b9b..1b03bc2 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -24,12 +24,6 @@ ], "strictNullChecks": true }, - "include": [ - "next-env.d.ts", - "next-auth.d.ts", - "**/*.ts", - "**/*.tsx", - ".next/types/**/*.ts" - ], + "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], "exclude": ["node_modules"] } From e9e40d7a081c55d3cf6923c222af9468f4b9e6cc Mon Sep 17 00:00:00 2001 From: Jared Palmer Date: Wed, 21 Jun 2023 14:32:54 -0700 Subject: [PATCH 24/26] Revert "Merge pull request #74 from vercel-labs:jp/next-auth" This reverts commit 6051e186b5c3820eb35b82bcb53a6c0e8498c25b, reversing changes made to 28f62d80cf90cb24beb837932c308f3a14bb5230. --- auth.ts | 16 +++------------- next-auth.d.ts | 13 +++++++++++++ package.json | 7 ++++++- pnpm-lock.yaml | 26 +++++++++++++++----------- tsconfig.json | 8 +++++++- 5 files changed, 44 insertions(+), 26 deletions(-) create mode 100644 next-auth.d.ts diff --git a/auth.ts b/auth.ts index 6b806b4..5c7c1dd 100644 --- a/auth.ts +++ b/auth.ts @@ -1,26 +1,16 @@ -import NextAuth, { type DefaultSession } from 'next-auth' +import NextAuth from 'next-auth' import GitHub from 'next-auth/providers/github' -declare module 'next-auth' { - /** - * Returned by `useSession`, `getSession` and received as a prop on the `SessionProvider` React Context - */ - interface Session { - user: { - /** The user's postal address. */ - id: string - } & DefaultSession['user'] - } -} - export const { handlers: { GET, POST }, auth, CSRF_experimental + // @ts-ignore } = NextAuth({ // @ts-ignore providers: [GitHub], callbacks: { + // @ts-ignore jwt: async ({ token, profile }) => { if (profile?.id) { token.id = profile.id diff --git a/next-auth.d.ts b/next-auth.d.ts new file mode 100644 index 0000000..918e14d --- /dev/null +++ b/next-auth.d.ts @@ -0,0 +1,13 @@ +import NextAuth, { DefaultSession } from 'next-auth' + +declare module 'next-auth' { + /** + * Returned by `useSession`, `getSession` and received as a prop on the `SessionProvider` React Context + */ + interface Session { + user: { + /** The user's postal address. */ + id: string + } & DefaultSession['user'] + } +} diff --git a/package.json b/package.json index ebd936c..353f59f 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "focus-trap-react": "^10.1.1", "nanoid": "^4.0.2", "next": "13.4.7-canary.1", - "next-auth": "0.0.0-manual.e65faa1c", + "next-auth": "0.0.0-manual.4cd21ea5", "next-themes": "^0.2.1", "openai-edge": "^0.5.1", "react": "^18.2.0", @@ -67,5 +67,10 @@ "tailwindcss-animate": "^1.0.5", "typescript": "^5.1.3" }, + "pnpm": { + "overrides": { + "@auth/nextjs": "0.0.0-manual.223c6467" + } + }, "packageManager": "pnpm@8.6.1" } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a16fd5b..79eced8 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -4,6 +4,9 @@ settings: autoInstallPeers: true excludeLinksFromLockfile: false +overrides: + '@auth/nextjs': 0.0.0-manual.223c6467 + dependencies: '@radix-ui/react-alert-dialog': specifier: ^1.0.4 @@ -63,8 +66,8 @@ dependencies: specifier: 13.4.7-canary.1 version: 13.4.7-canary.1(react-dom@18.2.0)(react@18.2.0) next-auth: - specifier: 0.0.0-manual.e65faa1c - version: 0.0.0-manual.e65faa1c(next@13.4.7-canary.1)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.0-manual.4cd21ea5 + version: 0.0.0-manual.4cd21ea5(next@13.4.7-canary.1)(react-dom@18.2.0)(react@18.2.0) next-themes: specifier: ^0.2.1 version: 0.2.1(next@13.4.7-canary.1)(react-dom@18.2.0)(react@18.2.0) @@ -165,8 +168,8 @@ packages: engines: {node: '>=10'} dev: true - /@auth/core@0.0.0-manual.8fcd46b0: - resolution: {integrity: sha512-KuhvZ0hHz6NvMAgAi+su0dJOD0YAiOWGaLswyfGK5RsG/cdhqyyiII9HOTaZbWZAKir0UGYb8SlN+owhV30JXg==} + /@auth/core@0.8.2: + resolution: {integrity: sha512-swqJ7tKFlqiYIl1znFGrrawUv1F6rwL+/f3DoeWDaZLnr2phiHFaZsvNvLK7WBJhnJbel78Vd3GznuR31AnFUw==} peerDependencies: nodemailer: ^6.8.0 peerDependenciesMeta: @@ -181,13 +184,13 @@ packages: preact-render-to-string: 5.2.3(preact@10.11.3) dev: false - /@auth/nextjs@0.0.0-manual.b53ca00b(next@13.4.7-canary.1)(react@18.2.0): - resolution: {integrity: sha512-g0XvlP+3MSXPX512K6Hu0mGOkb1QPCkXkaA0Zr9i+bmTEDU9TtYTTNmX2EyvLeTfmrEEU/CMS92aWTmiki1KVA==} + /@auth/nextjs@0.0.0-manual.223c6467(next@13.4.7-canary.1)(react@18.2.0): + resolution: {integrity: sha512-nO6TMZ67ysq5lwpffQofxVLlTDHBLYX2x6VNXCXqbOoapofAk1qKyJ57lelHQdgV3py6qqWej/bTa4fDL19IDw==} peerDependencies: - next: ^13.4.6 + next: ^13.4.2 react: ^18.2.0 dependencies: - '@auth/core': 0.0.0-manual.8fcd46b0 + '@auth/core': 0.8.2 next: 13.4.7-canary.1(react-dom@18.2.0)(react@18.2.0) react: 18.2.0 transitivePeerDependencies: @@ -4142,8 +4145,8 @@ packages: resolution: {integrity: sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==} dev: true - /next-auth@0.0.0-manual.e65faa1c(next@13.4.7-canary.1)(react-dom@18.2.0)(react@18.2.0): - resolution: {integrity: sha512-I51GvhZhZEf/gzhiTKivYPAIyZ74sCF3YXAMMuZ/bjahybeehPEu7opcPEA+H0Uxrvmo2G8/BQ7mT+TiFdM9IQ==} + /next-auth@0.0.0-manual.4cd21ea5(next@13.4.7-canary.1)(react-dom@18.2.0)(react@18.2.0): + resolution: {integrity: sha512-qzsrs2xeopmIYUz1C+FbudBIoNI7xSTd1xWeECr/Qa4NFzbCt8Dr9tb2Yocpa5jnRpk0xN96HwsJqimOYVjtRg==} peerDependencies: next: ^13.4.5 nodemailer: ^6.6.5 @@ -4153,7 +4156,8 @@ packages: nodemailer: optional: true dependencies: - '@auth/nextjs': 0.0.0-manual.b53ca00b(next@13.4.7-canary.1)(react@18.2.0) + '@auth/core': 0.8.2 + '@auth/nextjs': 0.0.0-manual.223c6467(next@13.4.7-canary.1)(react@18.2.0) next: 13.4.7-canary.1(react-dom@18.2.0)(react@18.2.0) react: 18.2.0 react-dom: 18.2.0(react@18.2.0) diff --git a/tsconfig.json b/tsconfig.json index 1b03bc2..9f91b9b 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -24,6 +24,12 @@ ], "strictNullChecks": true }, - "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], + "include": [ + "next-env.d.ts", + "next-auth.d.ts", + "**/*.ts", + "**/*.tsx", + ".next/types/**/*.ts" + ], "exclude": ["node_modules"] } From 0117cdfa5417762ede681546e070d74b4f4848f4 Mon Sep 17 00:00:00 2001 From: Jared Palmer Date: Wed, 21 Jun 2023 14:42:18 -0700 Subject: [PATCH 25/26] Fix auth --- components/header.tsx | 23 +++++++++++------------ components/login-button.tsx | 1 + 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/components/header.tsx b/components/header.tsx index b08bd46..24a3e45 100644 --- a/components/header.tsx +++ b/components/header.tsx @@ -4,7 +4,7 @@ import Link from 'next/link' import { cn } from '@/lib/utils' import { auth } from '@/auth' import { clearChats } from '@/app/actions' -import { buttonVariants } from '@/components/ui/button' +import { Button, buttonVariants } from '@/components/ui/button' import { Sidebar } from '@/components/sidebar' import { SidebarList } from '@/components/sidebar-list' import { @@ -22,7 +22,7 @@ import { LoginButton } from '@/components/login-button' export async function Header() { const session = await auth() return ( -
+
{session?.user ? ( @@ -37,21 +37,20 @@ export async function Header() { ) : ( - - + + )}
- + {session?.user ? ( ) : ( - + )}
@@ -63,7 +62,7 @@ export async function Header() { className={cn(buttonVariants({ variant: 'outline' }))} > - GitHub + GitHub { setIsLoading(true) + // next-auth signIn() function doesn't work yet at Edge Runtime due to usage of BroadcastChannel signIn('github', { callbackUrl: `/` }) }} disabled={isLoading} From 2dad7170723d8476331548748daa294b55564e51 Mon Sep 17 00:00:00 2001 From: Jared Palmer Date: Wed, 21 Jun 2023 16:26:19 -0700 Subject: [PATCH 26/26] Send a callbackUrl to /sign-in --- components/header.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/components/header.tsx b/components/header.tsx index 24a3e45..3ff0dd6 100644 --- a/components/header.tsx +++ b/components/header.tsx @@ -47,9 +47,7 @@ export async function Header() { ) : ( )}