UNPKG

next-csrf

Version:

CSRF mitigation library for Next.js

1 lines 4.38 kB
{"ast":null,"code":"var _jsxFileName = \"/home/jolvera/proj/next-csrf/example/pages/login.js\";\nimport React from \"react\";\nvar __jsx = React.createElement;\nimport styles from \"../styles/Home.module.css\";\n\nfunction Login() {\n var requestWithToken = function requestWithToken(event) {\n event.preventDefault();\n fetch(\"/api/protected\", {\n method: \"post\"\n }).then(function (response) {\n if (response.ok) {\n console.log(\"protected response ok\");\n console.log(response);\n }\n })[\"catch\"](function (error) {\n return console.error(error);\n });\n };\n\n return __jsx(React.Fragment, null, __jsx(\"p\", {\n __self: this,\n __source: {\n fileName: _jsxFileName,\n lineNumber: 22,\n columnNumber: 7\n }\n }, \"Use \\\"demo\\\" for both login and password\"), __jsx(\"form\", {\n className: styles.form,\n onSubmit: requestWithToken,\n __self: this,\n __source: {\n fileName: _jsxFileName,\n lineNumber: 23,\n columnNumber: 7\n }\n }, __jsx(\"label\", {\n __self: this,\n __source: {\n fileName: _jsxFileName,\n lineNumber: 24,\n columnNumber: 9\n }\n }, \"Login\", __jsx(\"input\", {\n type: \"text\",\n required: true,\n __self: this,\n __source: {\n fileName: _jsxFileName,\n lineNumber: 26,\n columnNumber: 11\n }\n })), __jsx(\"label\", {\n htmlFor: \"password\",\n __self: this,\n __source: {\n fileName: _jsxFileName,\n lineNumber: 29,\n columnNumber: 9\n }\n }, \"Password\", __jsx(\"input\", {\n type: \"password\",\n required: true,\n __self: this,\n __source: {\n fileName: _jsxFileName,\n lineNumber: 31,\n columnNumber: 11\n }\n })), __jsx(\"button\", {\n __self: this,\n __source: {\n fileName: _jsxFileName,\n lineNumber: 34,\n columnNumber: 9\n }\n }, \"Submit\")));\n}\n\n_c = Login;\nexport var __N_SSP = true;\nexport default Login;\n\nvar _c;\n\n$RefreshReg$(_c, \"Login\");","map":{"version":3,"sources":["/home/jolvera/proj/next-csrf/example/pages/login.js"],"names":["styles","Login","requestWithToken","event","preventDefault","fetch","method","then","response","ok","console","log","error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} from \"../lib/csrf\";\n\nfunction Login() {\n const requestWithToken = (event) => {\n event.preventDefault();\n\n fetch(\"/api/protected\", {\n method: \"post\",\n })\n .then((response) => {\n if (response.ok) {\n console.log(\"protected response ok\");\n console.log(response);\n }\n })\n .catch((error) => console.error(error));\n };\n\n return (\n <>\n <p>Use \"demo\" for both login and password</p>\n <form className={styles.form} onSubmit={requestWithToken}>\n <label>\n Login\n <input type=\"text\" required />\n </label>\n\n <label htmlFor=\"password\">\n Password\n <input type=\"password\" required />\n </label>\n\n <button>Submit</button>\n </form>\n </>\n );\n}\n\nexport const getServerSideProps = setup(async ({ req, res }) => {\n return { props: {} };\n});\n\nexport default Login;\n"]},"metadata":{},"sourceType":"module"}