{"version":3,"file":"verification-token-storage.mjs","names":[],"sources":["../../src/db/verification-token-storage.ts"],"sourcesContent":["import { base64Url } from \"@better-auth/utils/base64\";\nimport { createHash } from \"@better-auth/utils/hash\";\nimport type { StoreIdentifierOption } from \"../types\";\n\nconst defaultKeyHasher = async (identifier: string) => {\n\tconst hash = await createHash(\"SHA-256\").digest(\n\t\tnew TextEncoder().encode(identifier),\n\t);\n\treturn base64Url.encode(new Uint8Array(hash), { padding: false });\n};\n\nexport async function processIdentifier(\n\tidentifier: string,\n\toption: StoreIdentifierOption | undefined,\n): Promise<string> {\n\tif (!option || option === \"plain\") {\n\t\treturn identifier;\n\t}\n\tif (option === \"hashed\") {\n\t\treturn defaultKeyHasher(identifier);\n\t}\n\tif (typeof option === \"object\" && \"hash\" in option) {\n\t\treturn option.hash(identifier);\n\t}\n\treturn identifier;\n}\n\nexport function getStorageOption(\n\tidentifier: string,\n\tconfig:\n\t\t| StoreIdentifierOption\n\t\t| {\n\t\t\t\tdefault: StoreIdentifierOption;\n\t\t\t\toverrides?: Record<string, StoreIdentifierOption>;\n\t\t  }\n\t\t| undefined,\n): StoreIdentifierOption | undefined {\n\tif (!config) {\n\t\treturn undefined;\n\t}\n\n\tif (typeof config === \"object\" && \"default\" in config) {\n\t\tif (config.overrides) {\n\t\t\tfor (const [prefix, option] of Object.entries(config.overrides)) {\n\t\t\t\tif (identifier.startsWith(prefix)) {\n\t\t\t\t\treturn option;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn config.default;\n\t}\n\n\treturn config;\n}\n"],"mappings":";;;;AAIA,MAAM,mBAAmB,OAAO,eAAuB;CACtD,MAAM,OAAO,MAAM,WAAW,UAAU,CAAC,OACxC,IAAI,aAAa,CAAC,OAAO,WAAW,CACpC;AACD,QAAO,UAAU,OAAO,IAAI,WAAW,KAAK,EAAE,EAAE,SAAS,OAAO,CAAC;;AAGlE,eAAsB,kBACrB,YACA,QACkB;AAClB,KAAI,CAAC,UAAU,WAAW,QACzB,QAAO;AAER,KAAI,WAAW,SACd,QAAO,iBAAiB,WAAW;AAEpC,KAAI,OAAO,WAAW,YAAY,UAAU,OAC3C,QAAO,OAAO,KAAK,WAAW;AAE/B,QAAO;;AAGR,SAAgB,iBACf,YACA,QAOoC;AACpC,KAAI,CAAC,OACJ;AAGD,KAAI,OAAO,WAAW,YAAY,aAAa,QAAQ;AACtD,MAAI,OAAO,WACV;QAAK,MAAM,CAAC,QAAQ,WAAW,OAAO,QAAQ,OAAO,UAAU,CAC9D,KAAI,WAAW,WAAW,OAAO,CAChC,QAAO;;AAIV,SAAO,OAAO;;AAGf,QAAO"}