jskelet 0.5.2 → 0.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -0
- package/docs/06-cache.md +62 -11
- package/docs/07-yapilandirma.md +54 -3
- package/docs/12-panel-ve-oturum.md +88 -0
- package/docs/en/06-caching.md +63 -12
- package/docs/en/07-configuration.md +56 -3
- package/docs/en/12-dashboards-and-sessions.md +91 -0
- package/package.json +2 -2
- package/src/client/index.js +10 -0
- package/src/client/shared-cookie.js +225 -0
- package/src/config/defaults.js +27 -0
- package/src/config/index.js +108 -3
- package/src/http/cookies-entry.js +20 -0
- package/src/http/cookies.js +2 -0
- package/src/http/shared-cookie.js +178 -0
- package/src/index.js +7 -0
- package/src/server/auth/handoff.js +226 -0
- package/src/server/cache-vary.js +113 -0
- package/src/server/create-app.js +14 -0
- package/src/server/html-cache.js +17 -7
- package/src/server/prewarm.js +78 -10
- package/src/server/render.js +16 -7
- package/src/shared/cookie-domain.js +66 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Paylaşımlı cookie Domain seçimi — sunucu ve istemci aynı kuralları kullanır.
|
|
3
|
+
*
|
|
4
|
+
* `brand.sharedCookieRoots` örn. `[".investvio.com", ".localhost"]`.
|
|
5
|
+
* Host bu köklerden birine uyuyorsa Domain olarak o kök yazılır.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @param {string} host Host veya Host:port.
|
|
10
|
+
* @returns {string} Lowercase, portsuz.
|
|
11
|
+
*/
|
|
12
|
+
export function stripHostPort(host) {
|
|
13
|
+
const raw = String(host ?? "")
|
|
14
|
+
.split(",")[0]
|
|
15
|
+
.trim()
|
|
16
|
+
.toLowerCase();
|
|
17
|
+
if (!raw) return "";
|
|
18
|
+
if (raw.startsWith("[")) {
|
|
19
|
+
const end = raw.indexOf("]");
|
|
20
|
+
return end === -1 ? raw : raw.slice(0, end + 1);
|
|
21
|
+
}
|
|
22
|
+
const colon = raw.lastIndexOf(":");
|
|
23
|
+
if (colon === -1) return raw;
|
|
24
|
+
if (raw.indexOf(":") !== colon) return raw;
|
|
25
|
+
return raw.slice(0, colon);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Kökü `Domain=` biçimine getirir (başında nokta).
|
|
30
|
+
*
|
|
31
|
+
* @param {unknown} root
|
|
32
|
+
* @returns {string | null}
|
|
33
|
+
*/
|
|
34
|
+
export function normalizeCookieRoot(root) {
|
|
35
|
+
if (typeof root !== "string") return null;
|
|
36
|
+
const trimmed = root.trim().toLowerCase();
|
|
37
|
+
if (!trimmed || trimmed === ".") return null;
|
|
38
|
+
const bare = trimmed.replace(/^\./, "");
|
|
39
|
+
if (!bare || bare.includes("/") || bare.includes(":")) return null;
|
|
40
|
+
return `.${bare}`;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* @param {string} hostname Portsuz hostname.
|
|
45
|
+
* @param {Iterable<string>} roots `brand.sharedCookieRoots`.
|
|
46
|
+
* @returns {string | null} `Domain` değeri (başında nokta) ya da eşleşme yoksa null.
|
|
47
|
+
*/
|
|
48
|
+
export function resolveSharedCookieDomain(hostname, roots) {
|
|
49
|
+
const host = stripHostPort(hostname);
|
|
50
|
+
if (!host) return null;
|
|
51
|
+
|
|
52
|
+
for (const entry of roots ?? []) {
|
|
53
|
+
const root = normalizeCookieRoot(entry);
|
|
54
|
+
if (!root) continue;
|
|
55
|
+
const bare = root.slice(1);
|
|
56
|
+
if (host === bare || host.endsWith(`.${bare}`)) return root;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Paylaşımlı cookie için önerilen üst sınır. JWT / büyük token buraya
|
|
64
|
+
* sığmaz — kısa session id koyun; aksi halde handoff veya host-only cookie.
|
|
65
|
+
*/
|
|
66
|
+
export const SHARED_COOKIE_WARN_BYTES = 512;
|