Edit: /tmp/tsx-0/17887-4730fa6e9bdaad2b5b4d20ed887ee8185efc3789 (5286B)
{"code":"__filename=\"/opt/canhelp/node_modules/better-auth/dist/plugins/email-otp/otp-token.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 otp_token_exports={};__export(otp_token_exports,{storeOTP:()=>storeOTP,tryReuseOTP:()=>tryReuseOTP,verifyStoredOTP:()=>verifyStoredOTP});module.exports=__toCommonJS(otp_token_exports);var import_date=require(\"../../utils/date.mjs\");var import_buffer=require(\"../../crypto/buffer.mjs\");var import_crypto=require(\"../../crypto/index.mjs\");var import_utils=require(\"./utils.mjs\");async function storeOTP(ctx,opts,otp){if(opts.storeOTP===\"encrypted\")return await(0,import_crypto.symmetricEncrypt)({key:ctx.context.secretConfig,data:otp});if(opts.storeOTP===\"hashed\")return await(0,import_utils.defaultKeyHasher)(otp);if(typeof opts.storeOTP===\"object\"&&\"hash\"in opts.storeOTP)return await opts.storeOTP.hash(otp);if(typeof opts.storeOTP===\"object\"&&\"encrypt\"in opts.storeOTP)return await opts.storeOTP.encrypt(otp);return otp}__name(storeOTP,\"storeOTP\");async function verifyStoredOTP(ctx,opts,storedOtp,otp){if(opts.storeOTP===\"encrypted\")return(0,import_buffer.constantTimeEqual)(await(0,import_crypto.symmetricDecrypt)({key:ctx.context.secretConfig,data:storedOtp}),otp);if(opts.storeOTP===\"hashed\")return(0,import_buffer.constantTimeEqual)(await(0,import_utils.defaultKeyHasher)(otp),storedOtp);if(typeof opts.storeOTP===\"object\"&&\"hash\"in opts.storeOTP)return(0,import_buffer.constantTimeEqual)(await opts.storeOTP.hash(otp),storedOtp);if(typeof opts.storeOTP===\"object\"&&\"decrypt\"in opts.storeOTP)return(0,import_buffer.constantTimeEqual)(await opts.storeOTP.decrypt(storedOtp),otp);return(0,import_buffer.constantTimeEqual)(otp,storedOtp)}__name(verifyStoredOTP,\"verifyStoredOTP\");async function retrieveOTP(ctx,opts,storedOtp){if(opts.storeOTP===\"plain\"||opts.storeOTP===void 0)return storedOtp;if(opts.storeOTP===\"encrypted\")return await(0,import_crypto.symmetricDecrypt)({key:ctx.context.secretConfig,data:storedOtp});if(typeof opts.storeOTP===\"object\"&&\"decrypt\"in opts.storeOTP)return await opts.storeOTP.decrypt(storedOtp);return null}__name(retrieveOTP,\"retrieveOTP\");async function tryReuseOTP(ctx,opts,identifier){const existing=await ctx.context.internalAdapter.findVerificationValue(identifier);if(!existing||existing.expiresAt
=allowedAttempts)return null;const plainOtp=await retrieveOTP(ctx,opts,storedOtpValue);if(!plainOtp)return null;await ctx.context.internalAdapter.updateVerificationByIdentifier(identifier,{expiresAt:(0,import_date.getDate)(opts.expiresIn,\"sec\")});return plainOtp}__name(tryReuseOTP,\"tryReuseOTP\");0&&(module.exports={storeOTP,tryReuseOTP,verifyStoredOTP});\n})()\n","warnings":[],"map":{"version":3,"mappings":";suBAAA,4MAAwB,gCACxB,kBAAkC,mCAClC,kBAAmD,kCACnD,iBAAmD,uBAGnD,eAAe,SAAS,IAAK,KAAM,IAAK,CACvC,GAAI,KAAK,WAAa,YAAa,OAAO,QAAM,gCAAiB,CAChE,IAAK,IAAI,QAAQ,aACjB,KAAM,GACP,CAAC,EACD,GAAI,KAAK,WAAa,SAAU,OAAO,QAAM,+BAAiB,GAAG,EACjE,GAAI,OAAO,KAAK,WAAa,UAA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