diff --git a/__test__/story.e2e.ts b/__test__/story.e2e.ts index d635de5a..ff5b84d9 100644 --- a/__test__/story.e2e.ts +++ b/__test__/story.e2e.ts @@ -3,7 +3,6 @@ import { test, expect } from '@playwright/test'; import { PrismaClient } from '@prisma/client'; import { resolveFixturePath } from '../fixtures'; import { generateId } from '@/common/util/id'; -import { RECAPTCHA_COOKIE_KEY } from '@/common/util/grecaptcha'; const BASE_URL = 'http://localhost:3000'; @@ -58,12 +57,6 @@ test('質問の送信', async ({ page }) => { }) await page.goto(BASE_URL + "/stories/" + storyId); - process.env.MACHINE_TOKEN && await page.context().addCookies([{ - name: RECAPTCHA_COOKIE_KEY, - value: process.env.MACHINE_TOKEN, - url: BASE_URL, - httpOnly: true - }]); await page.waitForLoadState("networkidle") const input = await page.getByRole('textbox', { name: "AIへの質問" }); await input.fill("あなたはAIですか?"); diff --git a/package-lock.json b/package-lock.json index c5b3c639..730a4949 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "0.1.0", "hasInstallScript": true, "dependencies": { - "@anthropic-ai/sdk": "0.25.1", + "@anthropic-ai/sdk": "0.25.2", "@hookform/resolvers": "3.1.0", "@prisma/client": "5.18.0", "@szhsin/react-menu": "4.2.2", @@ -23,7 +23,7 @@ "mustache": "4.2.0", "next": "14.2.5", "next-auth": "4.24.7", - "openai": "4.55.4", + "openai": "4.55.5", "randomstring": "1.3.0", "react": "18.3.1", "react-copy-to-clipboard": "5.1.0", @@ -45,7 +45,7 @@ "devDependencies": { "@axe-core/playwright": "4.9.1", "@biomejs/biome": "1.8.3", - "@eslint/config-array": "0.17.1", + "@eslint/config-array": "0.18.0", "@eslint/object-schema": "2.1.4", "@next/bundle-analyzer": "14.2.5", "@playwright/test": "1.46.0", @@ -111,9 +111,9 @@ } }, "node_modules/@anthropic-ai/sdk": { - "version": "0.25.1", - "resolved": "https://registry.npmjs.org/@anthropic-ai/sdk/-/sdk-0.25.1.tgz", - "integrity": "sha512-+qF6hRax1XzpbZTy1YqQMTwOPY3W1B5PFS5ZXgmPl1V/lDqXm2uYFCpnSR3DREz1FRZ4lflzbK1cAhr88FvCpw==", + "version": "0.25.2", + "resolved": "https://registry.npmjs.org/@anthropic-ai/sdk/-/sdk-0.25.2.tgz", + "integrity": "sha512-F1Hck/asswwidFLtGdMg3XYgRxEUfygNbpkq5KEaEGsHNaSfxeX18/uZGQCL0oQNcj/tYNx8BaFXVwRhFDi45g==", "dependencies": { "@types/node": "^18.11.18", "@types/node-fetch": "^2.6.4", @@ -125,9 +125,9 @@ } }, "node_modules/@anthropic-ai/sdk/node_modules/@types/node": { - "version": "18.19.43", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.43.tgz", - "integrity": "sha512-Mw/YlgXnyJdEwLoFv2dpuJaDFriX+Pc+0qOBJ57jC1H6cDxIj2xc5yUrdtArDVG0m+KV6622a4p2tenEqB3C/g==", + "version": "18.19.44", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.44.tgz", + "integrity": "sha512-ZsbGerYg72WMXUIE9fYxtvfzLEuq6q8mKERdWFnqTmOvudMxnz+CBNRoOwJ2kNpFOncrKjT1hZwxjlFgQ9qvQA==", "dependencies": { "undici-types": "~5.26.4" } @@ -3085,9 +3085,9 @@ } }, "node_modules/@eslint/config-array": { - "version": "0.17.1", - "resolved": "https://registry.npmjs.org/@eslint/config-array/-/config-array-0.17.1.tgz", - "integrity": "sha512-BlYOpej8AQ8Ev9xVqroV7a02JK3SkBAaN9GfMMH9W6Ch8FlQlkjGw4Ir7+FgYwfirivAf4t+GtzuAxqfukmISA==", + "version": "0.18.0", + "resolved": "https://registry.npmjs.org/@eslint/config-array/-/config-array-0.18.0.tgz", + "integrity": "sha512-fTxvnS1sRMu3+JjXwJG0j/i4RT9u4qJ+lqS/yCGap4lH4zZGzQ7tu+xZqQmcMZq5OBZDL4QRxQzRjkWcGt8IVw==", "dev": true, "dependencies": { "@eslint/object-schema": "^2.1.4", @@ -17303,9 +17303,9 @@ } }, "node_modules/openai": { - "version": "4.55.4", - "resolved": "https://registry.npmjs.org/openai/-/openai-4.55.4.tgz", - "integrity": "sha512-TEC75Y6U/OKIJp9fHao3zkTYfKLYGqXdD2TI+xN2Zd5W8KNKvv6E4/OBTOW7jg7fySfrBrhy5fYzBbyBcdHEtQ==", + "version": "4.55.5", + "resolved": "https://registry.npmjs.org/openai/-/openai-4.55.5.tgz", + "integrity": "sha512-9OkMAMljFv1LxUFf5HLm/pw7zFd4yMgW+lKOYF80RBwuGWU+ZKF5BQGll+TEGAHu23YMeT8t6VSxI27c/DRAOA==", "dependencies": { "@types/node": "^18.11.18", "@types/node-fetch": "^2.6.4", @@ -22676,9 +22676,9 @@ } }, "@anthropic-ai/sdk": { - "version": "0.25.1", - "resolved": "https://registry.npmjs.org/@anthropic-ai/sdk/-/sdk-0.25.1.tgz", - "integrity": "sha512-+qF6hRax1XzpbZTy1YqQMTwOPY3W1B5PFS5ZXgmPl1V/lDqXm2uYFCpnSR3DREz1FRZ4lflzbK1cAhr88FvCpw==", + "version": "0.25.2", + "resolved": "https://registry.npmjs.org/@anthropic-ai/sdk/-/sdk-0.25.2.tgz", + "integrity": "sha512-F1Hck/asswwidFLtGdMg3XYgRxEUfygNbpkq5KEaEGsHNaSfxeX18/uZGQCL0oQNcj/tYNx8BaFXVwRhFDi45g==", "requires": { "@types/node": "^18.11.18", "@types/node-fetch": "^2.6.4", @@ -22690,9 +22690,9 @@ }, "dependencies": { "@types/node": { - "version": "18.19.43", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.43.tgz", - "integrity": "sha512-Mw/YlgXnyJdEwLoFv2dpuJaDFriX+Pc+0qOBJ57jC1H6cDxIj2xc5yUrdtArDVG0m+KV6622a4p2tenEqB3C/g==", + "version": "18.19.44", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.44.tgz", + "integrity": "sha512-ZsbGerYg72WMXUIE9fYxtvfzLEuq6q8mKERdWFnqTmOvudMxnz+CBNRoOwJ2kNpFOncrKjT1hZwxjlFgQ9qvQA==", "requires": { "undici-types": "~5.26.4" } @@ -24652,9 +24652,9 @@ "dev": true }, "@eslint/config-array": { - "version": "0.17.1", - "resolved": "https://registry.npmjs.org/@eslint/config-array/-/config-array-0.17.1.tgz", - "integrity": "sha512-BlYOpej8AQ8Ev9xVqroV7a02JK3SkBAaN9GfMMH9W6Ch8FlQlkjGw4Ir7+FgYwfirivAf4t+GtzuAxqfukmISA==", + "version": "0.18.0", + "resolved": "https://registry.npmjs.org/@eslint/config-array/-/config-array-0.18.0.tgz", + "integrity": "sha512-fTxvnS1sRMu3+JjXwJG0j/i4RT9u4qJ+lqS/yCGap4lH4zZGzQ7tu+xZqQmcMZq5OBZDL4QRxQzRjkWcGt8IVw==", "dev": true, "requires": { "@eslint/object-schema": "^2.1.4", @@ -34745,9 +34745,9 @@ } }, "openai": { - "version": "4.55.4", - "resolved": "https://registry.npmjs.org/openai/-/openai-4.55.4.tgz", - "integrity": "sha512-TEC75Y6U/OKIJp9fHao3zkTYfKLYGqXdD2TI+xN2Zd5W8KNKvv6E4/OBTOW7jg7fySfrBrhy5fYzBbyBcdHEtQ==", + "version": "4.55.5", + "resolved": "https://registry.npmjs.org/openai/-/openai-4.55.5.tgz", + "integrity": "sha512-9OkMAMljFv1LxUFf5HLm/pw7zFd4yMgW+lKOYF80RBwuGWU+ZKF5BQGll+TEGAHu23YMeT8t6VSxI27c/DRAOA==", "requires": { "@types/node": "^18.11.18", "@types/node-fetch": "^2.6.4", diff --git a/package.json b/package.json index 73b2339d..4a1b3863 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "build-storybook": "storybook build" }, "dependencies": { - "@anthropic-ai/sdk": "0.25.1", + "@anthropic-ai/sdk": "0.25.2", "@hookform/resolvers": "3.1.0", "@prisma/client": "5.18.0", "@szhsin/react-menu": "4.2.2", @@ -32,7 +32,7 @@ "mustache": "4.2.0", "next": "14.2.5", "next-auth": "4.24.7", - "openai": "4.55.4", + "openai": "4.55.5", "randomstring": "1.3.0", "react": "18.3.1", "react-copy-to-clipboard": "5.1.0", @@ -54,7 +54,7 @@ "devDependencies": { "@axe-core/playwright": "4.9.1", "@biomejs/biome": "1.8.3", - "@eslint/config-array": "0.17.1", + "@eslint/config-array": "0.18.0", "@eslint/object-schema": "2.1.4", "@next/bundle-analyzer": "14.2.5", "@playwright/test": "1.46.0", diff --git a/src/app/stories/[storyId]/page.tsx b/src/app/stories/[storyId]/page.tsx index 0399b39c..e99ef236 100644 --- a/src/app/stories/[storyId]/page.tsx +++ b/src/app/stories/[storyId]/page.tsx @@ -8,7 +8,6 @@ import { getUserSession } from "@/server/serverComponent/getUserSession"; import { setupABTestValue } from "@/server/serverComponent/setupABTestingVariant"; import { checkAnswer } from "@/server/services/answer"; import { askQuestion } from "@/server/services/question"; -import { verifyRecaptcha } from "@/server/services/recaptcha"; import { getStories, getStory } from "@/server/services/story"; import { deleteStory } from "@/server/services/story/deleteStory"; import { @@ -187,12 +186,10 @@ export default async function StoryPage({ params: { storyId } }: StoryProps) { }} sendQuestion={async (input) => { "use server"; - await verifyRecaptcha(input.recaptchaToken); return askQuestion(input.text, story, setupABTestValue()); }} checkAnswer={async (input) => { "use server"; - await verifyRecaptcha(input.recaptchaToken); return checkAnswer(input.text, story); }} postStoryEvalution={async () => { diff --git a/src/app/verification/page.tsx b/src/app/verification/page.tsx new file mode 100644 index 00000000..9dbf7c19 --- /dev/null +++ b/src/app/verification/page.tsx @@ -0,0 +1 @@ +export default async function Verification() {} diff --git a/src/common/util/grecaptcha.ts b/src/common/util/grecaptcha.ts deleted file mode 100644 index 57c76fc4..00000000 --- a/src/common/util/grecaptcha.ts +++ /dev/null @@ -1,21 +0,0 @@ -export const CLIENT_KEY = "6LcvVxAmAAAAABH21d-xJ76J1djolWL3WMaMV8ne"; - -export const RECAPTCHA_COOKIE_KEY = "recaptcha-token"; - -export const getRecaptchaToken = async (): Promise => { - return new Promise((resolve, reject) => { - const timer = setTimeout(() => { - reject("timeout"); - }, 1000); - // @ts-ignore - const grecaptcha = window.grecaptcha; - grecaptcha.ready(() => { - grecaptcha - .execute(CLIENT_KEY, { action: "submit" }) - .then((token: string) => { - clearTimeout(timer); - resolve(token); - }); - }); - }); -}; diff --git a/src/components/play/index.tsx b/src/components/play/index.tsx index e31b3ee8..eb8cc616 100644 --- a/src/components/play/index.tsx +++ b/src/components/play/index.tsx @@ -1,5 +1,4 @@ "use client"; -import { CLIENT_KEY, getRecaptchaToken } from "@/common/util/grecaptcha"; import { gtagEvent } from "@/common/util/gtag"; import { Button } from "@/designSystem/components/button"; import type { @@ -8,7 +7,6 @@ import type { answer as answerSchema, } from "@/server/model/story"; import { useMutation, useQuery } from "@tanstack/react-query"; -import Script from "next/script"; import { useCallback, useState } from "react"; import { z } from "zod"; import { useConfirmModal } from "../confirmModal"; @@ -35,14 +33,12 @@ type Props = { >; sendQuestion: (args: { text: string; - recaptchaToken: string; }) => Promise<{ answer: z.infer; hitQuestionExample: QuestionExampleWithCustomMessage | null; }>; checkAnswer: (args: { text: string; - recaptchaToken: string; }) => Promise<{ isCorrect: boolean; distance: number; @@ -55,7 +51,6 @@ const AnswerFormContainer: React.FC<{ changeMode: (mode: Mode) => void; checkAnswer: (args: { text: string; - recaptchaToken: string; }) => Promise<{ isCorrect: boolean; distance: number; @@ -66,7 +61,6 @@ const AnswerFormContainer: React.FC<{ async (text: string) => { const response = await checkAnswer({ text: text, - recaptchaToken: await getRecaptchaToken(), }); return { ...response, @@ -159,12 +153,9 @@ export function Play({ return ; } } + return ( <> -