@lucidcms/core
Version:
The core of the Lucid CMS. It's responsible for spinning up the API and serving the CMS.
1 lines • 1.53 kB
Source Map (JSON)
{"version":3,"file":"verify-token.mjs","names":["constants"],"sources":["../../../../src/services/auth/csrf/verify-token.ts"],"sourcesContent":["import { getCookie } from \"hono/cookie\";\nimport constants from \"../../../constants/constants.js\";\nimport { copy } from \"../../../libs/i18n/index.js\";\nimport type { LucidHonoContext } from \"../../../types/hono.js\";\nimport type { ServiceResponse } from \"../../../utils/services/types.js\";\n\nconst verifyToken = (\n\tc: LucidHonoContext,\n): Awaited<ServiceResponse<undefined>> => {\n\tconst cookieCSRF = getCookie(c, constants.cookies.csrf);\n\tconst headerCSRF = c.req.header(constants.headers.csrf);\n\n\tif (!cookieCSRF || !headerCSRF) {\n\t\treturn {\n\t\t\terror: {\n\t\t\t\ttype: \"forbidden\",\n\t\t\t\tcode: \"csrf\",\n\t\t\t\tmessage: copy(\"server:core.security.csrf.validation.failed\"),\n\t\t\t},\n\t\t\tdata: undefined,\n\t\t};\n\t}\n\tif (cookieCSRF !== headerCSRF) {\n\t\treturn {\n\t\t\terror: {\n\t\t\t\ttype: \"forbidden\",\n\t\t\t\tcode: \"csrf\",\n\t\t\t\tmessage: copy(\"server:core.security.csrf.validation.failed\"),\n\t\t\t},\n\t\t\tdata: undefined,\n\t\t};\n\t}\n\n\treturn {\n\t\terror: undefined,\n\t\tdata: undefined,\n\t};\n};\n\nexport default verifyToken;\n"],"mappings":"2IAMA,MAAM,EACL,GACyC,CACzC,IAAM,EAAa,EAAU,EAAGA,EAAU,QAAQ,IAAI,EAChD,EAAa,EAAE,IAAI,OAAOA,EAAU,QAAQ,IAAI,EAuBtD,MArBI,CAAC,GAAc,CAAC,GAUhB,IAAe,EACX,CACN,MAAO,CACN,KAAM,YACN,KAAM,OACN,QAAS,EAAK,6CAA6C,CAC5D,EACA,KAAM,IAAA,EACP,EAGM,CACN,MAAO,IAAA,GACP,KAAM,IAAA,EACP,CACD"}