Edit: /tmp/tsx-0/17887-31432ec3660f6b4fc5f95fdb67b5260fdcc8edea (4022B)
{"code":"__filename=\"/opt/canhelp/node_modules/better-auth/dist/oauth2/state.mjs\";(()=>{\nvar __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __hasOwnProp=Object.prototype.hasOwnProperty;var __name=(target,value)=>__defProp(target,\"name\",{value,configurable:true});var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:true})};var __copyProps=(to,from,except,desc)=>{if(from&&typeof from===\"object\"||typeof from===\"function\"){for(let key of __getOwnPropNames(from))if(!__hasOwnProp.call(to,key)&&key!==except)__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable})}return to};var __toCommonJS=mod=>__copyProps(__defProp({},\"__esModule\",{value:true}),mod);var state_exports={};__export(state_exports,{generateState:()=>generateState,parseState:()=>parseState});module.exports=__toCommonJS(state_exports);var import_random=require(\"../crypto/random.mjs\");var import_crypto=require(\"../crypto/index.mjs\");var import_oauth=require(\"../api/state/oauth.mjs\");var import_state=require(\"../state.mjs\");var import_error=require(\"@better-auth/core/error\");async function generateState(c,link,additionalData){const callbackURL=c.body?.callbackURL||c.context.options.baseURL;if(!callbackURL)throw import_error.APIError.from(\"BAD_REQUEST\",import_error.BASE_ERROR_CODES.CALLBACK_URL_REQUIRED);const codeVerifier=(0,import_random.generateRandomString)(128);const stateData={...additionalData?additionalData:{},callbackURL,codeVerifier,errorURL:c.body?.errorCallbackURL,newUserURL:c.body?.newUserCallbackURL,link,expiresAt:Date.now()+600*1e3,requestSignUp:c.body?.requestSignUp};await(0,import_oauth.setOAuthState)(stateData);try{return(0,import_state.generateGenericState)(c,stateData)}catch(error){c.context.logger.error(\"Failed to create verification\",error);throw new import_error.APIError(\"INTERNAL_SERVER_ERROR\",{message:\"Unable to create verification\",cause:error})}}__name(generateState,\"generateState\");async function parseState(c){const state=c.query.state||c.body.state;const errorURL=c.context.options.onAPIError?.errorURL||`${c.context.baseURL}/error`;let parsedData;try{parsedData=await(0,import_state.parseGenericState)(c,state)}catch(error){c.context.logger.error(\"Failed to parse state\",error);if(error instanceof import_state.StateError&&error.code===\"state_security_mismatch\")throw c.redirect(`${errorURL}?error=state_mismatch`);throw c.redirect(`${errorURL}?error=please_restart_the_process`)}if(!parsedData.errorURL)parsedData.errorURL=errorURL;if(parsedData)await(0,import_oauth.setOAuthState)(parsedData);return parsedData}__name(parseState,\"parseState\");0&&(module.exports={generateState,parseState});\n})()\n","warnings":[],"map":{"version":3,"mappings":";suBAAA,sKAAqC,gCACrC,kBAAO,+BACP,iBAA8B,kCAC9B,iBAAoE,wBACpE,iBAA2C,mCAG3C,eAAe,cAAc,EAAG,KAAM,eAAgB,CACrD,MAAM,YAAc,EAAE,MAAM,aAAe,EAAE,QAAQ,QAAQ,QAC7D,GAAI,CAAC,YAAa,MAAM,sBAAS,KAAK,cAAe,8BAAiB,qBAAqB,EAC3F,MAAM,gBAAe,oCAAqB,GAAG,EAC7C,MAAM,UAAY,CACjB,GAAG,eAAiB,eAAiB,CAAC,EACtC,YACA,aACA,SAAU,EAAE,MAAM,iBAClB,WAAY,EAAE,MAAM,mBACpB,KACA,UAAW,KAAK,IAAI,EAAI,IAAM,IAC9B,cAAe,EAAE,MAAM,aACxB,EACA,QAAM,4BAAc,SAAS,EAC7B,GAAI,CACH,SAAO,mCAAqB,EAAG,SAAS,CACzC,OAAS,MAAO,CACf,EAAE,QAAQ,OAAO,MAAM,gCAAiC,KAAK,EAC7D,MAAM,IAAI,sBAAS,wBAAyB,CAC3C,QAAS,gCACT,MAAO,KACR,CAAC,CACF,CACD,CAxBe,sCAyBf,eAAe,WAAW,EAAG,CAC5B,MAAM,MAAQ,EAAE,MAAM,OAAS,EAAE,KAAK,MACtC,MAAM,SAAW,EAAE,QAAQ,QAAQ,YAAY,UAAY,GAAG,EAAE,QAAQ,OAAO,SAC/E,IAAI,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