@tdacorp/hyle-sdk 0.23.0 → 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.
Files changed (36) hide show
  1. package/README.md +35 -19
  2. package/dist/check-routes-bin.js +28 -15
  3. package/dist/{chunk-YHXE3TGS.js → chunk-4REU4HJI.js} +27 -15
  4. package/dist/{chunk-UFMKLCXS.js → chunk-5TKJH2XC.js} +2 -2
  5. package/dist/{chunk-VXARM37R.js → chunk-BDFMNY76.js} +11 -5
  6. package/dist/{chunk-VUML2UPD.js → chunk-SY2FMIRZ.js} +1 -1
  7. package/dist/{chunk-JHZJOJDC.js → chunk-Y3BACEWA.js} +1 -1
  8. package/dist/{client--ighAWaj.d.ts → client-BErei7cE.d.ts} +5 -4
  9. package/dist/{client-DK-S2580.d.cts → client-DrB2vcTi.d.cts} +5 -4
  10. package/dist/comments.cjs +3 -2
  11. package/dist/comments.js +3 -2
  12. package/dist/{embed-XT0x_Jaa.d.cts → embed-B7T--kTT.d.cts} +1 -1
  13. package/dist/{embed-g7NT1CyB.d.ts → embed-DavTgSU4.d.ts} +1 -1
  14. package/dist/html.cjs +3 -2
  15. package/dist/html.js +2 -2
  16. package/dist/index.cjs +28 -15
  17. package/dist/index.d.cts +3 -3
  18. package/dist/index.d.ts +3 -3
  19. package/dist/index.js +2 -2
  20. package/dist/next.cjs +233 -148
  21. package/dist/next.d.cts +36 -31
  22. package/dist/next.d.ts +36 -31
  23. package/dist/next.js +204 -135
  24. package/dist/react.cjs +3 -2
  25. package/dist/react.d.cts +3 -3
  26. package/dist/react.d.ts +3 -3
  27. package/dist/react.js +3 -3
  28. package/dist/{resolve-CiZCPysX.d.cts → resolve-03IVloXU.d.cts} +1 -1
  29. package/dist/{resolve-BqC9l5RH.d.ts → resolve-BseM68oy.d.ts} +1 -1
  30. package/dist/{types-b9QbmEDd.d.cts → types-Dx-fEiZd.d.cts} +25 -5
  31. package/dist/{types-b9QbmEDd.d.ts → types-Dx-fEiZd.d.ts} +25 -5
  32. package/dist/use-cache.cjs +28 -15
  33. package/dist/use-cache.d.cts +3 -3
  34. package/dist/use-cache.d.ts +3 -3
  35. package/dist/use-cache.js +3 -3
  36. package/package.json +1 -1
package/dist/next.d.cts CHANGED
@@ -1,12 +1,13 @@
1
1
  import { ReactElement } from 'react';
2
- import { A as ArticleRef, O as OgImage, J as JsonLdConfig, H as HyleComponents, a as HyleSlots, E as EngagementConfig, b as EmbedHeading } from './embed-XT0x_Jaa.cjs';
3
- export { c as HyleCommentsFallback } from './embed-XT0x_Jaa.cjs';
4
- import { F as FetchResolverOptions, H as HyleResolver } from './resolve-CiZCPysX.cjs';
5
- export { f as fetchResolver, w as workspaceTags } from './resolve-CiZCPysX.cjs';
2
+ import { A as ArticleRef, O as OgImage, J as JsonLdConfig, H as HyleComponents, a as HyleSlots, E as EngagementConfig, b as EmbedHeading } from './embed-B7T--kTT.cjs';
3
+ export { c as HyleCommentsFallback } from './embed-B7T--kTT.cjs';
4
+ import { F as FetchResolverOptions, H as HyleResolver } from './resolve-03IVloXU.cjs';
5
+ export { f as fetchResolver, w as workspaceTags } from './resolve-03IVloXU.cjs';
6
6
  import { MetadataRoute, ResolvingMetadata, Metadata } from 'next';
7
7
  import { R as RevalidationCallbackOptions, b as RevalidationCallbackRoute } from './revalidation-callback-BQl77tQR.cjs';
8
- import { c as HyleCredential } from './client-DK-S2580.cjs';
9
- import './types-b9QbmEDd.cjs';
8
+ import { c as HyleCredential } from './client-DrB2vcTi.cjs';
9
+ import { NextRequest, NextResponse } from 'next/server';
10
+ import './types-Dx-fEiZd.cjs';
10
11
 
