Edit: /tmp/tsx-0/17887-5b2d6d812abd247e9898562ea15cb1f893ed8800 (5451B)
{"code":"__filename=\"/opt/canhelp/node_modules/better-auth/dist/context/secret-utils.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 secret_utils_exports={};__export(secret_utils_exports,{buildSecretConfig:()=>buildSecretConfig,parseSecretsEnv:()=>parseSecretsEnv,validateSecretsArray:()=>validateSecretsArray});module.exports=__toCommonJS(secret_utils_exports);var import_constants=require(\"../utils/constants.mjs\");var import_error=require(\"@better-auth/core/error\");function estimateEntropy(str){const unique=new Set(str).size;if(unique===0)return 0;return Math.log2(Math.pow(unique,str.length))}__name(estimateEntropy,\"estimateEntropy\");function parseSecretsEnv(envValue){if(!envValue)return null;return envValue.split(\",\").map(entry=>{entry=entry.trim();const colonIdx=entry.indexOf(\":\");if(colonIdx===-1)throw new import_error.BetterAuthError(`Invalid BETTER_AUTH_SECRETS entry: \"${entry}\". Expected format: \"
:\"`);const version=parseInt(entry.slice(0,colonIdx),10);if(!Number.isInteger(version)||version<0)throw new import_error.BetterAuthError(`Invalid version in BETTER_AUTH_SECRETS: \"${entry.slice(0,colonIdx)}\". Version must be a non-negative integer.`);const value=entry.slice(colonIdx+1).trim();if(!value)throw new import_error.BetterAuthError(`Empty secret value for version ${version} in BETTER_AUTH_SECRETS.`);return{version,value}})}__name(parseSecretsEnv,\"parseSecretsEnv\");function validateSecretsArray(secrets,logger){if(secrets.length===0)throw new import_error.BetterAuthError(\"`secrets` array must contain at least one entry.\");const seen=new Set;for(const s of secrets){const version=parseInt(String(s.version),10);if(!Number.isInteger(version)||version<0||String(version)!==String(s.version).trim())throw new import_error.BetterAuthError(`Invalid version ${s.version} in \\`secrets\\`. Version must be a non-negative integer.`);if(!s.value)throw new import_error.BetterAuthError(`Empty secret value for version ${version} in \\`secrets\\`.`);if(seen.has(version))throw new import_error.BetterAuthError(`Duplicate version ${version} in \\`secrets\\`. Each version must be unique.`);seen.add(version)}const current=secrets[0];if(current.value.length<32)logger.warn(`[better-auth] Warning: the current secret (version ${current.version}) should be at least 32 characters long for adequate security.`);if(estimateEntropy(current.value)<120)logger.warn(\"[better-auth] Warning: the current secret appears low-entropy. Use a randomly generated secret for production.\")}__name(validateSecretsArray,\"validateSecretsArray\");function buildSecretConfig(secrets,legacySecret){const keys=new Map;for(const s of secrets)keys.set(parseInt(String(s.version),10),s.value);return{keys,currentVersion:parseInt(String(secrets[0].version),10),legacySecret:legacySecret&&legacySecret!==import_constants.DEFAULT_SECRET?legacySecret:void 0}}__name(buildSecretConfig,\"buildSecretConfig\");0&&(module.exports={buildSecretConfig,parseSecretsEnv,validateSecretsArray});\n})()\n","warnings":[],"map":{"version":3,"mappings":";suBAAA,8PAA+B,kCAC/B,iBAAgC,mCAOhC,SAAS,gBAAgB,IAAK,CAC7B,MAAM,OAAS,IAAI,IAAI,GAAG,EAAE,KAC5B,GAAI,SAAW,EAAG,MAAO,GACzB,OAAO,KAAK,KAAK,KAAK,IAAI,OAAQ,IAAI,MAAM,CAAC,CAC9C,CAJS,0CAKT,SAAS,gBAAgB,SAAU,CAClC,GAAI,CAAC,SAAU,OAAO,KACtB,OAAO,SAAS,MAAM,GAAG,EAAE,IAAK,OAAU,CACzC,MAAQ,MAAM,KAAK,EACnB,MAAM,SAAW,MAAM,QAAQ,GAAG,EAClC,GAAI,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