@tdacorp/hyle-sdk 0.23.0 → 0.24.1
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 +36 -18
- package/dist/check-routes-bin.js +34 -16
- package/dist/{chunk-UFMKLCXS.js → chunk-5TKJH2XC.js} +2 -2
- package/dist/{chunk-VXARM37R.js → chunk-BDFMNY76.js} +11 -5
- package/dist/{chunk-VUML2UPD.js → chunk-O4QWHXVH.js} +1 -1
- package/dist/{chunk-YHXE3TGS.js → chunk-RCK4NCYC.js} +33 -16
- package/dist/{chunk-JHZJOJDC.js → chunk-Y3BACEWA.js} +1 -1
- package/dist/{client-DK-S2580.d.cts → client-CI-3cHtc.d.cts} +13 -5
- package/dist/{client--ighAWaj.d.ts → client-DN38IP63.d.ts} +13 -5
- package/dist/comments.cjs +3 -2
- package/dist/comments.js +3 -2
- package/dist/{embed-g7NT1CyB.d.ts → embed-BaLQbE_n.d.ts} +1 -1
- package/dist/{embed-XT0x_Jaa.d.cts → embed-BrrGgkgQ.d.cts} +1 -1
- package/dist/html.cjs +3 -2
- package/dist/html.js +2 -2
- package/dist/index.cjs +34 -16
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- package/dist/next.cjs +316 -184
- package/dist/next.d.cts +46 -31
- package/dist/next.d.ts +46 -31
- package/dist/next.js +265 -154
- package/dist/react.cjs +3 -2
- package/dist/react.d.cts +3 -3
- package/dist/react.d.ts +3 -3
- package/dist/react.js +3 -3
- package/dist/{resolve-CiZCPysX.d.cts → resolve-Ce_yz8gC.d.cts} +1 -1
- package/dist/{resolve-BqC9l5RH.d.ts → resolve-DMHbYyTS.d.ts} +1 -1
- package/dist/{types-b9QbmEDd.d.cts → types-CxE8kLeo.d.cts} +30 -5
- package/dist/{types-b9QbmEDd.d.ts → types-CxE8kLeo.d.ts} +30 -5
- package/dist/use-cache.cjs +34 -16
- 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/README.md
CHANGED
|
@@ -116,7 +116,7 @@ const html = hastToHtml(article.content.tree, { baseUrl: "https://example.com/bl
|
|
|
116
116
|
| `@tdacorp/hyle-sdk` | `createHyleClient` (typed `resolve`, `mounts`, `preview` and `asset`), `listPublicationPaths`, `checkRoutes` and the other route-check functions, `Cp1ClientError`, `verifyHyleSignature`, `parseSignatureHeader`, `isValidCacheTag`, `DeliveryDedupe`, `createRevalidationCallbackRoute`, `parseCommentEvent`, the result types | nothing (no framework) |
|
|
117
117
|
| `@tdacorp/hyle-sdk/react` | `ArticlePage`, `Comments`, `HyleReactions`, `ListPage`, `HyleListView`, `HyleArticleView`, `DocsPage`, `NotFound`, `Redirecting`, `Unavailable`, `HyleBody`, `HyleToc`, `HastContent`, `TrustedServerHtml`, `sanitizeHast` | react >= 19 |
|
|
118
118
|
| `@tdacorp/hyle-sdk/html` | `hastToHtml`, `HastLimitError` (server only) | nothing (no framework) |
|
|
119
|
-
| `@tdacorp/hyle-sdk/next` | `hylePage`, `hyleMetadata`, `hyleSitemap`, `hyleFeed`, `hyleRootPage`, `hyleRootMetadata`, `hyleRootSitemap`, `createMarkdownRoute`, `markdownRewritePath`, `createLlmsTxtRoute`, `createRevalidateRoute`, `createAssetRoute`, `createOgImageRoute`, `createEngagementRoute`, `hylePreviewPage`, `hylePreviewMetadata`, `
|
|
119
|
+
| `@tdacorp/hyle-sdk/next` | `hylePage`, `hyleMetadata`, `hyleSitemap`, `hyleFeed`, `hyleRootPage`, `hyleRootMetadata`, `hyleRootSitemap`, `createMarkdownRoute`, `markdownRewritePath`, `createLlmsTxtRoute`, `createRevalidateRoute`, `createAssetRoute`, `createOgImageRoute`, `createEngagementRoute`, `hylePreviewPage`, `hylePreviewMetadata`, `hyleProtectedMetadata`, `createProtectedUnlockRoute`, `hyleProtectedProxy`, `hyleProtectedPage`, `HyleList`, `HyleArticle`, `HyleComments`, `HyleCommentsFallback`, `fetchResolver`, `workspaceTags` | next >= 16 |
|
|
120
120
|
| `@tdacorp/hyle-sdk/next/use-cache` | `cachedResolver` | next >= 16 with `cacheComponents: true` |
|
|
121
121
|
| `@tdacorp/hyle-sdk/styles.css` | the stylesheet | |
|
|
122
122
|
|
|
@@ -425,36 +425,54 @@ The token is a bearer secret for that draft, together with your read credential,
|
|
|
425
425
|
- The token is in the page URL and the image URLs, so your access logs and the browser's history record it, and any script on the page can read it from `location.href`. Keep analytics, error reporting and other third-party scripts off this route, including ones your root layout adds to every page.
|
|
426
426
|
- Your proxy or middleware must let `/hyle-preview` through without a sign-in redirect that copies the URL elsewhere, and a catch-all must not claim it.
|
|
427
427
|
|
|
428
|
-
## Protected
|
|
428
|
+
## Protected shares
|
|
429
429
|
|
|
430
|
-
A protected
|
|
431
|
-
|
|
432
|
-
Two route files, ready made:
|
|
430
|
+
A protected share is a named group of documents that a visitor opens with a password (hyle ADR 0040). It is never published: it is in no list, sitemap, feed or search, and its pages are `noindex`. The share is reachable at a slug on your site, for example `/news/field-notes`, and `/news/field-notes/<doc>` for one of its documents. The proxy rewrite (below) is what serves a share; the unlock route is the one more file:
|
|
433
431
|
|
|
434
432
|
```ts
|
|
435
|
-
// app/
|
|
436
|
-
import {
|
|
433
|
+
// app/hyle-protected/unlock/route.ts
|
|
434
|
+
import { createProtectedUnlockRoute } from "@tdacorp/hyle-sdk/next";
|
|
437
435
|
|
|
438
|
-
export const
|
|
439
|
-
export default hyleProtectedPage({ baseUrl: process.env.HYLE_TARGET_BASE_URL!, token: process.env.HYLE_TARGET_TOKEN! });
|
|
436
|
+
export const { POST } = createProtectedUnlockRoute();
|
|
440
437
|
```
|
|
441
438
|
|
|
442
|
-
|
|
443
|
-
// app/p/[id]/unlock/route.ts
|
|
444
|
-
import { createProtectedUnlockRoute } from "@tdacorp/hyle-sdk/next";
|
|
439
|
+
`hyleRootPage` checks the slugs hyle reports in `GET /cp1/read/mounts` (`protected`) together with the mounts, so the longest entry wins (and a path under a live slug makes no resolve call), but **`hyleRootPage` never draws a share: a path under a live slug is `notFound()` there**, because a share is read with the visitor's cookie and the catch-all may be ISR, where reading a cookie is a 500. The proxy rewrite below is what serves a share, on every host, so a host without it shows its shares as 404. The longest entry wins, a share beating a mount only when it is longer, or equally long and of the same workspace config: one workspace's share never hides another workspace's mount. **A share hides everything under its slug** (`/<slug>` and `/<slug>/<doc>`), so a slug must not be a path or the parent of a path your host serves itself (`/learn` would take your own `/learn/notes`). hyle refuses a slug at, above or under a reserved path (`reserved_paths`, and the routes `hyle-sdk-check-routes --sync` sends as `host_reserved_paths`); a host route that was never synced is yours to keep out of share slugs. Without a cookie the page shows a password form (labelled, `autocomplete="off"`, the error announced) under a generic "Password required" heading. hyle's gate reply carries no share name, so a slug reveals only that a share exists. The form posts `slug` and `password` to `/hyle-protected/unlock`. The unlock route checks that the POST is same-origin and that its form body is at most 1 KiB, stores the password in an `HttpOnly`, `Secure`, `SameSite=Lax` cookie for 12 hours, scoped to `Path=/<slug>` and, for the share's images, to `Path=/api/hyle/assets` (never `Path=/`, so no other request of your host carries it), and redirects to `/<slug>`. It never calls hyle, so one view is one open. The page then asks hyle with `client.protected(slug, password, docSlug?)`: a wrong or expired password shows the form again with "Wrong or expired password". A good one draws one document as an article, or several as the docs layout with a sidebar that highlights the current document. The cookie is named `hyle_p_` and 16 characters of a hash of the slug, so one visitor can hold a password for each share.
|
|
445
440
|
|
|
446
|
-
|
|
441
|
+
The password must be 12 to 128 visible ASCII characters (no space, quote, comma, semicolon, percent sign or backslash), so it fits a cookie and a header unchanged. It is sent to hyle only in the `cp-protected` header, and a malformed slug or password is refused before anything is sent. The redirect target is built from the validated slug alone. Nothing is logged. Keep analytics off the protected paths: a page URL is shared with the person who holds the password.
|
|
442
|
+
|
|
443
|
+
Every answer that involves a protected share is `Cache-Control: no-store`, `X-Robots-Tag: noindex, nofollow` and `Referrer-Policy: no-referrer`. The unlock form is accepted by `Sec-Fetch-Site: same-origin` (whatever the `Origin`) or, when the browser does not send it, by `Origin` against the request's host, so a host that sets a global `Referrer-Policy: no-referrer` keeps working.
|
|
444
|
+
|
|
445
|
+
Images of a share go through `createAssetRoute` (`?hyle_protected=<slug>` reads the same cookie, and the route asks hyle for `?protected=<slug>` with the password in `cp-protected`). A basePath, or a locale-prefix middleware that rewrites or redirects the share paths, breaks it: leave the share slugs and `/hyle-protected/unlock` out of any basePath, locale or rewrite rule.
|
|
446
|
+
|
|
447
|
+
**A share needs two more files: a proxy and a view route.** A share is read with the visitor's cookie, and a page with `export const revalidate = 3600` or `generateStaticParams` cannot read a cookie at request time: Next answers 500 (`DYNAMIC_SERVER_USAGE`, measured on Next 16.5). So a share is drawn by a dynamic route that the host's proxy rewrites to, so the share URL does not change and the other pages stay cached:
|
|
448
|
+
|
|
449
|
+
```ts
|
|
450
|
+
// proxy.ts (Next 16; middleware.ts on older versions). Keep your own matcher, and leave /_next, /api and /hyle-protected out of it.
|
|
451
|
+
import { NextResponse, type NextRequest } from "next/server";
|
|
452
|
+
import { hyleProtectedProxy } from "@tdacorp/hyle-sdk/next";
|
|
453
|
+
import { configs } from "./hyle-configs"; // the array you pass to hyleRootPage
|
|
454
|
+
|
|
455
|
+
const share = hyleProtectedProxy(configs);
|
|
456
|
+
export async function proxy(req: NextRequest) {
|
|
457
|
+
return (await share(req)) ?? NextResponse.next();
|
|
458
|
+
}
|
|
447
459
|
```
|
|
448
460
|
|
|
449
|
-
|
|
461
|
+
```tsx
|
|
462
|
+
// app/hyle-protected/view/[[...path]]/page.tsx
|
|
463
|
+
import { hyleProtectedMetadata, hyleProtectedPage } from "@tdacorp/hyle-sdk/next";
|
|
464
|
+
import { configs } from "../../../../hyle-configs";
|
|
450
465
|
|
|
451
|
-
|
|
466
|
+
export const dynamic = "force-dynamic";
|
|
467
|
+
export const metadata = hyleProtectedMetadata;
|
|
468
|
+
export default hyleProtectedPage(configs);
|
|
469
|
+
```
|
|
452
470
|
|
|
453
|
-
|
|
471
|
+
`hyleProtectedProxy` rewrites a path to `/hyle-protected/view/<path>` only when it is under a slug hyle lists as protected, and returns `undefined` for everything else. A proxy has no fetch cache, so it keeps one read of hyle's mounts per config in memory and matches every path against it locally, so random paths cost no call to hyle. It is stale-while-revalidate: once it has a copy it answers from it at once, and after 30 seconds ONE read refreshes it in the background (a failed refresh keeps the copy), so a slow hyle delays no request; a new share is rewritten within about 30 seconds. Only a cold start (no copy yet) waits, for at most `lookupTimeoutMs` (`hyleProtectedProxy(configs, { lookupTimeoutMs })`, default 1500), after which the request goes on as a normal, non-share request while the read finishes; a mounts read that fails with no copy counts as "not a share" for those 30 seconds. Without the proxy a share path reaches the catch-all, which answers 404.
|
|
454
472
|
|
|
455
|
-
The
|
|
473
|
+
The view route reads the visitor's address from the first `x-forwarded-for` hop, else `x-real-ip`, and sends it to hyle as `X-Forwarded-For` with the gate and open reads (`hyleProtectedPage(configs, { clientIp: (headers) => ... })` reads it from elsewhere; a value that is not an IPv4 or IPv6 literal is dropped). The first hop is the visitor's only when your edge overwrites that header. hyle's site read surface does not use it yet. When hyle answers 429 (too many attempts), the view draws a page headed "Too many attempts, try again later" with the seconds to wait taken from `Retry-After`; an App Router page cannot set a status or header, so it is drawn with status 200. `client.protected(slug, password, docSlug?, { clientIp })` and `client.protectedGate(slug, { clientIp })` return `{ kind: "limited", retryAfterSeconds }` for a 429.
|
|
456
474
|
|
|
457
|
-
Requires a Hyle with migration
|
|
475
|
+
Requires a Hyle with migration 0111 and the `GET /cp1/read/_protected` and `GET /cp1/read/_protected/gate` routes (ADR 0040).
|
|
458
476
|
|
|
459
477
|
## Comments, votes and reactions
|
|
460
478
|
|
package/dist/check-routes-bin.js
CHANGED
|
@@ -16,9 +16,11 @@ var PREVIEW_PARAM = "hyle_preview";
|
|
|
16
16
|
var PREVIEW_QUERY_SOURCE = `\\?${PREVIEW_PARAM}=${PREVIEW_TOKEN_SOURCE}`;
|
|
17
17
|
var PROTECTED_PARAM = "hyle_protected";
|
|
18
18
|
var PROTECTED_HEADER = "cp-protected";
|
|
19
|
-
var
|
|
20
|
-
var
|
|
21
|
-
var
|
|
19
|
+
var SHARE_SLUG = "[a-z0-9-]+(?:/[a-z0-9-]+){0,3}";
|
|
20
|
+
var PROTECTED_SLUG = new RegExp(`^${SHARE_SLUG}$`);
|
|
21
|
+
var PROTECTED_DOC_SLUG = /^[a-z0-9-]+$/;
|
|
22
|
+
var PROTECTED_PASSWORD = /^[\x21\x23-\x24\x26-\x2B\x2D-\x3A\x3C-\x5B\x5D-\x7E]{12,128}$/;
|
|
23
|
+
var PROTECTED_QUERY_SOURCE = `\\?${PROTECTED_PARAM}=${SHARE_SLUG}`;
|
|
22
24
|
var HYLE_ASSET_URL = new RegExp(`^/assets/(${UUID}(?:\\.(?:${EXTENSIONS}))?)(${PREVIEW_QUERY_SOURCE}|${PROTECTED_QUERY_SOURCE})?$`, "i");
|
|
23
25
|
|
|
24
26
|
// src/errors.ts
|
|
@@ -74,6 +76,8 @@ function applyCredential(headers, credential, method, url) {
|
|
|
74
76
|
headers.set("cp-workspace", workspaceId);
|
|
75
77
|
});
|
|
76
78
|
}
|
|
79
|
+
var IP_LITERAL = /^[0-9a-fA-F:.]{2,45}$/;
|
|
80
|
+
var visitorHeaders = ({ clientIp }) => clientIp !== void 0 && IP_LITERAL.test(clientIp) ? { "x-forwarded-for": clientIp } : {};
|
|
77
81
|
var DEFAULT_TIMEOUT_MS = 1e4;
|
|
78
82
|
var DEFAULT_MAX_RESPONSE_BYTES = 5 * 1024 * 1024;
|
|
79
83
|
var LOOPBACK = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "[::1]"]);
|
|
@@ -100,7 +104,7 @@ var KINDS = /* @__PURE__ */ new Set(["article", "list", "redirect", "notfound",
|
|
|
100
104
|
var isStrings = (value) => Array.isArray(value) && value.every((v) => typeof v === "string");
|
|
101
105
|
function isMounts(data) {
|
|
102
106
|
const mounts = data.mounts;
|
|
103
|
-
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");
|
|
107
|
+
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));
|
|
104
108
|
}
|
|
105
109
|
function checkBaseUrl(baseUrl, allowInsecureHttp) {
|
|
106
110
|
let origin;
|
|
@@ -135,7 +139,7 @@ function createHyleClient(options) {
|
|
|
135
139
|
} catch {
|
|
136
140
|
parsed = void 0;
|
|
137
141
|
}
|
|
138
|
-
return { parsed, status: res.status };
|
|
142
|
+
return { parsed, status: res.status, retryAfter: res.headers.get("retry-after") };
|
|
139
143
|
}
|
|
140
144
|
const failure = ({ parsed, status }) => {
|
|
141
145
|
const err = parsed?.error;
|
|
@@ -183,22 +187,38 @@ function createHyleClient(options) {
|
|
|
183
187
|
if (data?.cp !== 1 || data.kind !== "preview" || typeof data.expires_at !== "string" || article?.kind !== "article" || article.content?.format !== "hast" || !article.publication) throw failure(reply);
|
|
184
188
|
return { kind: "preview", expires_at: data.expires_at, article: withAssetQuery(article, `${PREVIEW_PARAM}=${token}`) };
|
|
185
189
|
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
190
|
+
const limited = ({ retryAfter }) => ({ kind: "limited", retryAfterSeconds: Math.min(3600, Math.max(1, Math.trunc(Number(retryAfter)) || 60)) });
|
|
191
|
+
async function protectedGate(slug, opts = {}) {
|
|
192
|
+
if (!PROTECTED_SLUG.test(slug)) return { kind: "notfound" };
|
|
193
|
+
const reply = await get("/cp1/read/_protected/gate", new URLSearchParams({ path: slug }), { headers: visitorHeaders(opts), cache: "no-store" });
|
|
194
|
+
if (reply.status === 429) return limited(reply);
|
|
195
|
+
if (reply.status === 404 && reply.parsed?.error?.code === "NOT_FOUND") return { kind: "notfound" };
|
|
196
|
+
const data = reply.parsed?.data;
|
|
197
|
+
if (data?.cp === 1 && data.kind === "disabled") return { kind: "disabled" };
|
|
198
|
+
if (data?.cp === 1 && data.kind === "gate") return { kind: "gate" };
|
|
199
|
+
throw failure(reply);
|
|
200
|
+
}
|
|
201
|
+
async function protectedShare(slug, password, docSlug, opts = {}) {
|
|
202
|
+
if (!PROTECTED_SLUG.test(slug) || docSlug !== void 0 && !PROTECTED_DOC_SLUG.test(docSlug) || !PROTECTED_PASSWORD.test(password)) return { kind: "notfound" };
|
|
203
|
+
const path = docSlug === void 0 ? slug : `${slug}/${docSlug}`;
|
|
204
|
+
const reply = await get("/cp1/read/_protected", new URLSearchParams({ path }), { headers: { ...visitorHeaders(opts), [PROTECTED_HEADER]: password }, cache: "no-store" });
|
|
205
|
+
if (reply.status === 429) return limited(reply);
|
|
189
206
|
if (reply.status === 404 && reply.parsed?.error?.code === "NOT_FOUND") return { kind: "notfound" };
|
|
190
207
|
const data = reply.parsed?.data;
|
|
191
208
|
if (data?.cp === 1 && data.kind === "disabled") return { kind: "disabled" };
|
|
192
209
|
const article = data?.article;
|
|
193
|
-
const expires = data
|
|
194
|
-
if (data?.cp !== 1 || data.kind !== "protected" || typeof expires !== "string" && expires !== null || article?.kind !== "article" || article.content?.format !== "hast" || !article.publication) throw failure(reply);
|
|
195
|
-
return { kind: "protected", expires_at: expires, article: withAssetQuery(article, `${PROTECTED_PARAM}=${
|
|
210
|
+
const { name, expires_at: expires, documents, doc_slug: current } = data ?? {};
|
|
211
|
+
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(reply);
|
|
212
|
+
return { cp: 1, kind: "protected", name, expires_at: expires, documents, doc_slug: current, article: withAssetQuery(article, `${PROTECTED_PARAM}=${slug}`) };
|
|
196
213
|
}
|
|
197
214
|
async function asset(file, opts = {}) {
|
|
198
215
|
if (!ASSET_FILE.test(file)) throw new TypeError("asset file must be <uuid>[.<ext>]");
|
|
199
216
|
const { previewToken } = opts;
|
|
200
217
|
if (previewToken !== void 0 && !PREVIEW_TOKEN.test(previewToken)) throw new TypeError("previewToken is not a preview token");
|
|
201
|
-
const
|
|
218
|
+
const { protectedAccess } = opts;
|
|
219
|
+
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");
|
|
220
|
+
const query = protectedAccess === void 0 ? "" : `?protected=${encodeURIComponent(protectedAccess.slug)}`;
|
|
221
|
+
const url = `${base}/cp1/read/assets/${file}${query}`;
|
|
202
222
|
const headers = new Headers();
|
|
203
223
|
const applied = applyCredential(headers, options, "GET", url);
|
|
204
224
|
if (applied) await applied;
|
|
@@ -206,10 +226,8 @@ function createHyleClient(options) {
|
|
|
206
226
|
const value = opts.headers?.[name];
|
|
207
227
|
if (value) headers.set(name, value);
|
|
208
228
|
}
|
|
209
|
-
const { protectedAccess } = opts;
|
|
210
|
-
if (protectedAccess !== void 0 && !(PROTECTED_ID.test(protectedAccess.pageId) && PROTECTED_PASSWORD.test(protectedAccess.password))) throw new TypeError("protectedAccess is not a page id and password");
|
|
211
229
|
if (previewToken !== void 0) headers.set(PREVIEW_HEADER, previewToken);
|
|
212
|
-
if (protectedAccess !== void 0) headers.set(PROTECTED_HEADER,
|
|
230
|
+
if (protectedAccess !== void 0) headers.set(PROTECTED_HEADER, protectedAccess.password);
|
|
213
231
|
const uncached = previewToken !== void 0 || protectedAccess !== void 0;
|
|
214
232
|
return fetchImpl(url, { method: "GET", headers, redirect: "error", signal: AbortSignal.timeout(opts.timeoutMs ?? options.timeoutMs ?? DEFAULT_TIMEOUT_MS), ...uncached ? { cache: "no-store" } : {} });
|
|
215
233
|
}
|
|
@@ -220,7 +238,7 @@ function createHyleClient(options) {
|
|
|
220
238
|
if (applied) await applied;
|
|
221
239
|
return fetchImpl(url, { method: "GET", headers, redirect: "error", signal: AbortSignal.timeout(opts.timeoutMs ?? options.timeoutMs ?? DEFAULT_TIMEOUT_MS) });
|
|
222
240
|
}
|
|
223
|
-
return { resolve, mounts, pushPosts, preview, protected:
|
|
241
|
+
return { resolve, mounts, pushPosts, preview, protectedGate, protected: protectedShare, asset, theme };
|
|
224
242
|
}
|
|
225
243
|
|
|
226
244
|
// src/host-sync.ts
|
|
@@ -9,12 +9,12 @@ import {
|
|
|
9
9
|
scopeId,
|
|
10
10
|
stringsFor,
|
|
11
11
|
youtubeId
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-Y3BACEWA.js";
|
|
13
13
|
import {
|
|
14
14
|
hostAssetHtml,
|
|
15
15
|
themeFontHrefs,
|
|
16
16
|
themeStylesheetHref
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-BDFMNY76.js";
|
|
18
18
|
|
|
19
19
|
// src/react/content.tsx
|
|
20
20
|
import { toJsxRuntime } from "hast-util-to-jsx-runtime";
|
|
@@ -20,10 +20,15 @@ var PREVIEW_PARAM = "hyle_preview";
|
|
|
20
20
|
var PREVIEW_QUERY_SOURCE = `\\?${PREVIEW_PARAM}=${PREVIEW_TOKEN_SOURCE}`;
|
|
21
21
|
var PROTECTED_PARAM = "hyle_protected";
|
|
22
22
|
var PROTECTED_HEADER = "cp-protected";
|
|
23
|
-
var
|
|
24
|
-
var
|
|
25
|
-
var
|
|
26
|
-
var
|
|
23
|
+
var SHARE_SLUG = "[a-z0-9-]+(?:/[a-z0-9-]+){0,3}";
|
|
24
|
+
var PROTECTED_SLUG = new RegExp(`^${SHARE_SLUG}$`);
|
|
25
|
+
var PROTECTED_DOC_SLUG = /^[a-z0-9-]+$/;
|
|
26
|
+
var PROTECTED_PASSWORD = /^[\x21\x23-\x24\x26-\x2B\x2D-\x3A\x3C-\x5B\x5D-\x7E]{12,128}$/;
|
|
27
|
+
async function protectedCookieName(slug) {
|
|
28
|
+
const digest = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(slug));
|
|
29
|
+
return `hyle_p_${Buffer.from(digest).toString("base64url").slice(0, 16)}`;
|
|
30
|
+
}
|
|
31
|
+
var PROTECTED_QUERY_SOURCE = `\\?${PROTECTED_PARAM}=${SHARE_SLUG}`;
|
|
27
32
|
var HYLE_ASSET_URL = new RegExp(`^/assets/(${UUID}(?:\\.(?:${EXTENSIONS}))?)(${PREVIEW_QUERY_SOURCE}|${PROTECTED_QUERY_SOURCE})?$`, "i");
|
|
28
33
|
function hostAssetSrc(src) {
|
|
29
34
|
const [, file, query = ""] = HYLE_ASSET_URL.exec(src) ?? [];
|
|
@@ -59,7 +64,8 @@ export {
|
|
|
59
64
|
PREVIEW_QUERY_SOURCE,
|
|
60
65
|
PROTECTED_PARAM,
|
|
61
66
|
PROTECTED_HEADER,
|
|
62
|
-
|
|
67
|
+
PROTECTED_SLUG,
|
|
68
|
+
PROTECTED_DOC_SLUG,
|
|
63
69
|
PROTECTED_PASSWORD,
|
|
64
70
|
protectedCookieName,
|
|
65
71
|
hostAssetSrc,
|
|
@@ -5,11 +5,12 @@ import {
|
|
|
5
5
|
PREVIEW_HEADER,
|
|
6
6
|
PREVIEW_PARAM,
|
|
7
7
|
PREVIEW_TOKEN,
|
|
8
|
+
PROTECTED_DOC_SLUG,
|
|
8
9
|
PROTECTED_HEADER,
|
|
9
|
-
PROTECTED_ID,
|
|
10
10
|
PROTECTED_PARAM,
|
|
11
|
-
PROTECTED_PASSWORD
|
|
12
|
-
|
|
11
|
+
PROTECTED_PASSWORD,
|
|
12
|
+
PROTECTED_SLUG
|
|
13
|
+
} from "./chunk-BDFMNY76.js";
|
|
13
14
|
|
|
14
15
|
// src/errors.ts
|
|
15
16
|
var Cp1ClientError = class extends Error {
|
|
@@ -64,6 +65,8 @@ function applyCredential(headers, credential, method, url) {
|
|
|
64
65
|
headers.set("cp-workspace", workspaceId);
|
|
65
66
|
});
|
|
66
67
|
}
|
|
68
|
+
var IP_LITERAL = /^[0-9a-fA-F:.]{2,45}$/;
|
|
69
|
+
var visitorHeaders = ({ clientIp }) => clientIp !== void 0 && IP_LITERAL.test(clientIp) ? { "x-forwarded-for": clientIp } : {};
|
|
67
70
|
var DEFAULT_TIMEOUT_MS = 1e4;
|
|
68
71
|
var DEFAULT_MAX_RESPONSE_BYTES = 5 * 1024 * 1024;
|
|
69
72
|
var LOOPBACK = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "[::1]"]);
|
|
@@ -101,7 +104,7 @@ var KINDS = /* @__PURE__ */ new Set(["article", "list", "redirect", "notfound",
|
|
|
101
104
|
var isStrings = (value) => Array.isArray(value) && value.every((v) => typeof v === "string");
|
|
102
105
|
function isMounts(data) {
|
|
103
106
|
const mounts = data.mounts;
|
|
104
|
-
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");
|
|
107
|
+
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));
|
|
105
108
|
}
|
|
106
109
|
function checkBaseUrl(baseUrl, allowInsecureHttp) {
|
|
107
110
|
let origin;
|
|
@@ -136,7 +139,7 @@ function createHyleClient(options) {
|
|
|
136
139
|
} catch {
|
|
137
140
|
parsed = void 0;
|
|
138
141
|
}
|
|
139
|
-
return { parsed, status: res.status };
|
|
142
|
+
return { parsed, status: res.status, retryAfter: res.headers.get("retry-after") };
|
|
140
143
|
}
|
|
141
144
|
const failure = ({ parsed, status }) => {
|
|
142
145
|
const err = parsed?.error;
|
|
@@ -184,22 +187,38 @@ function createHyleClient(options) {
|
|
|
184
187
|
if (data?.cp !== 1 || data.kind !== "preview" || typeof data.expires_at !== "string" || article?.kind !== "article" || article.content?.format !== "hast" || !article.publication) throw failure(reply);
|
|
185
188
|
return { kind: "preview", expires_at: data.expires_at, article: withAssetQuery(article, `${PREVIEW_PARAM}=${token}`) };
|
|
186
189
|
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
+
const limited = ({ retryAfter }) => ({ kind: "limited", retryAfterSeconds: Math.min(3600, Math.max(1, Math.trunc(Number(retryAfter)) || 60)) });
|
|
191
|
+
async function protectedGate(slug, opts = {}) {
|
|
192
|
+
if (!PROTECTED_SLUG.test(slug)) return { kind: "notfound" };
|
|
193
|
+
const reply = await get("/cp1/read/_protected/gate", new URLSearchParams({ path: slug }), { headers: visitorHeaders(opts), cache: "no-store" });
|
|
194
|
+
if (reply.status === 429) return limited(reply);
|
|
195
|
+
if (reply.status === 404 && reply.parsed?.error?.code === "NOT_FOUND") return { kind: "notfound" };
|
|
196
|
+
const data = reply.parsed?.data;
|
|
197
|
+
if (data?.cp === 1 && data.kind === "disabled") return { kind: "disabled" };
|
|
198
|
+
if (data?.cp === 1 && data.kind === "gate") return { kind: "gate" };
|
|
199
|
+
throw failure(reply);
|
|
200
|
+
}
|
|
201
|
+
async function protectedShare(slug, password, docSlug, opts = {}) {
|
|
202
|
+
if (!PROTECTED_SLUG.test(slug) || docSlug !== void 0 && !PROTECTED_DOC_SLUG.test(docSlug) || !PROTECTED_PASSWORD.test(password)) return { kind: "notfound" };
|
|
203
|
+
const path = docSlug === void 0 ? slug : `${slug}/${docSlug}`;
|
|
204
|
+
const reply = await get("/cp1/read/_protected", new URLSearchParams({ path }), { headers: { ...visitorHeaders(opts), [PROTECTED_HEADER]: password }, cache: "no-store" });
|
|
205
|
+
if (reply.status === 429) return limited(reply);
|
|
190
206
|
if (reply.status === 404 && reply.parsed?.error?.code === "NOT_FOUND") return { kind: "notfound" };
|
|
191
207
|
const data = reply.parsed?.data;
|
|
192
208
|
if (data?.cp === 1 && data.kind === "disabled") return { kind: "disabled" };
|
|
193
209
|
const article = data?.article;
|
|
194
|
-
const expires = data
|
|
195
|
-
if (data?.cp !== 1 || data.kind !== "protected" || typeof expires !== "string" && expires !== null || article?.kind !== "article" || article.content?.format !== "hast" || !article.publication) throw failure(reply);
|
|
196
|
-
return { kind: "protected", expires_at: expires, article: withAssetQuery(article, `${PROTECTED_PARAM}=${
|
|
210
|
+
const { name, expires_at: expires, documents, doc_slug: current } = data ?? {};
|
|
211
|
+
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(reply);
|
|
212
|
+
return { cp: 1, kind: "protected", name, expires_at: expires, documents, doc_slug: current, article: withAssetQuery(article, `${PROTECTED_PARAM}=${slug}`) };
|
|
197
213
|
}
|
|
198
214
|
async function asset(file, opts = {}) {
|
|
199
215
|
if (!ASSET_FILE.test(file)) throw new TypeError("asset file must be <uuid>[.<ext>]");
|
|
200
216
|
const { previewToken } = opts;
|
|
201
217
|
if (previewToken !== void 0 && !PREVIEW_TOKEN.test(previewToken)) throw new TypeError("previewToken is not a preview token");
|
|
202
|
-
const
|
|
218
|
+
const { protectedAccess } = opts;
|
|
219
|
+
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");
|
|
220
|
+
const query = protectedAccess === void 0 ? "" : `?protected=${encodeURIComponent(protectedAccess.slug)}`;
|
|
221
|
+
const url = `${base}/cp1/read/assets/${file}${query}`;
|
|
203
222
|
const headers = new Headers();
|
|
204
223
|
const applied = applyCredential(headers, options, "GET", url);
|
|
205
224
|
if (applied) await applied;
|
|
@@ -207,10 +226,8 @@ function createHyleClient(options) {
|
|
|
207
226
|
const value = opts.headers?.[name];
|
|
208
227
|
if (value) headers.set(name, value);
|
|
209
228
|
}
|
|
210
|
-
const { protectedAccess } = opts;
|
|
211
|
-
if (protectedAccess !== void 0 && !(PROTECTED_ID.test(protectedAccess.pageId) && PROTECTED_PASSWORD.test(protectedAccess.password))) throw new TypeError("protectedAccess is not a page id and password");
|
|
212
229
|
if (previewToken !== void 0) headers.set(PREVIEW_HEADER, previewToken);
|
|
213
|
-
if (protectedAccess !== void 0) headers.set(PROTECTED_HEADER,
|
|
230
|
+
if (protectedAccess !== void 0) headers.set(PROTECTED_HEADER, protectedAccess.password);
|
|
214
231
|
const uncached = previewToken !== void 0 || protectedAccess !== void 0;
|
|
215
232
|
return fetchImpl(url, { method: "GET", headers, redirect: "error", signal: AbortSignal.timeout(opts.timeoutMs ?? options.timeoutMs ?? DEFAULT_TIMEOUT_MS), ...uncached ? { cache: "no-store" } : {} });
|
|
216
233
|
}
|
|
@@ -221,7 +238,7 @@ function createHyleClient(options) {
|
|
|
221
238
|
if (applied) await applied;
|
|
222
239
|
return fetchImpl(url, { method: "GET", headers, redirect: "error", signal: AbortSignal.timeout(opts.timeoutMs ?? options.timeoutMs ?? DEFAULT_TIMEOUT_MS) });
|
|
223
240
|
}
|
|
224
|
-
return { resolve, mounts, pushPosts, preview, protected:
|
|
241
|
+
return { resolve, mounts, pushPosts, preview, protectedGate, protected: protectedShare, asset, theme };
|
|
225
242
|
}
|
|
226
243
|
|
|
227
244
|
// src/host-sync.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { m as Resolved, i as MountsResult, H as HylePreview, e as HyleProtectedGate, d as HyleProtected } from './types-CxE8kLeo.cjs';
|
|
2
2
|
|
|
3
3
|
/** docs/cp1-spec.md section 5.3.3: `hyle.push/1`, the whole-post delivery of a path in push mode (ADR 0025). */
|
|
4
4
|
declare const MAX_PUSH_BODY_BYTES: number;
|
|
@@ -187,12 +187,19 @@ interface AssetOptions {
|
|
|
187
187
|
readonly timeoutMs?: number;
|
|
188
188
|
/** A draft preview's token (hyle ADR 0037): hyle then also serves the assets that draft names. The answer is never cached. */
|
|
189
189
|
readonly previewToken?: string;
|
|
190
|
-
/** A protected
|
|
190
|
+
/** A protected share's slug and password (hyle ADR 0040): hyle then also serves that share's assets. The answer is never cached. */
|
|
191
191
|
readonly protectedAccess?: {
|
|
192
|
-
readonly
|
|
192
|
+
readonly slug: string;
|
|
193
193
|
readonly password: string;
|
|
194
194
|
};
|
|
195
195
|
}
|
|
196
|
+
interface ProtectedReadOptions {
|
|
197
|
+
/**
|
|
198
|
+
* The visitor's address, sent to hyle as `X-Forwarded-For` so a read made for a visitor is attributable to them. Anything that is
|
|
199
|
+
* not an IPv4 or IPv6 literal is dropped. hyle's site read surface does not read it today (docs/cp1-spec.md section 3.10.3).
|
|
200
|
+
*/
|
|
201
|
+
readonly clientIp?: string | undefined;
|
|
202
|
+
}
|
|
196
203
|
declare function createHyleClient(options: HyleClientOptions): {
|
|
197
204
|
resolve: (opts: ResolveOptions) => Promise<Resolved>;
|
|
198
205
|
mounts: (opts?: MountsOptions) => Promise<MountsResult>;
|
|
@@ -202,7 +209,8 @@ declare function createHyleClient(options: HyleClientOptions): {
|
|
|
202
209
|
readonly init?: HyleRequestInit;
|
|
203
210
|
}) => Promise<PushPage>;
|
|
204
211
|
preview: (token: string | undefined) => Promise<HylePreview>;
|
|
205
|
-
|
|
212
|
+
protectedGate: (slug: string, opts?: ProtectedReadOptions) => Promise<HyleProtectedGate>;
|
|
213
|
+
protected: (slug: string, password: string, docSlug?: string, opts?: ProtectedReadOptions) => Promise<HyleProtected>;
|
|
206
214
|
asset: (file: string, opts?: AssetOptions) => Promise<Response>;
|
|
207
215
|
theme: (opts?: {
|
|
208
216
|
readonly timeoutMs?: number;
|
|
@@ -210,4 +218,4 @@ declare function createHyleClient(options: HyleClientOptions): {
|
|
|
210
218
|
};
|
|
211
219
|
type HyleClient = ReturnType<typeof createHyleClient>;
|
|
212
220
|
|
|
213
|
-
export { type AssetOptions as A, type HyleAuth as H, MAX_PUSH_BODY_BYTES as M, type
|
|
221
|
+
export { type AssetOptions as A, type HyleAuth as H, MAX_PUSH_BODY_BYTES as M, type ProtectedReadOptions as P, type ResolveOptions as R, type HyleClient as a, type HyleClientOptions as b, type HyleCredential as c, type HyleRequestInit as d, type MountsOptions as e, type PushEvent as f, type PushEventType as g, type PushPage as h, type PushPost as i, type PushRoute as j, type PushRouteOptions as k, type PushStore as l, type ResyncOptions as m, type ResyncResult as n, createHyleClient as o, createPushRoute as p, resyncPath as r, staleAfterResync as s };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { m as Resolved, i as MountsResult, H as HylePreview, e as HyleProtectedGate, d as HyleProtected } from './types-CxE8kLeo.js';
|
|
2
2
|
|
|
3
3
|
/** docs/cp1-spec.md section 5.3.3: `hyle.push/1`, the whole-post delivery of a path in push mode (ADR 0025). */
|
|
4
4
|
declare const MAX_PUSH_BODY_BYTES: number;
|
|
@@ -187,12 +187,19 @@ interface AssetOptions {
|
|
|
187
187
|
readonly timeoutMs?: number;
|
|
188
188
|
/** A draft preview's token (hyle ADR 0037): hyle then also serves the assets that draft names. The answer is never cached. */
|
|
189
189
|
readonly previewToken?: string;
|
|
190
|
-
/** A protected
|
|
190
|
+
/** A protected share's slug and password (hyle ADR 0040): hyle then also serves that share's assets. The answer is never cached. */
|
|
191
191
|
readonly protectedAccess?: {
|
|
192
|
-
readonly
|
|
192
|
+
readonly slug: string;
|
|
193
193
|
readonly password: string;
|
|
194
194
|
};
|
|
195
195
|
}
|
|
196
|
+
interface ProtectedReadOptions {
|
|
197
|
+
/**
|
|
198
|
+
* The visitor's address, sent to hyle as `X-Forwarded-For` so a read made for a visitor is attributable to them. Anything that is
|
|
199
|
+
* not an IPv4 or IPv6 literal is dropped. hyle's site read surface does not read it today (docs/cp1-spec.md section 3.10.3).
|
|
200
|
+
*/
|
|
201
|
+
readonly clientIp?: string | undefined;
|
|
202
|
+
}
|
|
196
203
|
declare function createHyleClient(options: HyleClientOptions): {
|
|
197
204
|
resolve: (opts: ResolveOptions) => Promise<Resolved>;
|
|
198
205
|
mounts: (opts?: MountsOptions) => Promise<MountsResult>;
|
|
@@ -202,7 +209,8 @@ declare function createHyleClient(options: HyleClientOptions): {
|
|
|
202
209
|
readonly init?: HyleRequestInit;
|
|
203
210
|
}) => Promise<PushPage>;
|
|
204
211
|
preview: (token: string | undefined) => Promise<HylePreview>;
|
|
205
|
-
|
|
212
|
+
protectedGate: (slug: string, opts?: ProtectedReadOptions) => Promise<HyleProtectedGate>;
|
|
213
|
+
protected: (slug: string, password: string, docSlug?: string, opts?: ProtectedReadOptions) => Promise<HyleProtected>;
|
|
206
214
|
asset: (file: string, opts?: AssetOptions) => Promise<Response>;
|
|
207
215
|
theme: (opts?: {
|
|
208
216
|
readonly timeoutMs?: number;
|
|
@@ -210,4 +218,4 @@ declare function createHyleClient(options: HyleClientOptions): {
|
|
|
210
218
|
};
|
|
211
219
|
type HyleClient = ReturnType<typeof createHyleClient>;
|
|
212
220
|
|
|
213
|
-
export { type AssetOptions as A, type HyleAuth as H, MAX_PUSH_BODY_BYTES as M, type
|
|
221
|
+
export { type AssetOptions as A, type HyleAuth as H, MAX_PUSH_BODY_BYTES as M, type ProtectedReadOptions as P, type ResolveOptions as R, type HyleClient as a, type HyleClientOptions as b, type HyleCredential as c, type HyleRequestInit as d, type MountsOptions as e, type PushEvent as f, type PushEventType as g, type PushPage as h, type PushPost as i, type PushRoute as j, type PushRouteOptions as k, type PushStore as l, type ResyncOptions as m, type ResyncResult as n, createHyleClient as o, createPushRoute as p, resyncPath as r, staleAfterResync as s };
|
package/dist/comments.cjs
CHANGED
|
@@ -370,8 +370,9 @@ var PREVIEW_TOKEN = new RegExp(`^${PREVIEW_TOKEN_SOURCE}$`);
|
|
|
370
370
|
var PREVIEW_PARAM = "hyle_preview";
|
|
371
371
|
var PREVIEW_QUERY_SOURCE = `\\?${PREVIEW_PARAM}=${PREVIEW_TOKEN_SOURCE}`;
|
|
372
372
|
var PROTECTED_PARAM = "hyle_protected";
|
|
373
|
-
var
|
|
374
|
-
var
|
|
373
|
+
var SHARE_SLUG = "[a-z0-9-]+(?:/[a-z0-9-]+){0,3}";
|
|
374
|
+
var PROTECTED_SLUG = new RegExp(`^${SHARE_SLUG}$`);
|
|
375
|
+
var PROTECTED_QUERY_SOURCE = `\\?${PROTECTED_PARAM}=${SHARE_SLUG}`;
|
|
375
376
|
var HYLE_ASSET_URL = new RegExp(`^/assets/(${UUID}(?:\\.(?:${EXTENSIONS}))?)(${PREVIEW_QUERY_SOURCE}|${PROTECTED_QUERY_SOURCE})?$`, "i");
|
|
376
377
|
function hostAssetSrc(src) {
|
|
377
378
|
const [, file, query = ""] = HYLE_ASSET_URL.exec(src) ?? [];
|
package/dist/comments.js
CHANGED
|
@@ -126,8 +126,9 @@ var PREVIEW_TOKEN = new RegExp(`^${PREVIEW_TOKEN_SOURCE}$`);
|
|
|
126
126
|
var PREVIEW_PARAM = "hyle_preview";
|
|
127
127
|
var PREVIEW_QUERY_SOURCE = `\\?${PREVIEW_PARAM}=${PREVIEW_TOKEN_SOURCE}`;
|
|
128
128
|
var PROTECTED_PARAM = "hyle_protected";
|
|
129
|
-
var
|
|
130
|
-
var
|
|
129
|
+
var SHARE_SLUG = "[a-z0-9-]+(?:/[a-z0-9-]+){0,3}";
|
|
130
|
+
var PROTECTED_SLUG = new RegExp(`^${SHARE_SLUG}$`);
|
|
131
|
+
var PROTECTED_QUERY_SOURCE = `\\?${PROTECTED_PARAM}=${SHARE_SLUG}`;
|
|
131
132
|
var HYLE_ASSET_URL = new RegExp(`^/assets/(${UUID}(?:\\.(?:${EXTENSIONS}))?)(${PREVIEW_QUERY_SOURCE}|${PROTECTED_QUERY_SOURCE})?$`, "i");
|
|
132
133
|
function hostAssetSrc(src) {
|
|
133
134
|
const [, file, query = ""] = HYLE_ASSET_URL.exec(src) ?? [];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ElementType, ReactNode, ComponentType, ReactElement } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { n as ResolvedArticle, L as ListItem, T as ThemeRef } from './types-CxE8kLeo.js';
|
|
3
3
|
|
|
4
4
|
type CalloutKind = "note" | "tip" | "important" | "warning" | "caution";
|
|
5
5
|
interface LinkProps {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ElementType, ReactNode, ComponentType, ReactElement } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { n as ResolvedArticle, L as ListItem, T as ThemeRef } from './types-CxE8kLeo.cjs';
|
|
3
3
|
|
|
4
4
|
type CalloutKind = "note" | "tip" | "important" | "warning" | "caution";
|
|
5
5
|
interface LinkProps {
|
package/dist/html.cjs
CHANGED
|
@@ -37,8 +37,9 @@ var PREVIEW_TOKEN = new RegExp(`^${PREVIEW_TOKEN_SOURCE}$`);
|
|
|
37
37
|
var PREVIEW_PARAM = "hyle_preview";
|
|
38
38
|
var PREVIEW_QUERY_SOURCE = `\\?${PREVIEW_PARAM}=${PREVIEW_TOKEN_SOURCE}`;
|
|
39
39
|
var PROTECTED_PARAM = "hyle_protected";
|
|
40
|
-
var
|
|
41
|
-
var
|
|
40
|
+
var SHARE_SLUG = "[a-z0-9-]+(?:/[a-z0-9-]+){0,3}";
|
|
41
|
+
var PROTECTED_SLUG = new RegExp(`^${SHARE_SLUG}$`);
|
|
42
|
+
var PROTECTED_QUERY_SOURCE = `\\?${PROTECTED_PARAM}=${SHARE_SLUG}`;
|
|
42
43
|
var HYLE_ASSET_URL = new RegExp(`^/assets/(${UUID}(?:\\.(?:${EXTENSIONS}))?)(${PREVIEW_QUERY_SOURCE}|${PROTECTED_QUERY_SOURCE})?$`, "i");
|
|
43
44
|
function hostAssetSrc(src) {
|
|
44
45
|
const [, file, query = ""] = HYLE_ASSET_URL.exec(src) ?? [];
|
package/dist/html.js
CHANGED