@tdacorp/hyle-sdk 0.22.2 → 0.24.0
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/README.md +48 -1
- package/dist/check-routes-bin.js +41 -8
- package/dist/{chunk-KU7LWK4E.js → chunk-4REU4HJI.js} +40 -9
- package/dist/{chunk-ZIW6FDU2.js → chunk-5TKJH2XC.js} +2 -2
- package/dist/{chunk-DUPT6XLB.js → chunk-BDFMNY76.js} +18 -1
- package/dist/{chunk-7T5EEJHK.js → chunk-SY2FMIRZ.js} +1 -1
- package/dist/{chunk-IW3TUD4G.js → chunk-Y3BACEWA.js} +1 -1
- package/dist/{client-BGjmEWhN.d.cts → client-BErei7cE.d.ts} +8 -1
- package/dist/{client-D0LTpr3Y.d.ts → client-DrB2vcTi.d.cts} +8 -1
- package/dist/comments.cjs +5 -1
- package/dist/comments.js +5 -1
- package/dist/{embed-CbtsbZs3.d.cts → embed-B7T--kTT.d.cts} +1 -1
- package/dist/{embed-Cf_2ZR5x.d.ts → embed-DavTgSU4.d.ts} +1 -1
- package/dist/html.cjs +5 -1
- package/dist/html.js +2 -2
- package/dist/index.cjs +41 -8
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- package/dist/next.cjs +265 -70
- package/dist/next.d.cts +47 -7
- package/dist/next.d.ts +47 -7
- package/dist/next.js +224 -65
- package/dist/react.cjs +5 -1
- package/dist/react.d.cts +3 -3
- package/dist/react.d.ts +3 -3
- package/dist/react.js +3 -3
- package/dist/{resolve-BnIv7aB7.d.cts → resolve-03IVloXU.d.cts} +1 -1
- package/dist/{resolve-BysHtZ_i.d.ts → resolve-BseM68oy.d.ts} +1 -1
- package/dist/{types-D09Z072G.d.cts → types-Dx-fEiZd.d.cts} +33 -1
- package/dist/{types-D09Z072G.d.ts → types-Dx-fEiZd.d.ts} +33 -1
- package/dist/use-cache.cjs +41 -8
- package/dist/use-cache.d.cts +3 -3
- package/dist/use-cache.d.ts +3 -3
- package/dist/use-cache.js +3 -3
- package/package.json +1 -1
package/dist/next.cjs
CHANGED
|
@@ -31,6 +31,7 @@ __export(next_exports, {
|
|
|
31
31
|
createLlmsTxtRoute: () => createLlmsTxtRoute,
|
|
32
32
|
createMarkdownRoute: () => createMarkdownRoute,
|
|
33
33
|
createOgImageRoute: () => createOgImageRoute,
|
|
34
|
+
createProtectedUnlockRoute: () => createProtectedUnlockRoute,
|
|
34
35
|
createRevalidateRoute: () => createRevalidateRoute,
|
|
35
36
|
fetchResolver: () => fetchResolver,
|
|
36
37
|
hyleFeed: () => hyleFeed,
|
|
@@ -39,6 +40,9 @@ __export(next_exports, {
|
|
|
39
40
|
hylePage: () => hylePage,
|
|
40
41
|
hylePreviewMetadata: () => hylePreviewMetadata,
|
|
41
42
|
hylePreviewPage: () => hylePreviewPage,
|
|
43
|
+
hyleProtectedMetadata: () => hyleProtectedMetadata,
|
|
44
|
+
hyleProtectedPage: () => hyleProtectedPage,
|
|
45
|
+
hyleProtectedProxy: () => hyleProtectedProxy,
|
|
42
46
|
hyleRootMetadata: () => hyleRootMetadata,
|
|
43
47
|
hyleRootPage: () => hyleRootPage,
|
|
44
48
|
hyleRootSitemap: () => hyleRootSitemap,
|
|
@@ -70,7 +74,18 @@ var PREVIEW_TOKEN = new RegExp(`^${PREVIEW_TOKEN_SOURCE}$`);
|
|
|
70
74
|
var PREVIEW_HEADER = "cp-preview";
|
|
71
75
|
var PREVIEW_PARAM = "hyle_preview";
|
|
72
76
|
var PREVIEW_QUERY_SOURCE = `\\?${PREVIEW_PARAM}=${PREVIEW_TOKEN_SOURCE}`;
|
|
73
|
-
var
|
|
77
|
+
var PROTECTED_PARAM = "hyle_protected";
|
|
78
|
+
var PROTECTED_HEADER = "cp-protected";
|
|
79
|
+
var SHARE_SLUG = "[a-z0-9-]+(?:/[a-z0-9-]+){0,3}";
|
|
80
|
+
var PROTECTED_SLUG = new RegExp(`^${SHARE_SLUG}$`);
|
|
81
|
+
var PROTECTED_DOC_SLUG = /^[a-z0-9-]+$/;
|
|
82
|
+
var PROTECTED_PASSWORD = /^[\x21\x23-\x24\x26-\x2B\x2D-\x3A\x3C-\x5B\x5D-\x7E]{12,128}$/;
|
|
83
|
+
async function protectedCookieName(slug) {
|
|
84
|
+
const digest = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(slug));
|
|
85
|
+
return `hyle_p_${Buffer.from(digest).toString("base64url").slice(0, 16)}`;
|
|
86
|
+
}
|
|
87
|
+
var PROTECTED_QUERY_SOURCE = `\\?${PROTECTED_PARAM}=${SHARE_SLUG}`;
|
|
88
|
+
var HYLE_ASSET_URL = new RegExp(`^/assets/(${UUID}(?:\\.(?:${EXTENSIONS}))?)(${PREVIEW_QUERY_SOURCE}|${PROTECTED_QUERY_SOURCE})?$`, "i");
|
|
74
89
|
function hostAssetSrc(src) {
|
|
75
90
|
const [, file, query = ""] = HYLE_ASSET_URL.exec(src) ?? [];
|
|
76
91
|
return file ? `${ASSET_ROUTE_PREFIX}/${file.toLowerCase()}${query}` : src;
|
|
@@ -122,8 +137,8 @@ function mapNode(node, mark, depth) {
|
|
|
122
137
|
...Array.isArray(children) ? { children: children.map((child) => mapNode(child, mark, depth + 1)) } : {}
|
|
123
138
|
};
|
|
124
139
|
}
|
|
125
|
-
function
|
|
126
|
-
const mark = (value) => typeof value === "string" ? value.replace(ASSET_PATH, (path) => `${path}?${
|
|
140
|
+
function withAssetQuery(article, query) {
|
|
141
|
+
const mark = (value) => typeof value === "string" ? value.replace(ASSET_PATH, (path) => `${path}?${query}`) : value;
|
|
127
142
|
const { publication, content } = article;
|
|
128
143
|
return {
|
|
129
144
|
...article,
|
|
@@ -182,7 +197,7 @@ var KINDS = /* @__PURE__ */ new Set(["article", "list", "redirect", "notfound",
|
|
|
182
197
|
var isStrings = (value) => Array.isArray(value) && value.every((v) => typeof v === "string");
|
|
183
198
|
function isMounts(data) {
|
|
184
199
|
const mounts = data.mounts;
|
|
185
|
-
return typeof data.workspace_id === "string" && isStrings(data.reserved) && isStrings(data.supported_locales) && Array.isArray(mounts) && mounts.every((m) => typeof m?.prefix === "string" && typeof m.default_section === "string");
|
|
200
|
+
return typeof data.workspace_id === "string" && isStrings(data.reserved) && isStrings(data.supported_locales) && Array.isArray(mounts) && mounts.every((m) => typeof m?.prefix === "string" && typeof m.default_section === "string") && (data.protected === void 0 || isStrings(data.protected));
|
|
186
201
|
}
|
|
187
202
|
function checkBaseUrl(baseUrl, allowInsecureHttp) {
|
|
188
203
|
let origin;
|
|
@@ -263,13 +278,37 @@ function createHyleClient(options) {
|
|
|
263
278
|
if (data?.cp === 1 && data.kind === "disabled") return { kind: "disabled" };
|
|
264
279
|
const article = data?.article;
|
|
265
280
|
if (data?.cp !== 1 || data.kind !== "preview" || typeof data.expires_at !== "string" || article?.kind !== "article" || article.content?.format !== "hast" || !article.publication) throw failure(reply2);
|
|
266
|
-
return { kind: "preview", expires_at: data.expires_at, article:
|
|
281
|
+
return { kind: "preview", expires_at: data.expires_at, article: withAssetQuery(article, `${PREVIEW_PARAM}=${token}`) };
|
|
282
|
+
}
|
|
283
|
+
async function protectedGate(slug) {
|
|
284
|
+
if (!PROTECTED_SLUG.test(slug)) return { kind: "notfound" };
|
|
285
|
+
const reply2 = await get("/cp1/read/_protected/gate", new URLSearchParams({ path: slug }), { cache: "no-store" });
|
|
286
|
+
if (reply2.status === 404 && reply2.parsed?.error?.code === "NOT_FOUND") return { kind: "notfound" };
|
|
287
|
+
const data = reply2.parsed?.data;
|
|
288
|
+
if (data?.cp === 1 && data.kind === "disabled") return { kind: "disabled" };
|
|
289
|
+
if (data?.cp === 1 && data.kind === "gate") return { kind: "gate" };
|
|
290
|
+
throw failure(reply2);
|
|
291
|
+
}
|
|
292
|
+
async function protectedShare(slug, password, docSlug) {
|
|
293
|
+
if (!PROTECTED_SLUG.test(slug) || docSlug !== void 0 && !PROTECTED_DOC_SLUG.test(docSlug) || !PROTECTED_PASSWORD.test(password)) return { kind: "notfound" };
|
|
294
|
+
const path = docSlug === void 0 ? slug : `${slug}/${docSlug}`;
|
|
295
|
+
const reply2 = await get("/cp1/read/_protected", new URLSearchParams({ path }), { headers: { [PROTECTED_HEADER]: password }, cache: "no-store" });
|
|
296
|
+
if (reply2.status === 404 && reply2.parsed?.error?.code === "NOT_FOUND") return { kind: "notfound" };
|
|
297
|
+
const data = reply2.parsed?.data;
|
|
298
|
+
if (data?.cp === 1 && data.kind === "disabled") return { kind: "disabled" };
|
|
299
|
+
const article = data?.article;
|
|
300
|
+
const { name, expires_at: expires, documents, doc_slug: current } = data ?? {};
|
|
301
|
+
if (data?.cp !== 1 || data.kind !== "protected" || typeof name !== "string" || typeof expires !== "string" && expires !== null || !Array.isArray(documents) || typeof current !== "string" || article?.kind !== "article" || article.content?.format !== "hast" || !article.publication) throw failure(reply2);
|
|
302
|
+
return { cp: 1, kind: "protected", name, expires_at: expires, documents, doc_slug: current, article: withAssetQuery(article, `${PROTECTED_PARAM}=${slug}`) };
|
|
267
303
|
}
|
|
268
304
|
async function asset(file, opts = {}) {
|
|
269
305
|
if (!ASSET_FILE.test(file)) throw new TypeError("asset file must be <uuid>[.<ext>]");
|
|
270
306
|
const { previewToken } = opts;
|
|
271
307
|
if (previewToken !== void 0 && !PREVIEW_TOKEN.test(previewToken)) throw new TypeError("previewToken is not a preview token");
|
|
272
|
-
const
|
|
308
|
+
const { protectedAccess } = opts;
|
|
309
|
+
if (protectedAccess !== void 0 && !(PROTECTED_SLUG.test(protectedAccess.slug) && PROTECTED_PASSWORD.test(protectedAccess.password))) throw new TypeError("protectedAccess is not a share slug and password");
|
|
310
|
+
const query = protectedAccess === void 0 ? "" : `?protected=${encodeURIComponent(protectedAccess.slug)}`;
|
|
311
|
+
const url = `${base}/cp1/read/assets/${file}${query}`;
|
|
273
312
|
const headers = new Headers();
|
|
274
313
|
const applied = applyCredential(headers, options, "GET", url);
|
|
275
314
|
if (applied) await applied;
|
|
@@ -278,7 +317,9 @@ function createHyleClient(options) {
|
|
|
278
317
|
if (value) headers.set(name, value);
|
|
279
318
|
}
|
|
280
319
|
if (previewToken !== void 0) headers.set(PREVIEW_HEADER, previewToken);
|
|
281
|
-
|
|
320
|
+
if (protectedAccess !== void 0) headers.set(PROTECTED_HEADER, protectedAccess.password);
|
|
321
|
+
const uncached = previewToken !== void 0 || protectedAccess !== void 0;
|
|
322
|
+
return fetchImpl(url, { method: "GET", headers, redirect: "error", signal: AbortSignal.timeout(opts.timeoutMs ?? options.timeoutMs ?? DEFAULT_TIMEOUT_MS), ...uncached ? { cache: "no-store" } : {} });
|
|
282
323
|
}
|
|
283
324
|
async function theme(opts = {}) {
|
|
284
325
|
const url = `${base}/cp1/read/theme.css`;
|
|
@@ -287,7 +328,7 @@ function createHyleClient(options) {
|
|
|
287
328
|
if (applied) await applied;
|
|
288
329
|
return fetchImpl(url, { method: "GET", headers, redirect: "error", signal: AbortSignal.timeout(opts.timeoutMs ?? options.timeoutMs ?? DEFAULT_TIMEOUT_MS) });
|
|
289
330
|
}
|
|
290
|
-
return { resolve, mounts, pushPosts, preview, asset, theme };
|
|
331
|
+
return { resolve, mounts, pushPosts, preview, protectedGate, protected: protectedShare, asset, theme };
|
|
291
332
|
}
|
|
292
333
|
|
|
293
334
|
// src/delivery-dedupe.ts
|
|
@@ -2523,6 +2564,10 @@ function sameOriginProblem(req, write, allowedOrigins) {
|
|
|
2523
2564
|
const site = req.headers.get("sec-fetch-site");
|
|
2524
2565
|
if (site !== null && site !== "same-origin") return true;
|
|
2525
2566
|
if (!write) return false;
|
|
2567
|
+
if (req.headers.get(ENGAGE_CSRF_HEADER) !== "1") return true;
|
|
2568
|
+
return originMismatch(req, allowedOrigins);
|
|
2569
|
+
}
|
|
2570
|
+
function originMismatch(req, allowedOrigins) {
|
|
2526
2571
|
const origin = req.headers.get("origin");
|
|
2527
2572
|
if (origin === null) return true;
|
|
2528
2573
|
let parsed;
|
|
@@ -2531,7 +2576,6 @@ function sameOriginProblem(req, write, allowedOrigins) {
|
|
|
2531
2576
|
} catch {
|
|
2532
2577
|
return true;
|
|
2533
2578
|
}
|
|
2534
|
-
if (req.headers.get(ENGAGE_CSRF_HEADER) !== "1") return true;
|
|
2535
2579
|
if (allowedOrigins) return !allowedOrigins.some((o) => safeOrigin(o) === parsed.origin);
|
|
2536
2580
|
const host = req.headers.get("x-forwarded-host")?.split(",")[0]?.trim() || req.headers.get("host") || new URL(req.url).host;
|
|
2537
2581
|
const proto = req.headers.get("x-forwarded-proto")?.split(",")[0]?.trim().toLowerCase();
|
|
@@ -3089,7 +3133,7 @@ function createRevalidateRoute(options) {
|
|
|
3089
3133
|
}
|
|
3090
3134
|
|
|
3091
3135
|
// src/next/root.ts
|
|
3092
|
-
var
|
|
3136
|
+
var import_navigation7 = require("next/navigation");
|
|
3093
3137
|
|
|
3094
3138
|
// src/next/mount-match.ts
|
|
3095
3139
|
function activeMounts(mounts) {
|
|
@@ -3115,28 +3159,151 @@ function isReserved(path, reserved) {
|
|
|
3115
3159
|
return reserved.some((entry) => entry.endsWith("/*") ? prefixMatches(entry.slice(0, -2), path) : entry === path);
|
|
3116
3160
|
}
|
|
3117
3161
|
|
|
3162
|
+
// src/next/protected.tsx
|
|
3163
|
+
var import_headers = require("next/headers");
|
|
3164
|
+
var import_navigation6 = require("next/navigation");
|
|
3165
|
+
|
|
3166
|
+
// src/next/preview.tsx
|
|
3167
|
+
var import_navigation5 = require("next/navigation");
|
|
3168
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
3169
|
+
function drawArticle(article, options) {
|
|
3170
|
+
const { locale } = article.publication;
|
|
3171
|
+
const toHref = (sitePath, linkLocale = locale) => (options.localePrefix?.(linkLocale) ?? "") + sitePath;
|
|
3172
|
+
const props = { article, components: options.components, slots: options.slots, locale, toHref };
|
|
3173
|
+
return options.layout === "docs" ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(DocsPage, { ...props }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(ArticlePage, { ...props });
|
|
3174
|
+
}
|
|
3175
|
+
var hylePreviewMetadata = { robots: { index: false, follow: false }, referrer: "no-referrer" };
|
|
3176
|
+
var BANNER = {
|
|
3177
|
+
position: "sticky",
|
|
3178
|
+
top: 0,
|
|
3179
|
+
zIndex: 2147483647,
|
|
3180
|
+
padding: "8px 16px",
|
|
3181
|
+
background: "#fde047",
|
|
3182
|
+
color: "#1a1a1a",
|
|
3183
|
+
font: "600 14px/1.4 system-ui, sans-serif",
|
|
3184
|
+
textAlign: "center"
|
|
3185
|
+
};
|
|
3186
|
+
function hylePreviewPage(options) {
|
|
3187
|
+
return async function HylePreviewPage({ searchParams }) {
|
|
3188
|
+
const { token } = await searchParams ?? {};
|
|
3189
|
+
const result = await createHyleClient(options).preview(typeof token === "string" ? token : void 0);
|
|
3190
|
+
if (result.kind !== "preview") (0, import_navigation5.notFound)();
|
|
3191
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
|
|
3192
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("meta", { name: "robots", content: "noindex, nofollow" }),
|
|
3193
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("meta", { name: "referrer", content: "no-referrer" }),
|
|
3194
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { role: "status", style: BANNER, children: "Unpublished draft preview" }),
|
|
3195
|
+
drawArticle(result.article, options)
|
|
3196
|
+
] });
|
|
3197
|
+
};
|
|
3198
|
+
}
|
|
3199
|
+
|
|
3200
|
+
// src/next/protected.tsx
|
|
3201
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
3202
|
+
var hyleProtectedMetadata = { robots: { index: false, follow: false }, referrer: "no-referrer" };
|
|
3203
|
+
var COOKIE_MAX_AGE_SECONDS = 12 * 60 * 60;
|
|
3204
|
+
var UNLOCK_MAX_BYTES = 1024;
|
|
3205
|
+
var PRIVATE_HEADERS = { "Cache-Control": "no-store", "Referrer-Policy": "no-referrer", "X-Robots-Tag": "noindex, nofollow" };
|
|
3206
|
+
var UNLOCK_PATH = "/hyle-protected/unlock";
|
|
3207
|
+
var PASSWORD_FIELD = "hyle-protected-password";
|
|
3208
|
+
var ERROR_ID = "hyle-protected-error";
|
|
3209
|
+
function PasswordForm({ slug, failed }) {
|
|
3210
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("main", { children: [
|
|
3211
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("h1", { children: "Password required" }),
|
|
3212
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("form", { method: "post", action: UNLOCK_PATH, autoComplete: "off", children: [
|
|
3213
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("input", { type: "hidden", name: "slug", value: slug }),
|
|
3214
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("label", { htmlFor: PASSWORD_FIELD, children: "Password" }),
|
|
3215
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
3216
|
+
"input",
|
|
3217
|
+
{
|
|
3218
|
+
id: PASSWORD_FIELD,
|
|
3219
|
+
name: "password",
|
|
3220
|
+
type: "password",
|
|
3221
|
+
autoComplete: "off",
|
|
3222
|
+
spellCheck: false,
|
|
3223
|
+
required: true,
|
|
3224
|
+
minLength: 12,
|
|
3225
|
+
maxLength: 128,
|
|
3226
|
+
"aria-invalid": failed || void 0,
|
|
3227
|
+
"aria-describedby": failed ? ERROR_ID : void 0
|
|
3228
|
+
}
|
|
3229
|
+
),
|
|
3230
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("button", { type: "submit", children: "Open" }),
|
|
3231
|
+
failed ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { id: ERROR_ID, role: "alert", children: "Wrong or expired password." }) : null
|
|
3232
|
+
] })
|
|
3233
|
+
] });
|
|
3234
|
+
}
|
|
3235
|
+
async function drawProtectedShare(options, slug, docSlug) {
|
|
3236
|
+
const client = createHyleClient({ baseUrl: options.baseUrl, token: options.token });
|
|
3237
|
+
const password = (await (0, import_headers.cookies)()).get(await protectedCookieName(slug))?.value;
|
|
3238
|
+
const share = password === void 0 ? void 0 : await client.protected(slug, password, docSlug);
|
|
3239
|
+
if (share?.kind === "disabled") (0, import_navigation6.notFound)();
|
|
3240
|
+
if (share?.kind === "protected") {
|
|
3241
|
+
if (docSlug !== void 0 && share.doc_slug !== docSlug) (0, import_navigation6.notFound)();
|
|
3242
|
+
const here = `/${slug}/${share.doc_slug}`;
|
|
3243
|
+
const article = {
|
|
3244
|
+
...share.article,
|
|
3245
|
+
publication: { ...share.article.publication, canonical_path: here },
|
|
3246
|
+
nav: { truncated: false, items: share.documents.map((d) => ({ slug: d.doc_slug, title: d.title, canonical_path: `/${slug}/${d.doc_slug}`, children: [] })) }
|
|
3247
|
+
};
|
|
3248
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [
|
|
3249
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("meta", { name: "robots", content: "noindex, nofollow" }),
|
|
3250
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("meta", { name: "referrer", content: "no-referrer" }),
|
|
3251
|
+
drawArticle(article, { ...options, layout: share.documents.length > 1 ? "docs" : "article" })
|
|
3252
|
+
] });
|
|
3253
|
+
}
|
|
3254
|
+
const gate = await client.protectedGate(slug);
|
|
3255
|
+
if (gate.kind !== "gate") (0, import_navigation6.notFound)();
|
|
3256
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [
|
|
3257
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("meta", { name: "robots", content: "noindex, nofollow" }),
|
|
3258
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("meta", { name: "referrer", content: "no-referrer" }),
|
|
3259
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(PasswordForm, { slug, failed: password !== void 0 })
|
|
3260
|
+
] });
|
|
3261
|
+
}
|
|
3262
|
+
function createProtectedUnlockRoute() {
|
|
3263
|
+
return {
|
|
3264
|
+
async POST(req) {
|
|
3265
|
+
const site = req.headers.get("sec-fetch-site");
|
|
3266
|
+
if (site === null ? originMismatch(req) : site !== "same-origin") return new Response(null, { status: 403, headers: PRIVATE_HEADERS });
|
|
3267
|
+
if (!/^application\/x-www-form-urlencoded(\s*;|$)/i.test(req.headers.get("content-type") ?? "")) return new Response(null, { status: 415, headers: PRIVATE_HEADERS });
|
|
3268
|
+
if (Number(req.headers.get("content-length")) > UNLOCK_MAX_BYTES) return new Response(null, { status: 413, headers: PRIVATE_HEADERS });
|
|
3269
|
+
const form = await readCapped(new Response(req.body), UNLOCK_MAX_BYTES).catch(() => void 0);
|
|
3270
|
+
if (form === void 0) return new Response(null, { status: 413, headers: PRIVATE_HEADERS });
|
|
3271
|
+
const fields = new URLSearchParams(form);
|
|
3272
|
+
const slug = fields.get("slug") ?? "";
|
|
3273
|
+
if (!PROTECTED_SLUG.test(slug)) return new Response(null, { status: 404, headers: PRIVATE_HEADERS });
|
|
3274
|
+
const password = fields.get("password") ?? "";
|
|
3275
|
+
const headers = new Headers({ ...PRIVATE_HEADERS, Location: `/${slug}` });
|
|
3276
|
+
if (PROTECTED_PASSWORD.test(password)) {
|
|
3277
|
+
const name = await protectedCookieName(slug);
|
|
3278
|
+
for (const path of [`/${slug}`, ASSET_ROUTE_PREFIX]) headers.append("Set-Cookie", `${name}=${password}; Max-Age=${COOKIE_MAX_AGE_SECONDS}; Path=${path}; HttpOnly; Secure; SameSite=Lax`);
|
|
3279
|
+
}
|
|
3280
|
+
return new Response(null, { status: 303, headers });
|
|
3281
|
+
}
|
|
3282
|
+
};
|
|
3283
|
+
}
|
|
3284
|
+
|
|
3118
3285
|
// src/next/root.ts
|
|
3119
3286
|
var MOUNTS_MAX_STALE_MS = 15 * 60 * 1e3;
|
|
3120
3287
|
var SECTION_SLUG = /^[A-Za-z0-9][A-Za-z0-9_-]*$/;
|
|
3121
|
-
var NONE = { mounts: [], reserved: [], defaultLocale: "" };
|
|
3288
|
+
var NONE = { mounts: [], reserved: [], defaultLocale: "", protected: [] };
|
|
3122
3289
|
var lastKnownGood = /* @__PURE__ */ new Map();
|
|
3123
|
-
function mountsLoader(config) {
|
|
3290
|
+
function mountsLoader(config, ttlMs) {
|
|
3124
3291
|
if (!config.workspaceId) throw new TypeError("hyleRootPage: `workspaceId` is required for the fetch cache");
|
|
3125
3292
|
const client = createHyleClient({ baseUrl: config.baseUrl, token: config.token });
|
|
3126
3293
|
const init = { next: { revalidate: config.revalidate ?? DEFAULT_REVALIDATE, tags: workspaceTags(config.workspaceId).slice(0, 1) } };
|
|
3127
3294
|
const key = `${new URL(config.baseUrl).origin}|${config.workspaceId}`;
|
|
3128
|
-
|
|
3295
|
+
async function fetchLoaded() {
|
|
3129
3296
|
try {
|
|
3130
3297
|
const result = await client.mounts({ init });
|
|
3131
3298
|
if (result.kind !== "mounts") {
|
|
3132
3299
|
lastKnownGood.delete(key);
|
|
3133
3300
|
return NONE;
|
|
3134
3301
|
}
|
|
3135
|
-
const loaded = { mounts: activeMounts(result.mounts), reserved: result.reserved, defaultLocale: result.default_locale };
|
|
3302
|
+
const loaded = { mounts: activeMounts(result.mounts), reserved: result.reserved, defaultLocale: result.default_locale, protected: result.protected ?? [] };
|
|
3136
3303
|
lastKnownGood.set(key, { loaded, at: Date.now() });
|
|
3137
3304
|
return loaded;
|
|
3138
3305
|
} catch (error) {
|
|
3139
|
-
(0,
|
|
3306
|
+
(0, import_navigation7.unstable_rethrow)(error);
|
|
3140
3307
|
if (error instanceof Cp1ClientError && (error.status === 401 || error.status === 403)) {
|
|
3141
3308
|
lastKnownGood.delete(key);
|
|
3142
3309
|
throw error;
|
|
@@ -3145,15 +3312,21 @@ function mountsLoader(config) {
|
|
|
3145
3312
|
if (kept && Date.now() - kept.at <= MOUNTS_MAX_STALE_MS) return kept.loaded;
|
|
3146
3313
|
throw error;
|
|
3147
3314
|
}
|
|
3315
|
+
}
|
|
3316
|
+
if (ttlMs === void 0) return fetchLoaded;
|
|
3317
|
+
let memo;
|
|
3318
|
+
return function load() {
|
|
3319
|
+
if (!memo || memo.until <= Date.now()) memo = { read: fetchLoaded(), until: Date.now() + ttlMs };
|
|
3320
|
+
return memo.read;
|
|
3148
3321
|
};
|
|
3149
3322
|
}
|
|
3150
3323
|
var asArray = (options) => Array.isArray(options) ? options : [options];
|
|
3151
|
-
function setup(options) {
|
|
3324
|
+
function setup(options, ttlMs) {
|
|
3152
3325
|
const configs = asArray(options);
|
|
3153
3326
|
if (configs.length === 0) throw new TypeError("hyleRootPage: pass at least one workspace config");
|
|
3154
3327
|
const param = configs[0].param ?? "hyle";
|
|
3155
3328
|
if (configs.some((c) => (c.param ?? "hyle") !== param)) throw new TypeError("hyleRootPage: every config must use the same `param`");
|
|
3156
|
-
return { configs, param, loaders: configs.map(mountsLoader) };
|
|
3329
|
+
return { configs, param, loaders: configs.map((config) => mountsLoader(config, ttlMs)) };
|
|
3157
3330
|
}
|
|
3158
3331
|
var sectionsOf = (config, mount) => [
|
|
3159
3332
|
...config.sections ?? [],
|
|
@@ -3163,20 +3336,33 @@ function mountOptionsOf(config, mount) {
|
|
|
3163
3336
|
const { mountOptions, ...rest } = config;
|
|
3164
3337
|
return { ...rest, ...mountOptions?.[mount.prefix === "" ? "/" : mount.prefix], basePath: mount.prefix, sections: sectionsOf(config, mount) };
|
|
3165
3338
|
}
|
|
3166
|
-
function rootMounts(options) {
|
|
3167
|
-
const { configs, param, loaders } = setup(options);
|
|
3339
|
+
function rootMounts(options, ttlMs) {
|
|
3340
|
+
const { configs, param, loaders } = setup(options, ttlMs);
|
|
3168
3341
|
return {
|
|
3169
3342
|
param,
|
|
3170
3343
|
async locate(path) {
|
|
3171
3344
|
const loaded = await Promise.all(loaders.map((load) => load()));
|
|
3345
|
+
let share;
|
|
3346
|
+
loaded.forEach(({ protected: slugs }, index) => {
|
|
3347
|
+
for (const slug of slugs) {
|
|
3348
|
+
const depth = slug.split("/").length;
|
|
3349
|
+
if (!prefixMatches(`/${slug}`, path) || share && depth <= share.depth) continue;
|
|
3350
|
+
const docSlug = path === `/${slug}` ? void 0 : path.slice(slug.length + 2);
|
|
3351
|
+
if (docSlug === void 0 || PROTECTED_DOC_SLUG.test(docSlug)) share = { index, slug, depth, docSlug };
|
|
3352
|
+
}
|
|
3353
|
+
});
|
|
3172
3354
|
let best;
|
|
3173
|
-
loaded.forEach(({ mounts, reserved },
|
|
3355
|
+
loaded.forEach(({ mounts, reserved }, index) => {
|
|
3174
3356
|
if (isReserved(path, reserved)) return;
|
|
3175
|
-
for (const
|
|
3357
|
+
for (const mount of mounts) if (prefixMatches(mount.prefix, path) && (!best || mount.depth > best.mount.depth)) best = { index, mount };
|
|
3176
3358
|
});
|
|
3177
|
-
|
|
3178
|
-
const
|
|
3179
|
-
|
|
3359
|
+
const won = share;
|
|
3360
|
+
const mounted = best;
|
|
3361
|
+
if (won && (!mounted || won.depth > mounted.mount.depth || won.depth === mounted.mount.depth && won.index === mounted.index)) {
|
|
3362
|
+
return { share: { config: configs[won.index], slug: won.slug, docSlug: won.docSlug } };
|
|
3363
|
+
}
|
|
3364
|
+
if (!mounted) return void 0;
|
|
3365
|
+
return { options: mountOptionsOf(configs[mounted.index], mounted.mount), mount: mounted.mount, index: mounted.index };
|
|
3180
3366
|
},
|
|
3181
3367
|
async all() {
|
|
3182
3368
|
const out = [];
|
|
@@ -3188,7 +3374,7 @@ function rootMounts(options) {
|
|
|
3188
3374
|
}
|
|
3189
3375
|
};
|
|
3190
3376
|
}
|
|
3191
|
-
function createRouter(options, make) {
|
|
3377
|
+
function createRouter(options, make, share) {
|
|
3192
3378
|
const mounts = rootMounts(options);
|
|
3193
3379
|
const handlers = /* @__PURE__ */ new Map();
|
|
3194
3380
|
return async function route(params) {
|
|
@@ -3198,6 +3384,7 @@ function createRouter(options, make) {
|
|
|
3198
3384
|
if (path === void 0 || path === "/" || !segments) return void 0;
|
|
3199
3385
|
const hit = await mounts.locate(path);
|
|
3200
3386
|
if (!hit) return void 0;
|
|
3387
|
+
if ("share" in hit) return { handler: share(hit.share), params };
|
|
3201
3388
|
const { mount, index } = hit;
|
|
3202
3389
|
const id = `${index}|${mount.prefix}|${mount.defaultSection}`;
|
|
3203
3390
|
let handler = handlers.get(id);
|
|
@@ -3209,15 +3396,15 @@ function createRouter(options, make) {
|
|
|
3209
3396
|
};
|
|
3210
3397
|
}
|
|
3211
3398
|
function hyleRootPage(options) {
|
|
3212
|
-
const route = createRouter(options, hylePage);
|
|
3399
|
+
const route = createRouter(options, hylePage, (s) => () => drawProtectedShare(s.config, s.slug, s.docSlug));
|
|
3213
3400
|
return async function HyleRootPage({ params, searchParams }) {
|
|
3214
3401
|
const hit = await route(await params ?? {});
|
|
3215
|
-
if (!hit) (0,
|
|
3402
|
+
if (!hit) (0, import_navigation7.notFound)();
|
|
3216
3403
|
return hit.handler({ params: Promise.resolve(hit.params), ...searchParams ? { searchParams } : {} });
|
|
3217
3404
|
};
|
|
3218
3405
|
}
|
|
3219
3406
|
function hyleRootMetadata(options) {
|
|
3220
|
-
const route = createRouter(options, hyleMetadata);
|
|
3407
|
+
const route = createRouter(options, hyleMetadata, () => async () => hyleProtectedMetadata);
|
|
3221
3408
|
return async function generateMetadata({ params, searchParams }, parent) {
|
|
3222
3409
|
const hit = await route(await params ?? {});
|
|
3223
3410
|
return hit ? hit.handler({ params: Promise.resolve(hit.params), ...searchParams ? { searchParams } : {} }, parent) : {};
|
|
@@ -3253,7 +3440,7 @@ function createMarkdownRoute(options) {
|
|
|
3253
3440
|
if (path === void 0 || path === "/") return reply(null, 404);
|
|
3254
3441
|
try {
|
|
3255
3442
|
const hit = await mounts.locate(path);
|
|
3256
|
-
if (!hit) return reply(null, 404);
|
|
3443
|
+
if (!hit || "share" in hit) return reply(null, 404);
|
|
3257
3444
|
const { locale, toHref } = routeContext({ ...hit.options, basePath: "", param: "path" }, params);
|
|
3258
3445
|
const result = await resolverFor(hit.options)(path, locale, void 0, void 0, void 0, "md");
|
|
3259
3446
|
if (result.kind === "article" && result.content.format === "md") {
|
|
@@ -3277,7 +3464,7 @@ function createMarkdownRoute(options) {
|
|
|
3277
3464
|
}
|
|
3278
3465
|
|
|
3279
3466
|
// src/next/llms.ts
|
|
3280
|
-
var
|
|
3467
|
+
var import_navigation8 = require("next/navigation");
|
|
3281
3468
|
var oneLine = (text) => text.replace(/\s+/g, " ").trim();
|
|
3282
3469
|
var linkTarget = (url) => url.replace(/[()]/g, (c) => c === "(" ? "%28" : "%29");
|
|
3283
3470
|
function createLlmsTxtRoute(options, llms) {
|
|
@@ -3302,7 +3489,7 @@ function createLlmsTxtRoute(options, llms) {
|
|
|
3302
3489
|
return new Response(`${lines.join("\n")}
|
|
3303
3490
|
`, { headers: { "Content-Type": "text/plain; charset=utf-8" } });
|
|
3304
3491
|
} catch (error) {
|
|
3305
|
-
(0,
|
|
3492
|
+
(0, import_navigation8.unstable_rethrow)(error);
|
|
3306
3493
|
console.error(`hyle: ${error instanceof Error ? error.name : "UnknownError"}`);
|
|
3307
3494
|
return new Response(null, { status: 503 });
|
|
3308
3495
|
}
|
|
@@ -3319,7 +3506,7 @@ var DEFAULT_TIMEOUT_MS3 = 3e4;
|
|
|
3319
3506
|
var CACHE_CONTROL = "public, max-age=3600, s-maxage=86400, stale-while-revalidate=86400";
|
|
3320
3507
|
var PARTIAL_CACHE_CONTROL = "no-store";
|
|
3321
3508
|
var SAFE_HEADERS = { "X-Content-Type-Options": "nosniff", "Content-Security-Policy": "default-src 'none'; style-src 'unsafe-inline'; sandbox" };
|
|
3322
|
-
var
|
|
3509
|
+
var PRIVATE_HEADERS2 = { "Cache-Control": "no-store", "Referrer-Policy": "no-referrer", "X-Robots-Tag": "noindex, nofollow" };
|
|
3323
3510
|
var empty = (status, headers = {}) => new Response(null, { status, headers: { "Cache-Control": "no-store", ...headers } });
|
|
3324
3511
|
var isSwitchedOff3 = (value) => ["0", "false"].includes(value?.trim().toLowerCase() ?? "");
|
|
3325
3512
|
var THEME_CACHE_CONTROL = "public, max-age=31536000, immutable";
|
|
@@ -3347,6 +3534,12 @@ async function serveTheme(client, scope, hash, timeoutMs, head) {
|
|
|
3347
3534
|
return empty(502);
|
|
3348
3535
|
}
|
|
3349
3536
|
}
|
|
3537
|
+
async function protectedAccessFor(req, slug) {
|
|
3538
|
+
if (!PROTECTED_SLUG.test(slug)) return void 0;
|
|
3539
|
+
const name = await protectedCookieName(slug);
|
|
3540
|
+
const password = req.headers.get("cookie")?.split(";").map((c) => c.trim()).find((c) => c.startsWith(`${name}=`))?.slice(name.length + 1);
|
|
3541
|
+
return password !== void 0 && PROTECTED_PASSWORD.test(password) ? { slug, password } : void 0;
|
|
3542
|
+
}
|
|
3350
3543
|
function capped(body, max) {
|
|
3351
3544
|
let seen = 0;
|
|
3352
3545
|
return body.pipeThrough(
|
|
@@ -3363,17 +3556,21 @@ function createAssetRoute(options) {
|
|
|
3363
3556
|
let client;
|
|
3364
3557
|
const maxBytes = options.maxBytes ?? DEFAULT_MAX_BYTES;
|
|
3365
3558
|
async function serve(req, ctx2, head) {
|
|
3366
|
-
const
|
|
3367
|
-
const
|
|
3368
|
-
|
|
3559
|
+
const query = new URL(req.url).searchParams;
|
|
3560
|
+
const previewToken = query.get(PREVIEW_PARAM);
|
|
3561
|
+
const slug = query.get(PROTECTED_PARAM);
|
|
3562
|
+
const res = await relay(req, ctx2, head, previewToken, slug);
|
|
3563
|
+
if (previewToken !== null || slug !== null) for (const [name, value] of Object.entries(PRIVATE_HEADERS2)) res.headers.set(name, value);
|
|
3369
3564
|
return res;
|
|
3370
3565
|
}
|
|
3371
|
-
async function relay(req, ctx2, head, previewToken) {
|
|
3566
|
+
async function relay(req, ctx2, head, previewToken, slug) {
|
|
3372
3567
|
if (isSwitchedOff3((options.env ?? process.env).HYLE_CONTENT_ENABLED)) return empty(404);
|
|
3373
3568
|
const file = (await ctx2.params).file;
|
|
3374
3569
|
const [, themeScope, themeHash] = typeof file === "string" ? THEME_FILE.exec(file) ?? [] : [];
|
|
3375
3570
|
if (typeof file !== "string" || !themeHash && !ASSET_FILE.test(file)) return empty(404);
|
|
3376
3571
|
if (previewToken !== null && !PREVIEW_TOKEN.test(previewToken)) return empty(404);
|
|
3572
|
+
const protectedAccess = slug === null ? void 0 : await protectedAccessFor(req, slug);
|
|
3573
|
+
if (slug !== null && protectedAccess === void 0) return empty(404);
|
|
3377
3574
|
try {
|
|
3378
3575
|
client ??= createHyleClient({ baseUrl: options.baseUrl?.trim() ?? "", token: options.token?.trim() ?? "", ...options.fetch ? { fetch: options.fetch } : {} });
|
|
3379
3576
|
} catch {
|
|
@@ -3385,6 +3582,7 @@ function createAssetRoute(options) {
|
|
|
3385
3582
|
upstream = await client.asset(file, {
|
|
3386
3583
|
timeoutMs: options.timeoutMs ?? DEFAULT_TIMEOUT_MS3,
|
|
3387
3584
|
...previewToken === null ? {} : { previewToken },
|
|
3585
|
+
...protectedAccess === void 0 ? {} : { protectedAccess },
|
|
3388
3586
|
headers: { range: req.headers.get("range"), "if-range": req.headers.get("if-range"), "if-none-match": req.headers.get("if-none-match") }
|
|
3389
3587
|
});
|
|
3390
3588
|
} catch {
|
|
@@ -3403,7 +3601,7 @@ function createAssetRoute(options) {
|
|
|
3403
3601
|
const range = upstream.headers.get("content-range");
|
|
3404
3602
|
return empty(416, range ? { "Content-Range": range } : {});
|
|
3405
3603
|
}
|
|
3406
|
-
if (upstream.status === 429 && previewToken !== null) {
|
|
3604
|
+
if (upstream.status === 429 && (previewToken !== null || slug !== null)) {
|
|
3407
3605
|
drop();
|
|
3408
3606
|
const wait = upstream.headers.get("retry-after");
|
|
3409
3607
|
return empty(429, wait ? { "Retry-After": wait } : {});
|
|
@@ -3430,7 +3628,7 @@ function createAssetRoute(options) {
|
|
|
3430
3628
|
}
|
|
3431
3629
|
|
|
3432
3630
|
// src/next/og.tsx
|
|
3433
|
-
var
|
|
3631
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
3434
3632
|
var SIZE = { width: 1200, height: 630 };
|
|
3435
3633
|
var MAX_TITLE = 140;
|
|
3436
3634
|
function createOgImageRoute(options) {
|
|
@@ -3460,9 +3658,9 @@ function createOgImageRoute(options) {
|
|
|
3460
3658
|
const chars = [...title];
|
|
3461
3659
|
const shown = chars.length > MAX_TITLE ? `${chars.slice(0, MAX_TITLE - 1).join("")}\u2026` : title;
|
|
3462
3660
|
return new import_og.ImageResponse(
|
|
3463
|
-
/* @__PURE__ */ (0,
|
|
3464
|
-
/* @__PURE__ */ (0,
|
|
3465
|
-
options.siteName ? /* @__PURE__ */ (0,
|
|
3661
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { style: { display: "flex", flexDirection: "column", justifyContent: "space-between", width: "100%", height: "100%", padding: 80, background: "#111827", color: "#ffffff" }, children: [
|
|
3662
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { style: { fontSize: 64, fontWeight: 700, lineHeight: 1.2 }, children: shown }),
|
|
3663
|
+
options.siteName ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { style: { fontSize: 32, color: "#9ca3af" }, children: options.siteName }) : null
|
|
3466
3664
|
] }),
|
|
3467
3665
|
// shortcut: @vercel/og fetches Google Fonts / emoji assets at render time for non-Latin titles and emoji (no switch to disable it), upgrade to a satori render with bundled fonts if a host needs zero egress.
|
|
3468
3666
|
{ ...SIZE, headers: { "cache-control": "public, max-age=3600, s-maxage=31536000, immutable" } }
|
|
@@ -3471,35 +3669,28 @@ function createOgImageRoute(options) {
|
|
|
3471
3669
|
};
|
|
3472
3670
|
}
|
|
3473
3671
|
|
|
3474
|
-
// src/next/
|
|
3475
|
-
var
|
|
3476
|
-
var
|
|
3477
|
-
var
|
|
3478
|
-
var
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
|
|
3487
|
-
};
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
const
|
|
3494
|
-
|
|
3495
|
-
|
|
3496
|
-
const props = { article, components: options.components, slots: options.slots, locale, toHref };
|
|
3497
|
-
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [
|
|
3498
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("meta", { name: "robots", content: "noindex, nofollow" }),
|
|
3499
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("meta", { name: "referrer", content: "no-referrer" }),
|
|
3500
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { role: "status", style: BANNER, children: "Unpublished draft preview" }),
|
|
3501
|
-
options.layout === "docs" ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(DocsPage, { ...props }) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ArticlePage, { ...props })
|
|
3502
|
-
] });
|
|
3672
|
+
// src/next/protected-view.ts
|
|
3673
|
+
var import_navigation9 = require("next/navigation");
|
|
3674
|
+
var import_server = require("next/server");
|
|
3675
|
+
var VIEW_PATH = "/hyle-protected/view";
|
|
3676
|
+
var MOUNTS_SNAPSHOT_MS = 3e4;
|
|
3677
|
+
var SHARE_PATH = /^\/[a-z0-9-]+(?:\/[a-z0-9-]+){0,4}$/;
|
|
3678
|
+
function hyleProtectedProxy(options) {
|
|
3679
|
+
const mounts = rootMounts(options, MOUNTS_SNAPSHOT_MS);
|
|
3680
|
+
return async function protectedProxy(req) {
|
|
3681
|
+
const path = req.nextUrl.pathname;
|
|
3682
|
+
if (!SHARE_PATH.test(path)) return void 0;
|
|
3683
|
+
const hit = await mounts.locate(path).catch(() => void 0);
|
|
3684
|
+
return hit && "share" in hit ? import_server.NextResponse.rewrite(new URL(`${VIEW_PATH}${path}`, req.url)) : void 0;
|
|
3685
|
+
};
|
|
3686
|
+
}
|
|
3687
|
+
function hyleProtectedPage(options) {
|
|
3688
|
+
const mounts = rootMounts(options);
|
|
3689
|
+
return async function HyleProtectedPage({ params }) {
|
|
3690
|
+
const path = `/${((await params).path ?? []).join("/")}`;
|
|
3691
|
+
const hit = SHARE_PATH.test(path) ? await mounts.locate(path) : void 0;
|
|
3692
|
+
if (!hit || !("share" in hit)) (0, import_navigation9.notFound)();
|
|
3693
|
+
return drawProtectedShare(hit.share.config, hit.share.slug, hit.share.docSlug);
|
|
3503
3694
|
};
|
|
3504
3695
|
}
|
|
3505
3696
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -3515,6 +3706,7 @@ function hylePreviewPage(options) {
|
|
|
3515
3706
|
createLlmsTxtRoute,
|
|
3516
3707
|
createMarkdownRoute,
|
|
3517
3708
|
createOgImageRoute,
|
|
3709
|
+
createProtectedUnlockRoute,
|
|
3518
3710
|
createRevalidateRoute,
|
|
3519
3711
|
fetchResolver,
|
|
3520
3712
|
hyleFeed,
|
|
@@ -3523,6 +3715,9 @@ function hylePreviewPage(options) {
|
|
|
3523
3715
|
hylePage,
|
|
3524
3716
|
hylePreviewMetadata,
|
|
3525
3717
|
hylePreviewPage,
|
|
3718
|
+
hyleProtectedMetadata,
|
|
3719
|
+
hyleProtectedPage,
|
|
3720
|
+
hyleProtectedProxy,
|
|
3526
3721
|
hyleRootMetadata,
|
|
3527
3722
|
hyleRootPage,
|
|
3528
3723
|
hyleRootSitemap,
|