11
12
  type RouteParams = Record<string, string | string[] | undefined>;
12
13
  interface CommonOptions {
@@ -387,7 +388,7 @@ interface AssetRoute {
387
388
  * header so that draft's assets load; every such answer is `no-store`. The token is never sent for the theme stylesheet,
388
389
  * which is the credential's own with or without it. No other query parameter is read.
389
390
  *
390
- * Protected page (hyle ADR 0039): `?hyle_protected=<pageId>` takes the password from that page's cookie (`hyle_p_<pageId>`, set by
391
+ * Protected share (hyle ADR 0040): `?hyle_protected=<slug>` takes the password from that share's cookie (`hyle_p_<hash of slug>`, set by
391
392
  * `createProtectedUnlockRoute`) and forwards it as the `cp-protected` header. A missing or malformed cookie is a 404 that reaches
392
393
  * nobody; every such answer is private and `no-store`, as a draft's is.
393
394
  */
@@ -539,34 +540,38 @@ declare const hylePreviewMetadata: Metadata;
539
540
  declare function hylePreviewPage(options: HylePreviewPageOptions): (props: PageProps) => Promise<ReactElement>;
540
541
 
541
542
  /**
542
- * `export const metadata = hyleProtectedMetadata`, next to `hyleProtectedPage`. The page also renders both tags itself. The
543
- * referrer is `same-origin`, not `no-referrer`: a no-referrer page sends `Origin: null` on its own form POST, which the unlock
544
- * route would refuse. The URL carries no secret.
543
+ * The `robots` and `referrer` of a protected share (hyle ADR 0040). The unlock form is same-origin by `Sec-Fetch-Site`, so
544
+ * `no-referrer` does not stop it. The URL carries no secret.
545
545
  */
546
546
  declare const hyleProtectedMetadata: Metadata;
547
547
  /**
548
- * The page behind a protected link (ADR 0039): `export default hyleProtectedPage({ baseUrl, token })` in `app/p/[id]/page.tsx`.
549
- * It reads the visitor's cookie for this page and asks hyle for it: no cookie shows the password form, a cookie hyle refuses
550
- * shows the form with "Wrong or expired password", and a good one draws the article as a published page does. A malformed id
551
- * or a switched-off surface is `notFound()`. The page reads cookies, so it is rendered per request and never cached.
552
- */
553
- declare function hyleProtectedPage(options: HylePreviewPageOptions): (props: {
554
- params: Promise<{
555
- id?: string;
556
- }>;
557
- }) => Promise<ReactElement>;
558
- /**
559
- * `export const { POST } = createProtectedUnlockRoute()` in `app/p/[id]/unlock/route.ts`. The form posts the password here; the
560
- * route sets it in the page's HttpOnly cookie and sends the visitor back to `/p/<id>`, where the page checks it with hyle. It
561
- * never calls hyle itself, so a view is one open. Only a same-origin POST with a form body of at most 1 KiB is read, and the
562
- * password is stored only if it has the password's shape. The redirect target is built from the validated page id alone.
548
+ * `export const { POST } = createProtectedUnlockRoute()` in `app/hyle-protected/unlock/route.ts` (ADR 0040). The password form
549
+ * posts `slug` and `password` here; the route sets the password in the share's HttpOnly cookie (scoped to `/<slug>` and to the asset route, so no other request of the host carries it) and sends the visitor to `/<slug>`,
550
+ * where the page checks it with hyle. It never calls hyle, so a view is one open. Only a same-origin POST with a form body of at
551
+ * most 1 KiB is read. The cookie is set only for a password of the right shape, and the redirect target is built from the
552
+ * validated slug alone.
563
553
  */
564
554
  declare function createProtectedUnlockRoute(): {
565
- POST: (req: Request, ctx: {
566
- params: Promise<{
567
- id?: string;
568
- }>;
569
- }) => Promise<Response>;
555
+ POST: (req: Request) => Promise<Response>;
570
556
  };
571
557
 
572
- export { type AssetRoute, type AssetRouteOptions, ENGAGE_CSRF_HEADER, type EngageReader, type EngagementRoute, type EngagementRouteOptions, FetchResolverOptions, HyleArticle, type HyleArticleProps, HyleComments, type HyleCommentsProps, type HyleFeedOptions, HyleList, type HyleListProps, type HyleNextOptions, type HylePreviewPageOptions, HyleResolver, type HyleRootConfig, type HyleRootSitemapOptions, type HyleSitemapOptions, type LlmsTxtOptions, MOUNTS_MAX_STALE_MS, type MarkdownRoute, type OgImageRoute, type PageProps, type RevalidateRouteOptions, type RouteParams, createAssetRoute, createEngagementRoute, createLlmsTxtRoute, createMarkdownRoute, createOgImageRoute, createProtectedUnlockRoute, createRevalidateRoute, hyleFeed, hyleFeedLink, hyleMetadata, hylePage, hylePreviewMetadata, hylePreviewPage, hyleProtectedMetadata, hyleProtectedPage, hyleRootMetadata, hyleRootPage, hyleRootSitemap, hyleSitemap, markdownRewritePath };
558
+ /**
559
+ * For a host whose catch-all is static or ISR (`revalidate`, `generateStaticParams`): reading the visitor's cookie there is a 500
560
+ * (`DYNAMIC_SERVER_USAGE`), so a share is drawn by a dynamic route instead. In the host's `proxy.ts`:
561
+ * `const share = hyleProtectedProxy(configs); export async function proxy(req) { return (await share(req)) ?? NextResponse.next(); }`.
562
+ * A path under a live share slug is REWRITTEN to `/hyle-protected/view/<path>` (the visitor's URL does not change); every other
563
+ * request returns undefined, so the host's ordinary pages stay cached. A proxy has no fetch cache, so it keeps ONE read of hyle's
564
+ * mounts per config in memory for 30 seconds (shared by concurrent requests, the last good copy used when a refresh fails) and
565
+ * matches every path against it locally: random paths never cost a call to hyle. The page behind the rewrite checks again through
566
+ * the usual mounts cache. A mounts read that fails with no copy counts as "not a share" for those 30 seconds rather than erroring
567
+ * every request of the host.
568
+ */
569
+ declare function hyleProtectedProxy(options: Configs): (req: NextRequest) => Promise<NextResponse | undefined>;
570
+ /** The page of `app/hyle-protected/view/[[...path]]/page.tsx` (see `hyleProtectedProxy`): the share under the path, else `notFound()`. */
571
+ declare function hyleProtectedPage(options: Configs): (props: {
572
+ readonly params: Promise<{
573
+ readonly path?: string[];
574
+ }>;
575
+ }) => Promise<ReactElement>;
576
+
577
+ export { type AssetRoute, type AssetRouteOptions, ENGAGE_CSRF_HEADER, type EngageReader, type EngagementRoute, type EngagementRouteOptions, FetchResolverOptions, HyleArticle, type HyleArticleProps, HyleComments, type HyleCommentsProps, type HyleFeedOptions, HyleList, type HyleListProps, type HyleNextOptions, type HylePreviewPageOptions, HyleResolver, type HyleRootConfig, type HyleRootSitemapOptions, type HyleSitemapOptions, type LlmsTxtOptions, MOUNTS_MAX_STALE_MS, type MarkdownRoute, type OgImageRoute, type PageProps, type RevalidateRouteOptions, type RouteParams, createAssetRoute, createEngagementRoute, createLlmsTxtRoute, createMarkdownRoute, createOgImageRoute, createProtectedUnlockRoute, createRevalidateRoute, hyleFeed, hyleFeedLink, hyleMetadata, hylePage, hylePreviewMetadata, hylePreviewPage, hyleProtectedMetadata, hyleProtectedPage, hyleProtectedProxy, hyleRootMetadata, hyleRootPage, hyleRootSitemap, hyleSitemap, markdownRewritePath };
package/dist/next.d.ts CHANGED
@@ -1,12 +1,13 @@
1
1
  import { ReactElement } from 'react';
2
- import { A as ArticleRef, O as OgImage, J as JsonLdConfig, H as HyleComponents, a as HyleSlots, E as EngagementConfig, b as EmbedHeading } from './embed-g7NT1CyB.js';
3
- export { c as HyleCommentsFallback } from './embed-g7NT1CyB.js';
4
- import { F as FetchResolverOptions, H as HyleResolver } from './resolve-BqC9l5RH.js';
5
- export { f as fetchResolver, w as workspaceTags } from './resolve-BqC9l5RH.js';
2
+ import { A as ArticleRef, O as OgImage, J as JsonLdConfig, H as HyleComponents, a as HyleSlots, E as EngagementConfig, b as EmbedHeading } from './embed-DavTgSU4.js';
3
+ export { c as HyleCommentsFallback } from './embed-DavTgSU4.js';
4
+ import { F as FetchResolverOptions, H as HyleResolver } from './resolve-BseM68oy.js';
5
+ export { f as fetchResolver, w as workspaceTags } from './resolve-BseM68oy.js';
6
6
  import { MetadataRoute, ResolvingMetadata, Metadata } from 'next';
7
7
  import { R as RevalidationCallbackOptions, b as RevalidationCallbackRoute } from './revalidation-callback-BQl77tQR.js';
8
- import { c as HyleCredential } from './client--ighAWaj.js';
9
- import './types-b9QbmEDd.js';
8
+ import { c as HyleCredential } from './client-BErei7cE.js';
9
+ import { NextRequest, NextResponse } from 'next/server';
10
+ import './types-Dx-fEiZd.js';
10
11
 
11
12
  type RouteParams = Record<string, string | string[] | undefined>;
12
13
  interface CommonOptions {
@@ -387,7 +388,7 @@ interface AssetRoute {
387
388
  * header so that draft's assets load; every such answer is `no-store`. The token is never sent for the theme stylesheet,
388
389
  * which is the credential's own with or without it. No other query parameter is read.
389
390
  *
390
- * Protected page (hyle ADR 0039): `?hyle_protected=<pageId>` takes the password from that page's cookie (`hyle_p_<pageId>`, set by
391
+ * Protected share (hyle ADR 0040): `?hyle_protected=<slug>` takes the password from that share's cookie (`hyle_p_<hash of slug>`, set by
391
392
  * `createProtectedUnlockRoute`) and forwards it as the `cp-protected` header. A missing or malformed cookie is a 404 that reaches
392
393
  * nobody; every such answer is private and `no-store`, as a draft's is.
393
394
  */
@@ -539,34 +540,38 @@ declare const hylePreviewMetadata: Metadata;
539
540
  declare function hylePreviewPage(options: HylePreviewPageOptions): (props: PageProps) => Promise<ReactElement>;
540
541
 
541
542
  /**
542
- * `export const metadata = hyleProtectedMetadata`, next to `hyleProtectedPage`. The page also renders both tags itself. The
543
- * referrer is `same-origin`, not `no-referrer`: a no-referrer page sends `Origin: null` on its own form POST, which the unlock
544
- * route would refuse. The URL carries no secret.
543
+ * The `robots` and `referrer` of a protected share (hyle ADR 0040). The unlock form is same-origin by `Sec-Fetch-Site`, so
544
+ * `no-referrer` does not stop it. The URL carries no secret.
545
545
  */
546
546
  declare const hyleProtectedMetadata: Metadata;
547
547
  /**
548
- * The page behind a protected link (ADR 0039): `export default hyleProtectedPage({ baseUrl, token })` in `app/p/[id]/page.tsx`.
549
- * It reads the visitor's cookie for this page and asks hyle for it: no cookie shows the password form, a cookie hyle refuses
550
- * shows the form with "Wrong or expired password", and a good one draws the article as a published page does. A malformed id
551
- * or a switched-off surface is `notFound()`. The page reads cookies, so it is rendered per request and never cached.
552
- */
553
- declare function hyleProtectedPage(options: HylePreviewPageOptions): (props: {
554
- params: Promise<{
555
- id?: string;
556
- }>;
557
- }) => Promise<ReactElement>;
558
- /**
559
- * `export const { POST } = createProtectedUnlockRoute()` in `app/p/[id]/unlock/route.ts`. The form posts the password here; the
560
- * route sets it in the page's HttpOnly cookie and sends the visitor back to `/p/<id>`, where the page checks it with hyle. It
561
- * never calls hyle itself, so a view is one open. Only a same-origin POST with a form body of at most 1 KiB is read, and the
562
- * password is stored only if it has the password's shape. The redirect target is built from the validated page id alone.
548
+ * `export const { POST } = createProtectedUnlockRoute()` in `app/hyle-protected/unlock/route.ts` (ADR 0040). The password form
549
+ * posts `slug` and `password` here; the route sets the password in the share's HttpOnly cookie (scoped to `/<slug>` and to the asset route, so no other request of the host carries it) and sends the visitor to `/<slug>`,
550
+ * where the page checks it with hyle. It never calls hyle, so a view is one open. Only a same-origin POST with a form body of at
551
+ * most 1 KiB is read. The cookie is set only for a password of the right shape, and the redirect target is built from the
552
+ * validated slug alone.
563
553
  */
564
554
  declare function createProtectedUnlockRoute(): {
565
- POST: (req: Request, ctx: {
566
- params: Promise<{
567
- id?: string;
568
- }>;
569
- }) => Promise<Response>;
555
+ POST: (req: Request) => Promise<Response>;
570
556
  };
571
557
 
572
- export { type AssetRoute, type AssetRouteOptions, ENGAGE_CSRF_HEADER, type EngageReader, type EngagementRoute, type EngagementRouteOptions, FetchResolverOptions, HyleArticle, type HyleArticleProps, HyleComments, type HyleCommentsProps, type HyleFeedOptions, HyleList, type HyleListProps, type HyleNextOptions, type HylePreviewPageOptions, HyleResolver, type HyleRootConfig, type HyleRootSitemapOptions, type HyleSitemapOptions, type LlmsTxtOptions, MOUNTS_MAX_STALE_MS, type MarkdownRoute, type OgImageRoute, type PageProps, type RevalidateRouteOptions, type RouteParams, createAssetRoute, createEngagementRoute, createLlmsTxtRoute, createMarkdownRoute, createOgImageRoute, createProtectedUnlockRoute, createRevalidateRoute, hyleFeed, hyleFeedLink, hyleMetadata, hylePage, hylePreviewMetadata, hylePreviewPage, hyleProtectedMetadata, hyleProtectedPage, hyleRootMetadata, hyleRootPage, hyleRootSitemap, hyleSitemap, markdownRewritePath };
558
+ /**
559
+ * For a host whose catch-all is static or ISR (`revalidate`, `generateStaticParams`): reading the visitor's cookie there is a 500
560
+ * (`DYNAMIC_SERVER_USAGE`), so a share is drawn by a dynamic route instead. In the host's `proxy.ts`:
561
+ * `const share = hyleProtectedProxy(configs); export async function proxy(req) { return (await share(req)) ?? NextResponse.next(); }`.
562
+ * A path under a live share slug is REWRITTEN to `/hyle-protected/view/<path>` (the visitor's URL does not change); every other
563
+ * request returns undefined, so the host's ordinary pages stay cached. A proxy has no fetch cache, so it keeps ONE read of hyle's
564
+ * mounts per config in memory for 30 seconds (shared by concurrent requests, the last good copy used when a refresh fails) and
565
+ * matches every path against it locally: random paths never cost a call to hyle. The page behind the rewrite checks again through
566
+ * the usual mounts cache. A mounts read that fails with no copy counts as "not a share" for those 30 seconds rather than erroring
567
+ * every request of the host.
568
+ */
569
+ declare function hyleProtectedProxy(options: Configs): (req: NextRequest) => Promise<NextResponse | undefined>;
570
+ /** The page of `app/hyle-protected/view/[[...path]]/page.tsx` (see `hyleProtectedProxy`): the share under the path, else `notFound()`. */
571
+ declare function hyleProtectedPage(options: Configs): (props: {
572
+ readonly params: Promise<{
573
+ readonly path?: string[];
574
+ }>;
575
+ }) => Promise<ReactElement>;
576
+
577
+ export { type AssetRoute, type AssetRouteOptions, ENGAGE_CSRF_HEADER, type EngageReader, type EngagementRoute, type EngagementRouteOptions, FetchResolverOptions, HyleArticle, type HyleArticleProps, HyleComments, type HyleCommentsProps, type HyleFeedOptions, HyleList, type HyleListProps, type HyleNextOptions, type HylePreviewPageOptions, HyleResolver, type HyleRootConfig, type HyleRootSitemapOptions, type HyleSitemapOptions, type LlmsTxtOptions, MOUNTS_MAX_STALE_MS, type MarkdownRoute, type OgImageRoute, type PageProps, type RevalidateRouteOptions, type RouteParams, createAssetRoute, createEngagementRoute, createLlmsTxtRoute, createMarkdownRoute, createOgImageRoute, createProtectedUnlockRoute, createRevalidateRoute, hyleFeed, hyleFeedLink, hyleMetadata, hylePage, hylePreviewMetadata, hylePreviewPage, hyleProtectedMetadata, hyleProtectedPage, hyleProtectedProxy, hyleRootMetadata, hyleRootPage, hyleRootSitemap, hyleSitemap, markdownRewritePath };