feat: Reinitialize frontend with SvelteKit and TypeScript

- Delete old Vite+Svelte frontend
- Initialize new SvelteKit project with TypeScript
- Configure Tailwind CSS v4 + DaisyUI
- Implement JWT authentication with auto-refresh
- Create login page with form validation (Zod)
- Add protected route guards
- Update Docker configuration for single-stage build
- Add E2E tests with Playwright (6/11 passing)
- Fix Svelte 5 reactivity with $state() runes

Known issues:
- 5 E2E tests failing (timing/async issues)
- Token refresh implementation needs debugging
- Validation error display timing
This commit is contained in:
2026-02-17 16:19:59 -05:00
parent 54df6018f5
commit de2d83092e
28274 changed files with 3816354 additions and 90 deletions

View File

@@ -0,0 +1,28 @@
import URL from '../url/URL.js';
import ICookie from './ICookie.js';
import ICookieContainer from './ICookieContainer.js';
import IOptionalCookie from './IOptionalCookie.js';
/**
* Cookie Container.
*
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cookie.
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie.
*/
export default class CookieContainer implements ICookieContainer {
#private;
/**
* Adds cookies.
*
* @param cookies Cookies.
*/
addCookies(cookies: IOptionalCookie[]): void;
/**
* Returns cookies.
*
* @param [url] URL.
* @param [httpOnly] "true" if only http cookies should be returned.
* @returns Cookies.
*/
getCookies(url?: URL | null, httpOnly?: boolean): ICookie[];
}
//# sourceMappingURL=CookieContainer.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"CookieContainer.d.ts","sourceRoot":"","sources":["../../src/cookie/CookieContainer.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,eAAe,CAAC;AAEhC,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,gBAAgB,MAAM,uBAAuB,CAAC;AACrD,OAAO,eAAe,MAAM,sBAAsB,CAAC;AAInD;;;;;GAKG;AACH,MAAM,CAAC,OAAO,OAAO,eAAgB,YAAW,gBAAgB;;IAG/D;;;;OAIG;IACI,UAAU,CAAC,OAAO,EAAE,eAAe,EAAE,GAAG,IAAI;IA6BnD;;;;;;OAMG;IACI,UAAU,CAAC,GAAG,GAAE,GAAG,GAAG,IAAW,EAAE,QAAQ,UAAQ,GAAG,OAAO,EAAE;CAetE"}

View File

