MCPcopy
hub / github.com/cloudflare/vibesdk / createSecureCookie

Function createSecureCookie

worker/utils/authUtils.ts:156–178  ·  view source on GitHub ↗
(options: CookieOptions)

Source from the content-addressed store, hash-verified

154 * Create secure cookie string with all options
155 */
156export function createSecureCookie(options: CookieOptions): string {
157 const {
158 name,
159 value,
160 maxAge = 7 * 24 * 60 * 60, // 7 days default
161 secure = true,
162 sameSite = 'Lax',
163 path = '/',
164 domain,
165 } = options;
166
167 const parts = [`${name}=${encodeURIComponent(value)}`];
168
169 if (maxAge > 0) parts.push(`Max-Age=${maxAge}`);
170 if (path) parts.push(`Path=${path}`);
171 if (domain) parts.push(`Domain=${domain}`);
172 if (secure) parts.push('Secure');
173 if (sameSite) parts.push(`SameSite=${sameSite}`);
174
175 parts.push('HttpOnly');
176
177 return parts.join('; ');
178}
179
180/**
181 * Set auth cookies with proper security settings

Callers 4

setTokenCookieMethod · 0.90
clearTokenCookieMethod · 0.90
clearAuthCookieFunction · 0.85
setSecureAuthCookiesFunction · 0.85

Calls 1

pushMethod · 0.80

Tested by

no test coverage detected