/opt/canhelp/node_modules/better-auth/dist/cookies
NameSizeModeActions
cookie-utils.d.mts11400644editdlrm
cookie-utils.mjs36780644editdlrm
cookie-utils.mjs.map74660644editdlrm
index.d.mts46530644editdlrm
index.mjs127680644editdlrm
index.mjs.map253470644editdlrm
session-store.d.mts15610644editdlrm
session-store.mjs66410644editdlrm
session-store.mjs.map136080644editdlrm
Edit: /opt/canhelp/node_modules/better-auth/dist/cookies/cookie-utils.mjs (3678B)
//#region src/cookies/cookie-utils.ts function tryDecode(str) { try { return decodeURIComponent(str); } catch { return str; } } const SECURE_COOKIE_PREFIX = "__Secure-"; const HOST_COOKIE_PREFIX = "__Host-"; /** * Remove __Secure- or __Host- prefix from cookie name. */ function stripSecureCookiePrefix(cookieName) { if (cookieName.startsWith(SECURE_COOKIE_PREFIX)) return cookieName.slice(9); if (cookieName.startsWith(HOST_COOKIE_PREFIX)) return cookieName.slice(7); return cookieName; } /** * Split a comma-joined `Set-Cookie` header string into individual cookies. */ function splitSetCookieHeader(setCookie) { if (!setCookie) return []; const result = []; let start = 0; let i = 0; while (i < setCookie.length) { if (setCookie[i] === ",") { let j = i + 1; while (j < setCookie.length && setCookie[j] === " ") j++; while (j < setCookie.length && setCookie[j] !== "=" && setCookie[j] !== ";" && setCookie[j] !== ",") j++; if (j < setCookie.length && setCookie[j] === "=") { const part = setCookie.slice(start, i).trim(); if (part) result.push(part); start = i + 1; while (start < setCookie.length && setCookie[start] === " ") start++; i = start; continue; } } i++; } const last = setCookie.slice(start).trim(); if (last) result.push(last); return result; } function parseSetCookieHeader(setCookie) { const cookies = /* @__PURE__ */ new Map(); splitSetCookieHeader(setCookie).forEach((cookieString) => { const [nameValue, ...attributes] = cookieString.split(";").map((part) => part.trim()); const [name, ...valueParts] = (nameValue || "").split("="); const value = valueParts.join("="); if (!name || value === void 0) return; const attrObj = { value: value.includes("%") ? tryDecode(value) : value }; attributes.forEach((attribute) => { const [attrName, ...attrValueParts] = attribute.split("="); const attrValue = attrValueParts.join("="); const normalizedAttrName = attrName.trim().toLowerCase(); switch (normalizedAttrName) { case "max-age": attrObj["max-age"] = attrValue ? parseInt(attrValue.trim(), 10) : void 0; break; case "expires": attrObj.expires = attrValue ? new Date(attrValue.trim()) : void 0; break; case "domain": attrObj.domain = attrValue ? attrValue.trim() : void 0; break; case "path": attrObj.path = attrValue ? attrValue.trim() : void 0; break; case "secure": attrObj.secure = true; break; case "httponly": attrObj.httponly = true; break; case "samesite": attrObj.samesite = attrValue ? attrValue.trim().toLowerCase() : void 0; break; default: attrObj[normalizedAttrName] = attrValue ? attrValue.trim() : true; break; } }); cookies.set(name, attrObj); }); return cookies; } function setCookieToHeader(headers) { return (context) => { const setCookieHeader = context.response.headers.get("set-cookie"); if (!setCookieHeader) return; const cookieMap = /* @__PURE__ */ new Map(); (headers.get("cookie") || "").split(";").forEach((cookie) => { const [name, ...rest] = cookie.trim().split("="); if (name && rest.length > 0) cookieMap.set(name, rest.join("=")); }); parseSetCookieHeader(setCookieHeader).forEach((value, name) => { cookieMap.set(name, value.value); }); const updatedCookies = Array.from(cookieMap.entries()).map(([name, value]) => `${name}=${value}`).join("; "); headers.set("cookie", updatedCookies); }; } //#endregion export { HOST_COOKIE_PREFIX, SECURE_COOKIE_PREFIX, parseSetCookieHeader, setCookieToHeader, splitSetCookieHeader, stripSecureCookiePrefix }; //# sourceMappingURL=cookie-utils.mjs.map