@@ -0,0 +1,58 @@
import DefaultCookie from './DefaultCookie.js';
import CookieExpireUtility from './urilities/CookieExpireUtility.js';
import CookieURLUtility from './urilities/CookieURLUtility.js';
/**
* Cookie Container.
*
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cookie.
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie.
*/
export default class CookieContainer {
#cookies = [];
/**
* Adds cookies.
*
* @param cookies Cookies.
*/
addCookies(cookies) {
const indexMap = {};
const getKey = (cookie) => `${cookie.key}-${cookie.originURL.hostname}-${cookie.path}-${typeof cookie.value}`;
// Creates a map of cookie key, domain, path and value to index.
for (let i = 0, max = this.#cookies.length; i < max; i++) {
indexMap[getKey(this.#cookies[i])] = i;
}
for (const cookie of cookies) {
const newCookie = Object.assign({}, DefaultCookie, cookie);
if (newCookie && newCookie.key && newCookie.originURL) {
// Remove existing cookie with same name, domain and path.
const index = indexMap[getKey(newCookie)];
if (index !== undefined) {
this.#cookies.splice(index, 1);
}
if (!CookieExpireUtility.hasExpired(newCookie)) {
indexMap[getKey(newCookie)] = this.#cookies.length;
this.#cookies.push(newCookie);
}
}
}
}
/**
* Returns cookies.
*
* @param [url] URL.
* @param [httpOnly] "true" if only http cookies should be returned.
* @returns Cookies.
*/
getCookies(url = null, httpOnly = false) {
const cookies = [];
for (const cookie of this.#cookies) {
if (!CookieExpireUtility.hasExpired(cookie) &&
(!httpOnly || !cookie.httpOnly) &&
(!url || CookieURLUtility.cookieMatchesURL(cookie, url || cookie.originURL))) {
cookies.push(cookie);
}
}
return cookies;
}
}
//# sourceMappingURL=CookieContainer.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"CookieContainer.js","sourceRoot":"","sources":["../../src/cookie/CookieContainer.ts"],"names":[],"mappings":"AACA,OAAO,aAAa,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AChD,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;oBACnD,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;gBAC/B,CAAC;YACF,CAAC;QACF,CAAC;IACF,CAAC;IAED;;;;;;OAMG;IACI,UAAU,CAAC,MAAkB,IAAI,EAAE,QAAQ,GAAG,KAAK;QACzD,MAAM,OAAO,GAAG,EAAE,CAAC;QAEnB,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YACpC,IACC,CAAC,mBAAmB,CAAC,UAAU,CAAC,MAAM,CAAC;gBACvC,CAAC,CAAC,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC;gBAC/B,CAAC,CAAC,GAAG,IAAI,gBAAgB,CAAC,gBAAgB,CAAC,MAAM,EAAE,GAAG,IAAI,MAAM,CAAC,SAAS,CAAC,CAAC,EAC3E,CAAC;gBACF,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACtB,CAAC;QACF,CAAC;QAED,OAAO,OAAO,CAAC;IAChB,CAAC;CACD"}

View File

@@ -0,0 +1,4 @@
import ICookie from './ICookie.js';
declare const _default: ICookie;
export default _default;
//# sourceMappingURL=DefaultCookie.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"DefaultCookie.d.ts","sourceRoot":"","sources":["../../src/cookie/DefaultCookie.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,MAAM,cAAc,CAAC;wBAEnB,OAAO;AAAvB,wBAaE"}

View File

@@ -0,0 +1,15 @@
import CookieSameSiteEnum from './enums/CookieSameSiteEnum.js';
export default {
// Required
key: null,
originURL: null,
// Optional
value: null,
domain: '',
path: '',
expires: null,
httpOnly: false,
secure: false,
sameSite: CookieSameSiteEnum.lax
};
//# sourceMappingURL=DefaultCookie.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"DefaultCookie.js","sourceRoot":"","sources":["../../src/cookie/DefaultCookie.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,MAAM,+BAA+B,CAAC;AAG/D,eAAwB;IACvB,WAAW;IACX,GAAG,EAAE,IAAI;IACT,SAAS,EAAE,IAAI;IAEf,WAAW;IACX,KAAK,EAAE,IAAI;IACX,MAAM,EAAE,EAAE;IACV,IAAI,EAAE,EAAE;IACR,OAAO,EAAE,IAAI;IACb,QAAQ,EAAE,KAAK;IACf,MAAM,EAAE,KAAK;IACb,QAAQ,EAAE,kBAAkB,CAAC,GAAG;CAChC,CAAC"}

View File

@@ -0,0 +1,13 @@
import CookieSameSiteEnum from './enums/CookieSameSiteEnum.js';
export default interface ICookie {
key: string;
originURL: URL;
value: string | null;
domain: string;
path: string;
expires: Date | null;
httpOnly: boolean;
secure: boolean;
sameSite: CookieSameSiteEnum;
}
//# sourceMappingURL=ICookie.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ICookie.d.ts","sourceRoot":"","sources":["../../src/cookie/ICookie.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,MAAM,+BAA+B,CAAC;AAE/D,MAAM,CAAC,OAAO,WAAW,OAAO;IAE/B,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,GAAG,CAAC;IACf,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,IAAI,GAAG,IAAI,CAAC;IACrB,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,kBAAkB,CAAC;CAC7B"}

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=ICookie.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ICookie.js","sourceRoot":"","sources":["../../src/cookie/ICookie.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,26 @@
import URL from '../url/URL.js';
import ICookie from './ICookie.js';
import IOptionalCookie from './IOptionalCookie.js';
/**
* Cookie Container.
*
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cookie.
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie.
*/
export default interface ICookieContainer {
/**
* Adds cookies.
*
* @param cookies Cookies.
*/
addCookies(cookies: IOptionalCookie[]): void;
/**
* Returns cookies.
*
* @param [url] URL.
* @param [httpOnly] "true" if only http cookies should be returned.
* @returns Cookies.
*/
getCookies(url: URL | null, httpOnly?: boolean): ICookie[];
}
//# sourceMappingURL=ICookieContainer.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ICookieContainer.d.ts","sourceRoot":"","sources":["../../src/cookie/ICookieContainer.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,eAAe,CAAC;AAChC,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,eAAe,MAAM,sBAAsB,CAAC;AAEnD;;;;;GAKG;AACH,MAAM,CAAC,OAAO,WAAW,gBAAgB;IACxC;;;;OAIG;IACH,UAAU,CAAC,OAAO,EAAE,eAAe,EAAE,GAAG,IAAI,CAAC;IAE7C;;;;;;OAMG;IACH,UAAU,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,EAAE,QAAQ,CAAC,EAAE,OAAO,GAAG,OAAO,EAAE,CAAC;CAC3D"}

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=ICookieContainer.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ICookieContainer.js","sourceRoot":"","sources":["../../src/cookie/ICookieContainer.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,13 @@
import CookieSameSiteEnum from './enums/CookieSameSiteEnum.js';
export default interface IOptionalCookie {
key: string;
originURL: URL;
value?: string | null;
domain?: string;
path?: string;
expires?: Date | null;
httpOnly?: boolean;
secure?: boolean;
sameSite?: CookieSameSiteEnum;
}
//# sourceMappingURL=IOptionalCookie.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"IOptionalCookie.d.ts","sourceRoot":"","sources":["../../src/cookie/IOptionalCookie.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,MAAM,+BAA+B,CAAC;AAE/D,MAAM,CAAC,OAAO,WAAW,eAAe;IAEvC,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,GAAG,CAAC;IAGf,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,kBAAkB,CAAC;CAC9B"}

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=IOptionalCookie.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"IOptionalCookie.js","sourceRoot":"","sources":["../../src/cookie/IOptionalCookie.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,7 @@
declare enum CookieSameSiteEnum {
strict = "Strict",
lax = "Lax",
none = "None"
}
export default CookieSameSiteEnum;
//# sourceMappingURL=CookieSameSiteEnum.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"CookieSameSiteEnum.d.ts","sourceRoot":"","sources":["../../../src/cookie/enums/CookieSameSiteEnum.ts"],"names":[],"mappings":"AAAA,aAAK,kBAAkB;IACtB,MAAM,WAAW;IACjB,GAAG,QAAQ;IACX,IAAI,SAAS;CACb;AACD,eAAe,kBAAkB,CAAC"}

View File

@@ -0,0 +1,8 @@
var CookieSameSiteEnum;
(function (CookieSameSiteEnum) {
CookieSameSiteEnum["strict"] = "Strict";
CookieSameSiteEnum["lax"] = "Lax";
CookieSameSiteEnum["none"] = "None";
})(CookieSameSiteEnum || (CookieSameSiteEnum = {}));
export default CookieSameSiteEnum;
//# sourceMappingURL=CookieSameSiteEnum.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"CookieSameSiteEnum.js","sourceRoot":"","sources":["../../../src/cookie/enums/CookieSameSiteEnum.ts"],"names":[],"mappings":"AAAA,IAAK,kBAIJ;AAJD,WAAK,kBAAkB;IACtB,uCAAiB,CAAA;IACjB,iCAAW,CAAA;IACX,mCAAa,CAAA;AACd,CAAC,EAJI,kBAAkB,KAAlB,kBAAkB,QAItB;AACD,eAAe,kBAAkB,CAAC"}

View File

@@ -0,0 +1,14 @@
import ICookie from '../ICookie.js';
/**
* Cookie expire utility.
*/
export default class CookieExpireUtility {
/**
* Returns "true" if cookie has expired.
*
* @param cookie Cookie.
* @returns "true" if cookie has expired.
*/
static hasExpired(cookie: ICookie): boolean | null;
}
//# sourceMappingURL=CookieExpireUtility.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"CookieExpireUtility.d.ts","sourceRoot":"","sources":["../../../src/cookie/urilities/CookieExpireUtility.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,eAAe,CAAC;AAEpC;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,mBAAmB;IACvC;;;;;OAKG;WACW,UAAU,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,GAAG,IAAI;CAGzD"}

View File

@@ -0,0 +1,15 @@
/**
* Cookie expire utility.
*/
export default class CookieExpireUtility {
/**
* Returns "true" if cookie has expired.
*
* @param cookie Cookie.
* @returns "true" if cookie has expired.
*/
static hasExpired(cookie) {
return cookie.expires && cookie.expires.getTime() < Date.now();
}
}
//# sourceMappingURL=CookieExpireUtility.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"CookieExpireUtility.js","sourceRoot":"","sources":["../../../src/cookie/urilities/CookieExpireUtility.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,mBAAmB;IACvC;;;;;OAKG;IACI,MAAM,CAAC,UAAU,CAAC,MAAe;QACvC,OAAO,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAChE,CAAC;CACD"}

View File

@@ -0,0 +1,23 @@
import URL from '../../url/URL.js';
import ICookie from '../ICookie.js';
/**
* Cookie string.
*/
export default class CookieStringUtility {
/**
* Returns cookie.
*
* @param originURL Origin URL.
* @param cookieString Cookie string.
* @returns Cookie.
*/
static stringToCookie(originURL: URL, cookieString: string): ICookie | null;
/**
* Returns cookie string with key and value.
*
* @param cookies Cookies.
* @returns Cookie string.
*/
static cookiesToString(cookies: ICookie[]): string;
}
//# sourceMappingURL=CookieStringUtility.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"CookieStringUtility.d.ts","sourceRoot":"","sources":["../../../src/cookie/urilities/CookieStringUtility.ts"],"names":[],"mappings":"AACA,OAAO,GAAG,MAAM,kBAAkB,CAAC;AACnC,OAAO,OAAO,MAAM,eAAe,CAAC;AAGpC;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,mBAAmB;IACvC;;;;;;OAMG;WACW,cAAc,CAAC,SAAS,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI;IA6ElF;;;;;OAKG;WACW,eAAe,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,MAAM;CAazD"}

View File

@@ -0,0 +1,98 @@
import CookieSameSiteEnum from '../enums/CookieSameSiteEnum.js';
import DefaultCookie from '../DefaultCookie.js';
/**
* Cookie string.
*/
export default class CookieStringUtility {
/**
* Returns cookie.
*
* @param originURL Origin URL.
* @param cookieString Cookie string.
* @returns Cookie.
*/
static stringToCookie(originURL, cookieString) {
const parts = cookieString.split(';');
const part = parts.shift();
const index = part.indexOf('=');
const key = index !== -1 ? part.slice(0, index).trim() : part.trim();
const value = index !== -1 ? part.slice(index + 1).trim() : null;
const cookie = Object.assign({}, DefaultCookie, {
// Required
key,
value,
originURL
});
// Invalid if key is empty.
if (!cookie.key) {
return null;
}
for (const part of parts) {
const index = part.indexOf('=');
const key = index !== -1 ? part.slice(0, index).trim().toLowerCase() : part.trim().toLowerCase();
const value = index !== -1 ? part.slice(index + 1).trim() : '';
switch (key) {
case 'expires':
cookie.expires = new Date(value);
break;
case 'max-age':
cookie.expires = new Date(parseInt(value, 10) * 1000 + Date.now());
break;
case 'domain':
cookie.domain = value;
break;
case 'path':
cookie.path = value[0] === '/' ? value : `/${value}`;
break;
case 'httponly':
cookie.httpOnly = true;
break;
case 'secure':
cookie.secure = true;
break;
case 'samesite':
switch (value.toLowerCase()) {
case 'strict':
cookie.sameSite = CookieSameSiteEnum.strict;
break;
case 'lax':
cookie.sameSite = CookieSameSiteEnum.lax;
break;
case 'none':
cookie.sameSite = CookieSameSiteEnum.none;
}
break;
}
}
const lowerKey = cookie.key.toLowerCase();
// Invalid if __secure- prefix is used and cookie is not secure.
if (lowerKey.startsWith('__secure-') && !cookie.secure) {
return null;
}
// Invalid if __host- prefix is used and cookie is not secure, not on root path or has a domain.
if (lowerKey.startsWith('__host-') &&
(!cookie.secure || cookie.path !== '/' || cookie.domain)) {
return null;
}
return cookie;
}
/**
* Returns cookie string with key and value.
*
* @param cookies Cookies.
* @returns Cookie string.
*/
static cookiesToString(cookies) {
const cookieString = [];
for (const cookie of cookies) {
if (cookie.value !== null) {
cookieString.push(`${cookie.key}=${cookie.value}`);
}
else {
cookieString.push(cookie.key);
}
}
return cookieString.join('; ');
}
}
//# sourceMappingURL=CookieStringUtility.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"CookieStringUtility.js","sourceRoot":"","sources":["../../../src/cookie/urilities/CookieStringUtility.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,MAAM,gCAAgC,CAAC;AAGhE,OAAO,aAAa,MAAM,qBAAqB,CAAC;AAEhD;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,mBAAmB;IACvC;;;;;;OAMG;IACI,MAAM,CAAC,cAAc,CAAC,SAAc,EAAE,Y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,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;YACxD,OAAO,IAAI,CAAC;QACb,CAAC;QAED,gGAAgG;QAChG,IACC,QAAQ,CAAC,UAAU,CAAC,SAAS,CAAC;YAC9B,CAAC,CAAC,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,IAAI,KAAK,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,EACvD,CAAC;YACF,OAAO,IAAI,CAAC;QACb,CAAC;QAED,OAAO,MAAM,CAAC;IACf,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,eAAe,CAAC,OAAkB;QAC/C,MAAM,YAAY,GAAa,EAAE,CAAC;QAElC,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;YAC9B,IAAI,MAAM,CAAC,KAAK,KAAK,IAAI,EAAE,CAAC;gBAC3B,YAAY,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,GAAG,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;YACpD,CAAC;iBAAM,CAAC;gBACP,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YAC/B,CAAC;QACF,CAAC;QAED,OAAO,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;CACD"}

View File

@@ -0,0 +1,16 @@
import URL from '../../url/URL.js';
import ICookie from '../ICookie.js';
/**
* Cookie string.
*/
export default class CookieURLUtility {
/**
* Returns "true" if cookie matches URL.
*
* @param cookie Cookie.
* @param url URL.
* @returns "true" if cookie matches URL.
*/
static cookieMatchesURL(cookie: ICookie, url: URL): boolean;
}
//# sourceMappingURL=CookieURLUtility.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"CookieURLUtility.d.ts","sourceRoot":"","sources":["../../../src/cookie/urilities/CookieURLUtility.ts"],"names":[],"mappings":"AACA,OAAO,GAAG,MAAM,kBAAkB,CAAC;AACnC,OAAO,OAAO,MAAM,eAAe,CAAC;AAEpC;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,gBAAgB;IACpC;;;;;;OAMG;WACW,gBAAgB,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,GAAG,OAAO;CAWlE"}

View File

@@ -0,0 +1,23 @@
import CookieSameSiteEnum from '../enums/CookieSameSiteEnum.js';
/**
* Cookie string.
*/
export default class CookieURLUtility {
/**
* Returns "true" if cookie matches URL.
*
* @param cookie Cookie.
* @param url URL.
* @returns "true" if cookie matches URL.
*/
static cookieMatchesURL(cookie, url) {
const isLocalhost = url.hostname === 'localhost' || url.hostname.endsWith('.localhost');
return ((!cookie.secure || url.protocol === 'https:' || isLocalhost) &&
(!cookie.domain || url.hostname.endsWith(cookie.domain)) &&
(!cookie.path || url.pathname.startsWith(cookie.path)) &&
// @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#samesitesamesite-value
((cookie.sameSite === CookieSameSiteEnum.none && cookie.secure) ||
cookie.originURL.hostname === url.hostname));
}
}
//# sourceMappingURL=CookieURLUtility.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"CookieURLUtility.js","sourceRoot":"","sources":["../../../src/cookie/urilities/CookieURLUtility.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,MAAM,gCAAgC,CAAC;AAIhE;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,gBAAgB;IACpC;;;;;;OAMG;IACI,MAAM,CAAC,gBAAgB,CAAC,MAAe,EAAE,GAAQ;QACvD,MAAM,WAAW,GAAG,GAAG,CAAC,QAAQ,KAAK,WAAW,IAAI,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;QACxF,OAAO,CACN,CAAC,CAAC,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,QAAQ,KAAK,QAAQ,IAAI,WAAW,CAAC;YAC5D,CAAC,CAAC,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YACxD,CAAC,CAAC,MAAM,CAAC,IAAI,IAAI,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YACtD,mGAAmG;YACnG,CAAC,CAAC,MAAM,CAAC,QAAQ,KAAK,kBAAkB,CAAC,IAAI,IAAI,MAAM,CAAC,MAAM,CAAC;gBAC9D,MAAM,CAAC,SAAS,CAAC,QAAQ,KAAK,GAAG,CAAC,QAAQ,CAAC,CAC5C,CAAC;IACH,CAAC;CACD"}