{"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\";\nimport { setup } from \"../lib/csrf\";\n\nfunction Login() {\n  const requestWithToken = event => {\n    event.preventDefault();\n    fetch(\"/api/protected\", {\n      method: \"post\"\n    }).then(response => {\n      if (response.ok) {\n        console.log(\"protected response ok\");\n        console.log(response);\n      }\n    }).catch(error => console.error(error));\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\nexport const getServerSideProps = setup(async ({\n  req,\n  res\n}) => {\n  return {\n    props: {}\n  };\n});\nexport default Login;","map":{"version":3,"sources":["/home/jolvera/proj/next-csrf/example/pages/login.js"],"names":["styles","setup","Login","requestWithToken","event","preventDefault","fetch","method","then","response","ok","console","log","catch","error","form","getServerSideProps","req","res","props"],"mappings":";;;AAAA,OAAOA,MAAP,MAAmB,2BAAnB;AACA,SAASC,KAAT,QAAsB,aAAtB;;AAEA,SAASC,KAAT,GAAiB;AACf,QAAMC,gBAAgB,GAAIC,KAAD,IAAW;AAClCA,IAAAA,KAAK,CAACC,cAAN;AAEAC,IAAAA,KAAK,CAAC,gBAAD,EAAmB;AACtBC,MAAAA,MAAM,EAAE;AADc,KAAnB,CAAL,CAGGC,IAHH,CAGSC,QAAD,IAAc;AAClB,UAAIA,QAAQ,CAACC,EAAb,EAAiB;AACfC,QAAAA,OAAO,CAACC,GAAR,CAAY,uBAAZ;AACAD,QAAAA,OAAO,CAACC,GAAR,CAAYH,QAAZ;AACD;AACF,KARH,EASGI,KATH,CASUC,KAAD,IAAWH,OAAO,CAACG,KAAR,CAAcA,KAAd,CATpB;AAUD,GAbD;;AAeA,SACE,4BACE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gDADF,EAEE;AAAM,IAAA,SAAS,EAAEd,MAAM,CAACe,IAAxB;AAA8B,IAAA,QAAQ,EAAEZ,gBAAxC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KACE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,cAEE;AAAO,IAAA,IAAI,EAAC,MAAZ;AAAmB,IAAA,QAAQ,MAA3B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAFF,CADF,EAME;AAAO,IAAA,OAAO,EAAC,UAAf;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAEE;AAAO,IAAA,IAAI,EAAC,UAAZ;AAAuB,IAAA,QAAQ,MAA/B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAFF,CANF,EAWE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,cAXF,CAFF,CADF;AAkBD;;AAED,OAAO,MAAMa,kBAAkB,GAAGf,KAAK,CAAC,OAAO;AAAEgB,EAAAA,GAAF;AAAOC,EAAAA;AAAP,CAAP,KAAwB;AAC9D,SAAO;AAAEC,IAAAA,KAAK,EAAE;AAAT,GAAP;AACD,CAFsC,CAAhC;AAIP,eAAejB,KAAf","sourcesContent":["import styles from \"../styles/Home.module.css\";\nimport { setup } 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"}