@parhelia/preview-ticket 0.0.0-stage → 1.0.13030

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 (59) hide show
  1. package/README.md +59 -2
  2. package/dist/alpaca/index.d.ts +101 -0
  3. package/dist/alpaca/index.d.ts.map +1 -0
  4. package/dist/alpaca/index.js +200 -0
  5. package/dist/client.d.ts +36 -0
  6. package/dist/client.d.ts.map +1 -0
  7. package/dist/client.js +125 -0
  8. package/dist/config.d.ts +52 -0
  9. package/dist/config.d.ts.map +1 -0
  10. package/dist/config.js +51 -0
  11. package/dist/constants.d.ts +80 -0
  12. package/dist/constants.d.ts.map +1 -0
  13. package/dist/constants.js +79 -0
  14. package/dist/context.d.ts +9 -0
  15. package/dist/context.d.ts.map +1 -0
  16. package/dist/context.js +46 -0
  17. package/dist/cookie.d.ts +7 -0
  18. package/dist/cookie.d.ts.map +1 -0
  19. package/dist/cookie.js +29 -0
  20. package/dist/errors.d.ts +91 -0
  21. package/dist/errors.d.ts.map +1 -0
  22. package/dist/errors.js +114 -0
  23. package/dist/fetch/index.d.ts +51 -0
  24. package/dist/fetch/index.d.ts.map +1 -0
  25. package/dist/fetch/index.js +44 -0
  26. package/dist/gateway.d.ts +17 -0
  27. package/dist/gateway.d.ts.map +1 -0
  28. package/dist/gateway.js +41 -0
  29. package/dist/headers.d.ts +4 -0
  30. package/dist/headers.d.ts.map +1 -0
  31. package/dist/headers.js +40 -0
  32. package/dist/index.d.ts +25 -0
  33. package/dist/index.d.ts.map +1 -0
  34. package/dist/index.js +15 -0
  35. package/dist/kit.d.ts +54 -0
  36. package/dist/kit.d.ts.map +1 -0
  37. package/dist/kit.js +347 -0
  38. package/dist/next/app.d.ts +8 -0
  39. package/dist/next/app.d.ts.map +1 -0
  40. package/dist/next/app.js +14 -0
  41. package/dist/next/index.d.ts +58 -0
  42. package/dist/next/index.d.ts.map +1 -0
  43. package/dist/next/index.js +121 -0
  44. package/dist/redact.d.ts +3 -0
  45. package/dist/redact.d.ts.map +1 -0
  46. package/dist/redact.js +11 -0
  47. package/dist/refusal.d.ts +20 -0
  48. package/dist/refusal.d.ts.map +1 -0
  49. package/dist/refusal.js +26 -0
  50. package/dist/secrets.d.ts +12 -0
  51. package/dist/secrets.d.ts.map +1 -0
  52. package/dist/secrets.js +21 -0
  53. package/dist/signing.d.ts +44 -0
  54. package/dist/signing.d.ts.map +1 -0
  55. package/dist/signing.js +94 -0
  56. package/dist/store.d.ts +59 -0
  57. package/dist/store.d.ts.map +1 -0
  58. package/dist/store.js +69 -0
  59. package/package.json +66 -4
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Where a live session's reads go: the Parhelia preview gateway of the head's preview store, with the session's
3
+ * `credential` (the ticket's gateway credential, derived from the preview key — never the key) in the CMS SDK's own
4
+ * credential slot and the session's `headers` on every read. The one place the environment names of the gateway are read:
5
+ *
6
+ * | Variable | Meaning |
7
+ * |---|---|
8
+ * | `PARHELIA_PREVIEW_URL` | Parhelia's base URL as the head's server reaches it (`https:`; `http:` only for loopback or with `PARHELIA_PREVIEW_ALLOW_HTTP=true`) |
9
+ * | `PARHELIA_ORIGIN` | used when `PARHELIA_PREVIEW_URL` is unset (setup plan E: the one name for the Parhelia origin) |
10
+ * | `PARHELIA_PREVIEW_KEY` | the host entry's `previewKey` |
11
+ * | `PARHELIA_PREVIEW_STORE` | the store id the reads go to (one of the entry's `previewStores`) |
12
+ * | `PARHELIA_STORE` | used when `PARHELIA_PREVIEW_STORE` is unset (the store the head renders) |
13
+ *
14
+ * The redemption reads the same URL and key with the same rules (`config.ts`), so a head that could redeem a code can read
15
+ * through the gateway. The key stays in the head: it signs the redemption and derives each session's credential.
16
+ */
17
+ import { previewGatewayUrl } from "./client.js";
18
+ import { redemptionConfigOf } from "./config.js";
19
+ import { ENV_PREVIEW_STORE, ENV_STORE } from "./constants.js";
20
+ import { HeadPreviewStates, ParheliaPreviewError, refusal } from "./errors.js";
21
+ /**
22
+ * The gateway from the environment (default `process.env`, read at call time). Throws {@link ParheliaPreviewError}
23
+ * `preview-head-not-configured` (500) when the URL, the key or the store is missing, or the URL is not acceptable — a
24
+ * named state for the page to show, never a render with the head's own credential.
25
+ */
26
+ export const previewGatewayFromEnv = (env = typeof process !==
27
+ "undefined" && process.env
28
+ ? process.env
29
+ : {}) => {
30
+ const config = redemptionConfigOf({ env });
31
+ if ("code" in config)
32
+ throw new ParheliaPreviewError(config);
33
+ const storeId = (env[ENV_PREVIEW_STORE]?.trim() || env[ENV_STORE]?.trim()) ?? "";
34
+ if (!storeId) {
35
+ throw new ParheliaPreviewError(refusal(HeadPreviewStates.HeadNotConfigured, `The head has no ${ENV_PREVIEW_STORE} (or ${ENV_STORE}) configured for per-person preview.`));
36
+ }
37
+ return {
38
+ baseUrl: previewGatewayUrl(config.parheliaUrl, storeId),
39
+ storeId,
40
+ };
41
+ };
@@ -0,0 +1,4 @@
1
+ export type PreviewHeaders = Readonly<Record<string, string>>;
2
+ /** A header map carrying `ticket`, or an empty one. */
3
+ export declare const previewHeaderMap: (ticket?: string) => PreviewHeaders;
4
+ //# sourceMappingURL=headers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"headers.d.ts","sourceRoot":"","sources":["../src/headers.ts"],"names":[],"mappings":"AAaA,MAAM,MAAM,cAAc,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAmB9D,uDAAuD;AACvD,eAAO,MAAM,gBAAgB,YAAa,MAAM,KAAG,cAWlD,CAAC"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * The header map a head passes to its preview client: `{ "X-Parhelia-Preview-Ticket": "<ticket>" }`
3
+ * during a live preview session, `{}` otherwise.
4
+ *
5
+ * It spreads, iterates and converts like a plain record (`{...h}`, `Object.entries(h)`,
6
+ * `new Headers(h)`), but it never serialises: `JSON.stringify` (Next.js `__NEXT_DATA__`, API
7
+ * answers) and the React Server Components payload both see `{}` through `toJSON`, Node's
8
+ * `console.log` / `util.inspect` print `[redacted]`, and Next.js' own `getServerSideProps` check
9
+ * rejects it as a prop in development (not a plain object). A head that copies the ticket into a
10
+ * plain object and returns that as a prop defeats this — pass the map straight to the client.
11
+ */
12
+ import { PREVIEW_TICKET_HEADER } from "./constants.js";
13
+ const INSPECT = Symbol.for("nodejs.util.inspect.custom");
14
+ const PreviewHeadersPrototype = Object.create(Object.prototype, {
15
+ toJSON: {
16
+ value: () => ({}),
17
+ enumerable: false,
18
+ },
19
+ toString: {
20
+ value: () => "[PreviewHeaders redacted]",
21
+ enumerable: false,
22
+ },
23
+ [INSPECT]: {
24
+ value: () => "PreviewHeaders { [redacted] }",
25
+ enumerable: false,
26
+ },
27
+ });
28
+ /** A header map carrying `ticket`, or an empty one. */
29
+ export const previewHeaderMap = (ticket) => {
30
+ const map = Object.create(PreviewHeadersPrototype);
31
+ if (ticket) {
32
+ Object.defineProperty(map, PREVIEW_TICKET_HEADER, {
33
+ value: ticket,
34
+ enumerable: true,
35
+ writable: false,
36
+ configurable: false,
37
+ });
38
+ }
39
+ return Object.freeze(map);
40
+ };
@@ -0,0 +1,25 @@
1
+ /**
2
+ * `@parhelia/preview-ticket` — the framework-neutral core of Parhelia's opt-in per-person preview
3
+ * for rendering hosts. Next.js heads use `@parhelia/preview-ticket/next`, other fetch-based heads
4
+ * `@parhelia/preview-ticket/fetch`.
5
+ */
6
+ export { PREVIEW_CODE_PARAMETER, PREVIEW_HANDLE_COOKIE, PREVIEW_TICKET_HEADER, PREVIEW_REFUSAL_HEADER, DEFAULT_SESSION_CAP_SECONDS, ENV_PARHELIA_URL, ENV_PARHELIA_ORIGIN, ENV_PREVIEW_KEY, ENV_ALLOW_HTTP, ENV_PREVIEW_STORE, ENV_STORE, PREVIEW_PROTOCOL_VERSION, } from "./constants.js";
7
+ export { previewGatewayUrl, previewTicketUrl, redeemPreviewCode, } from "./client.js";
8
+ export { previewGatewayFromEnv } from "./gateway.js";
9
+ export type { PreviewGateway } from "./gateway.js";
10
+ export type { RedeemInput, RedemptionResult, RedeemedTicket, RefusedRedemption, } from "./client.js";
11
+ export type { PreviewKitOptions } from "./config.js";
12
+ export { DeliveryReadRefused, HeadPreviewStates, ParheliaPreviewError, RedemptionRefusals, } from "./errors.js";
13
+ export { gatewayCredential, previewKeyId, signRedemption } from "./signing.js";
14
+ export type { RedemptionSignature, SignRedemptionInput } from "./signing.js";
15
+ export type { HeadPreviewState, PreviewRefusal } from "./errors.js";
16
+ export { answerPreviewRefusal, deliveryRefusal, previewRefusalOf } from "./refusal.js";
17
+ export type { RefusalResponse } from "./refusal.js";
18
+ export type { PreviewHeaders } from "./headers.js";
19
+ export { createPreviewKit, NO_STORE_HEADERS } from "./kit.js";
20
+ export { FRAME_REFERRER_POLICY, redemptionContextRefusal } from "./context.js";
21
+ export type { CookieSource, PreviewDecision, PreviewKit, PreviewSession, } from "./kit.js";
22
+ export { redactParheliaPreview } from "./redact.js";
23
+ export { createMemoryPreviewStore, sharedMemoryPreviewStore } from "./store.js";
24
+ export type { CookieCheckRecord, MemoryStoreOptions, PreviewStoreRecord, PreviewTicketStore, RefusedRecord, TicketRecord, } from "./store.js";
25
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EACL,sBAAsB,EACtB,qBAAqB,EACrB,qBAAqB,EACrB,sBAAsB,EACtB,2BAA2B,EAC3B,gBAAgB,EAChB,mBAAmB,EACnB,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,SAAS,EACT,wBAAwB,GACzB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACrD,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACnD,YAAY,EACV,WAAW,EACX,gBAAgB,EAChB,cAAc,EACd,iBAAiB,GAClB,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC/E,YAAY,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAC7E,YAAY,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACvF,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAC/E,YAAY,EACV,YAAY,EACZ,eAAe,EACf,UAAU,EACV,cAAc,GACf,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,wBAAwB,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAChF,YAAY,EACV,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,aAAa,EACb,YAAY,GACb,MAAM,YAAY,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,15 @@
1
+ /**
2
+ * `@parhelia/preview-ticket` — the framework-neutral core of Parhelia's opt-in per-person preview
3
+ * for rendering hosts. Next.js heads use `@parhelia/preview-ticket/next`, other fetch-based heads
4
+ * `@parhelia/preview-ticket/fetch`.
5
+ */
6
+ export { PREVIEW_CODE_PARAMETER, PREVIEW_HANDLE_COOKIE, PREVIEW_TICKET_HEADER, PREVIEW_REFUSAL_HEADER, DEFAULT_SESSION_CAP_SECONDS, ENV_PARHELIA_URL, ENV_PARHELIA_ORIGIN, ENV_PREVIEW_KEY, ENV_ALLOW_HTTP, ENV_PREVIEW_STORE, ENV_STORE, PREVIEW_PROTOCOL_VERSION, } from "./constants.js";
7
+ export { previewGatewayUrl, previewTicketUrl, redeemPreviewCode, } from "./client.js";
8
+ export { previewGatewayFromEnv } from "./gateway.js";
9
+ export { DeliveryReadRefused, HeadPreviewStates, ParheliaPreviewError, RedemptionRefusals, } from "./errors.js";
10
+ export { gatewayCredential, previewKeyId, signRedemption } from "./signing.js";
11
+ export { answerPreviewRefusal, deliveryRefusal, previewRefusalOf } from "./refusal.js";
12
+ export { createPreviewKit, NO_STORE_HEADERS } from "./kit.js";
13
+ export { FRAME_REFERRER_POLICY, redemptionContextRefusal } from "./context.js";
14
+ export { redactParheliaPreview } from "./redact.js";
15
+ export { createMemoryPreviewStore, sharedMemoryPreviewStore } from "./store.js";
package/dist/kit.d.ts ADDED
@@ -0,0 +1,54 @@
1
+ import { type PreviewKitOptions } from "./config.js";
2
+ import { type PreviewHeaders } from "./headers.js";
3
+ export type PreviewDecision = {
4
+ readonly kind: "pass";
5
+ } | {
6
+ readonly kind: "live";
7
+ readonly ticketId: string;
8
+ } | {
9
+ readonly kind: "answer";
10
+ readonly response: Response;
11
+ readonly reason: "redeemed" | "refused";
12
+ };
13
+ export interface PreviewSession {
14
+ /** Parhelia's non-secret name of the ticket (for logs and support). */
15
+ readonly ticketId: string;
16
+ /** The header map for the head's preview client (see {@link PreviewHeaders}). */
17
+ readonly headers: PreviewHeaders;
18
+ /**
19
+ * What the head's preview client puts in the CMS SDK's own credential slot on gateway reads (the SDK's access token or API
20
+ * key): the ticket's gateway credential, derived from the head's key, never the key itself. As secret as the ticket: not enumerable, never serialised (`JSON.stringify` and
21
+ * `util.inspect` of the session leave it out) — pass it straight to the client, never into a prop.
22
+ */
23
+ readonly credential: string;
24
+ }
25
+ /**
26
+ * Where a render reads the handle from: a Web `Request`, `Headers`, a `Cookie` header string, a
27
+ * Node request (`{ headers: { cookie } }`), Next's parsed cookies (`{ cookies: { name: value } }`,
28
+ * `NextApiRequest`, `getServerSideProps`' `req`) or Next's `cookies()` store (`{ get(name) }`).
29
+ */
30
+ export type CookieSource = Request | Headers | string | null | undefined | {
31
+ readonly get: (name: string) => {
32
+ readonly value: string;
33
+ } | undefined;
34
+ } | {
35
+ readonly headers: Headers | {
36
+ readonly cookie?: string | readonly string[] | undefined;
37
+ };
38
+ } | {
39
+ readonly cookies: Readonly<Partial<Record<string, string>>>;
40
+ };
41
+ export interface PreviewKit {
42
+ /** Middleware step: run before any render, for every request the head serves. */
43
+ handle(request: Request, context?: {
44
+ readonly basePath?: string;
45
+ }): Promise<PreviewDecision>;
46
+ /** The live session of this render, null without a handle cookie; throws {@link ParheliaPreviewError} otherwise. */
47
+ readSession(source: CookieSource): Promise<PreviewSession | null>;
48
+ /** The ticket header map of this render (`{}` without a handle cookie); throws {@link ParheliaPreviewError} otherwise. */
49
+ headers(source: CookieSource): Promise<PreviewHeaders>;
50
+ }
51
+ /** Response headers of every answer this package gives and of every live-session render. */
52
+ export declare const NO_STORE_HEADERS: Readonly<Record<string, string>>;
53
+ export declare const createPreviewKit: (options?: PreviewKitOptions) => PreviewKit;
54
+ //# sourceMappingURL=kit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kit.d.ts","sourceRoot":"","sources":["../src/kit.ts"],"names":[],"mappings":"AAiBA,OAAO,EAML,KAAK,iBAAiB,EACvB,MAAM,aAAa,CAAC;AAerB,OAAO,EAAoB,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AAUrE,MAAM,MAAM,eAAe,GACvB;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACzB;IAAE,QAAQ,CAAC,IAAI,EAAE,MA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CAAC;IAClE,0HAA0H;IAC1H,OAAO,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;CACxD;AAED,4FAA4F;AAC5F,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAK7D,CAAC;AAEF,eAAO,MAAM,gBAAgB,aAClB,iBAAiB,KACzB,UAoRF,CAAC"}
package/dist/kit.js ADDED
@@ -0,0 +1,347 @@
1
+ /**
2
+ * The framework-neutral core of a head's per-person preview.
3
+ *
4
+ * `handle(request)` runs before anything renders and decides one of three things:
5
+ * - **pass** — no code in the URL and no handle cookie: the request is not touched (today's head);
6
+ * - **answer** — a response to send instead of rendering: the 303 that removes a code from the URL
7
+ * (after redeeming it back-channel and setting the handle cookie), or a named refusal page — among them a code
8
+ * outside the editor's frame (`context.ts`: the editor-bound redemption rule), refused before anything else;
9
+ * - **live** — a live preview session: render, `private, no-store`, and read the ticket with
10
+ * `readSession()` / `headers()` from the same store.
11
+ *
12
+ * The ticket is only ever in the head's server-side store and in the header map handed to the
13
+ * head's preview client. It is never in a URL, a cookie, a response header, a log line or a prop.
14
+ * The head's key signs the redemption and derives each ticket's gateway credential; it never travels.
15
+ */
16
+ import { redeemPreviewCode } from "./client.js";
17
+ import { redemptionContextRefusal } from "./context.js";
18
+ import { cookieCheckOf, editorOriginOf, redemptionConfigOf, redemptionTimeoutOf, sessionCapOf, } from "./config.js";
19
+ import { EDITOR_SIGNAL_HEADER, PARHELIA_FRAME_MARKER_PARAMETER, PREVIEW_CODE_PARAMETER, PREVIEW_HANDLE_COOKIE, PREVIEW_REFUSAL_HEADER, } from "./constants.js";
20
+ import { cookiePath, handleCookie, handleCookieValues } from "./cookie.js";
21
+ import { HeadPreviewStates, ParheliaPreviewError, refusal, } from "./errors.js";
22
+ import { previewHeaderMap } from "./headers.js";
23
+ import { frameUrlKey, handleKey, isHandle, newHandle } from "./secrets.js";
24
+ import { gatewayCredential } from "./signing.js";
25
+ import { assertSharedStore, sharedMemoryPreviewStore, } from "./store.js";
26
+ /** Response headers of every answer this package gives and of every live-session render. */
27
+ export const NO_STORE_HEADERS = Object.freeze({
28
+ "Cache-Control": "private, no-store",
29
+ "Referrer-Policy": "no-referrer",
30
+ });
31
+ export const createPreviewKit = (options = {}) => {
32
+ const storeOf = () => options.store ?? sharedMemoryPreviewStore();
33
+ const answerRefusal = async (state, request) => ({
34
+ kind: "answer",
35
+ reason: "refused",
36
+ response: await refusalResponse(state, request, options),
37
+ });
38
+ const handle = async (request, context) => {
39
+ const url = new URL(request.url);
40
+ const rawPairs = url.search.length > 1 ? url.search.slice(1).split("&") : [];
41
+ const codePairs = rawPairs.filter((pair) => isCodePair(pair));
42
+ const cookieValues = handleCookieValues(request.headers.get("cookie"));
43
+ if (codePairs.length > 0) {
44
+ // The editor-bound rule first: a code outside the editor's frame is refused by name — Parhelia is not called, no
45
+ // cookie is set and no handle is touched (a planted request must not replace the browser's live session either).
46
+ const outside = redemptionContextRefusal(request.headers, editorOriginOf(options));
47
+ if (outside)
48
+ return answerRefusal(outside, request);
49
+ return redeem(request, url, rawPairs, codePairs, cookieValues, context?.basePath);
50
+ }
51
+ if (cookieValues.length > 0) {
52
+ return resume(request, cookieValues);
53
+ }
54
+ if (url.searchParams.has(PARHELIA_FRAME_MARKER_PARAMETER)) {
55
+ return checkDroppedCookie(request, url);
56
+ }
57
+ return PASS;
58
+ };
59
+ const redeem = async (request, url, rawPairs, codePairs, cookieValues, basePath) => {
60
+ const kept = rawPairs.filter((pair) => pair.length > 0 && !isCodePair(pair));
61
+ const query = kept.length > 0 ? `?${kept.join("&")}` : "";
62
+ const lastSegment = url.pathname.slice(url.pathname.lastIndexOf("/") + 1);
63
+ const location = `./${lastSegment}${query}`;
64
+ // The follow-up request's URL as the URL parser will see it (the key of the dropped-cookie check).
65
+ const target = new URL(location, url);
66
+ const pathAndQuery = `${target.pathname}${target.search}`;
67
+ let outcome;
68
+ const code = codePairs.length === 1 ? decodeValue(codePairs[0]) : undefined;
69
+ const config = redemptionConfigOf(options);
70
+ let store;
71
+ try {
72
+ store = storeOf();
73
+ assertSharedStore(store);
74
+ }
75
+ catch (error) {
76
+ return answerRefusal(stateOf(error), request);
77
+ }
78
+ if (!code || !/^[A-Za-z0-9_-]{1,256}$/.test(code)) {
79
+ outcome = refusedRecord(refusal(HeadPreviewStates.CodeInvalid, "The frame URL carried no usable preview code."));
80
+ }
81
+ else if ("code" in config) {
82
+ outcome = refusedRecord(config);
83
+ }
84
+ else {
85
+ const result = await redeemPreviewCode({
86
+ parheliaUrl: config.parheliaUrl,
87
+ previewKey: config.previewKey,
88
+ code,
89
+ fetch: options.fetch,
90
+ timeoutMs: redemptionTimeoutOf(options),
91
+ });
92
+ outcome = result.ok
93
+ ? {
94
+ v: 1,
95
+ kind: "ticket",
96
+ ticket: result.ticket,
97
+ ticketId: result.ticketId,
98
+ expiresIn: result.expiresIn,
99
+ }
100
+ : refusedRecord(result.refusal);
101
+ }
102
+ const handleValue = newHandle();
103
+ const cap = sessionCapOf(options);
104
+ const checkKey = url.searchParams.has(PARHELIA_FRAME_MARKER_PARAMETER)
105
+ ? await frameUrlKey(pathAndQuery)
106
+ : undefined;
107
+ try {
108
+ // A fresh handle per redemption (never the browser's old one: a planted handle must not
109
+ // receive the next person's ticket); the replaced record is dropped.
110
+ for (const old of cookieValues)
111
+ if (isHandle(old))
112
+ await store.delete(await handleKey(old));
113
+ await store.set(await handleKey(handleValue), { ...outcome, ...(checkKey ? { checkKey } : {}) }, cap);
114
+ if (checkKey) {
115
+ await store.set(checkKey, {
116
+ v: 1,
117
+ kind: "cookie-check",
118
+ ...(outcome.kind === "refused"
119
+ ? {
120
+ code: outcome.code,
121
+ status: outcome.status,
122
+ message: outcome.message,
123
+ }
124
+ : {}),
125
+ ...(isProxied(request) ? { proxied: true } : {}),
126
+ }, cookieCheckOf(options));
127
+ }
128
+ }
129
+ catch {
130
+ return answerRefusal(refusal(HeadPreviewStates.StoreUnavailable, "The head's preview store failed."), request);
131
+ }
132
+ const headers = new Headers(NO_STORE_HEADERS);
133
+ headers.set("Location", location);
134
+ headers.append("Set-Cookie", handleCookie(handleValue, cookiePath(basePath), cap));
135
+ return {
136
+ kind: "answer",
137
+ reason: "redeemed",
138
+ response: new Response(null, { status: 303, headers }),
139
+ };
140
+ };
141
+ const resume = async (request, cookieValues) => {
142
+ const lost = refusal(HeadPreviewStates.SessionLost, "This head no longer knows the preview session; reload the page in the editor.");
143
+ const handleValue = cookieValues.find(isHandle);
144
+ if (!handleValue)
145
+ return answerRefusal(lost, request);
146
+ let record;
147
+ try {
148
+ const store = storeOf();
149
+ assertSharedStore(store);
150
+ const key = await handleKey(handleValue);
151
+ record = await store.get(key);
152
+ if (record && record.kind !== "cookie-check" && record.checkKey) {
153
+ // The browser sent the handle back: the dropped-cookie check for that frame URL is done.
154
+ await store.delete(record.checkKey);
155
+ const { checkKey: _done, ...confirmed } = record;
156
+ await store.set(key, confirmed, sessionCapOf(options));
157
+ }
158
+ }
159
+ catch (error) {
160
+ return answerRefusal(stateOf(error), request);
161
+ }
162
+ if (record?.kind === "ticket")
163
+ return { kind: "live", ticketId: record.ticketId };
164
+ if (record?.kind === "refused")
165
+ return answerRefusal(refusal(record.code, record.message, record.status), request);
166
+ return answerRefusal(lost, request);
167
+ };
168
+ const checkDroppedCookie = async (request, url) => {
169
+ let record;
170
+ try {
171
+ const store = storeOf();
172
+ if (store.sharedWithRender === false)
173
+ return PASS;
174
+ record = await store.get(await frameUrlKey(`${url.pathname}${url.search}`));
175
+ }
176
+ catch {
177
+ // Without a cookie nothing says this frame was meant to be a per-person preview; a store
178
+ // failure here must not break the canvases of entries that never opted in.
179
+ return PASS;
180
+ }
181
+ if (record?.kind !== "cookie-check")
182
+ return PASS;
183
+ // Without the cookie nothing names the browser, so the check is keyed by the frame URL alone. A browser's follow-up
184
+ // and soft refreshes take the channel its redemption took; a request through the other one is someone else (a
185
+ // visitor typing the URL, a proxied editor while a directly framed one lost its cookie, a capture): not refused.
186
+ if ((record.proxied === true) !== isProxied(request))
187
+ return PASS;
188
+ return answerRefusal(record.code
189
+ ? refusal(record.code, record.message ?? "", record.status)
190
+ : refusal(HeadPreviewStates.CookieBlocked, "The browser did not keep the head's preview cookie (third-party or partitioned cookies are blocked), so per-person preview is unavailable here."), request);
191
+ };
192
+ const readSession = async (source) => {
193
+ const values = handleValuesOf(source);
194
+ if (values.length === 0)
195
+ return null;
196
+ const lost = refusal(HeadPreviewStates.SessionLost, "This head no longer knows the preview session; reload the page in the editor.");
197
+ const handleValue = values.find(isHandle);
198
+ if (!handleValue)
199
+ throw new ParheliaPreviewError(lost);
200
+ let record;
201
+ try {
202
+ const store = storeOf();
203
+ assertSharedStore(store);
204
+ record = await store.get(await handleKey(handleValue));
205
+ }
206
+ catch (error) {
207
+ throw new ParheliaPreviewError(stateOf(error));
208
+ }
209
+ if (record?.kind === "ticket") {
210
+ // The credential is derived per read from the key and the ticket: the store never holds it.
211
+ const config = redemptionConfigOf(options);
212
+ if ("code" in config)
213
+ throw new ParheliaPreviewError(config);
214
+ return previewSession(record.ticketId, record.ticket, await gatewayCredential(config.previewKey, record.ticket));
215
+ }
216
+ if (record?.kind === "refused")
217
+ throw new ParheliaPreviewError(refusal(record.code, record.message, record.status));
218
+ throw new ParheliaPreviewError(lost);
219
+ };
220
+ return {
221
+ handle,
222
+ readSession,
223
+ async headers(source) {
224
+ return (await readSession(source))?.headers ?? previewHeaderMap();
225
+ },
226
+ };
227
+ };
228
+ const PASS = Object.freeze({ kind: "pass" });
229
+ const INSPECT = Symbol.for("nodejs.util.inspect.custom");
230
+ /** A live session whose credential neither enumerates nor serialises (like the ticket in its header map). */
231
+ const previewSession = (ticketId, ticket, credential) => {
232
+ const session = { ticketId, headers: previewHeaderMap(ticket) };
233
+ Object.defineProperties(session, {
234
+ credential: { value: credential, enumerable: false },
235
+ toJSON: { value: () => ({ ticketId }), enumerable: false },
236
+ [INSPECT]: {
237
+ value: () => `PreviewSession { ticketId: ${JSON.stringify(ticketId)}, [redacted] }`,
238
+ enumerable: false,
239
+ },
240
+ });
241
+ return Object.freeze(session);
242
+ };
243
+ /**
244
+ * The request came through Parhelia's rendering proxy: it carries the editor signal header, which the proxy stamps on what
245
+ * it forwards and a browser cannot put on a frame navigation. Presence only — the value is the head's to check; a forged
246
+ * header gains nothing here but the render the head gives that request anyway.
247
+ */
248
+ const isProxied = (request) => request.headers.has(EDITOR_SIGNAL_HEADER);
249
+ const isCodePair = (pair) => {
250
+ const equals = pair.indexOf("=");
251
+ const name = equals < 0 ? pair : pair.slice(0, equals);
252
+ return decodeName(name) === PREVIEW_CODE_PARAMETER;
253
+ };
254
+ const decodeName = (name) => {
255
+ try {
256
+ return decodeURIComponent(name.replace(/\+/g, " "));
257
+ }
258
+ catch {
259
+ return name;
260
+ }
261
+ };
262
+ const decodeValue = (pair) => {
263
+ const equals = pair.indexOf("=");
264
+ if (equals < 0)
265
+ return undefined;
266
+ try {
267
+ return decodeURIComponent(pair.slice(equals + 1).replace(/\+/g, " "));
268
+ }
269
+ catch {
270
+ return undefined;
271
+ }
272
+ };
273
+ const refusedRecord = (state) => ({
274
+ v: 1,
275
+ kind: "refused",
276
+ code: state.code,
277
+ status: state.status,
278
+ message: state.message,
279
+ });
280
+ const stateOf = (error) => error instanceof ParheliaPreviewError
281
+ ? refusal(error.code, error.detail, error.status)
282
+ : refusal(HeadPreviewStates.StoreUnavailable, "The head's preview store failed.");
283
+ const handleValuesOf = (source) => {
284
+ if (source == null)
285
+ return [];
286
+ if (typeof source === "string")
287
+ return handleCookieValues(source);
288
+ if (source instanceof Headers)
289
+ return handleCookieValues(source.get("cookie"));
290
+ if (typeof Request !== "undefined" && source instanceof Request)
291
+ return handleCookieValues(source.headers.get("cookie"));
292
+ if ("cookies" in source &&
293
+ source.cookies &&
294
+ typeof source.cookies === "object") {
295
+ const cookies = source.cookies;
296
+ if (typeof cookies.get === "function") {
297
+ return handleValuesOf(cookies);
298
+ }
299
+ const value = cookies[PREVIEW_HANDLE_COOKIE];
300
+ if (typeof value === "string")
301
+ return [value];
302
+ // Fall through: a Node request whose cookies were not parsed still has the header.
303
+ }
304
+ if ("get" in source && typeof source.get === "function") {
305
+ const value = source.get(PREVIEW_HANDLE_COOKIE)?.value;
306
+ return typeof value === "string" ? [value] : [];
307
+ }
308
+ if ("headers" in source && source.headers) {
309
+ const headers = source.headers;
310
+ if (headers instanceof Headers)
311
+ return handleCookieValues(headers.get("cookie"));
312
+ const cookie = headers.cookie;
313
+ return handleCookieValues(Array.isArray(cookie)
314
+ ? cookie.join("; ")
315
+ : cookie);
316
+ }
317
+ return [];
318
+ };
319
+ const escapeHtml = (value) => value.replace(/[&<>"']/g, (char) => `&#${char.charCodeAt(0)};`);
320
+ /** The named refusal page (or the head's own, made private and unreferred). */
321
+ const refusalResponse = async (state, request, options) => {
322
+ if (options.onRefusal) {
323
+ const custom = await options.onRefusal(state, request);
324
+ const headers = new Headers(custom.headers);
325
+ for (const [name, value] of Object.entries(NO_STORE_HEADERS))
326
+ headers.set(name, value);
327
+ headers.set(PREVIEW_REFUSAL_HEADER, state.code);
328
+ return new Response(custom.body, {
329
+ status: custom.status,
330
+ statusText: custom.statusText,
331
+ headers,
332
+ });
333
+ }
334
+ const headers = new Headers(NO_STORE_HEADERS);
335
+ headers.set("Content-Type", "text/html; charset=utf-8");
336
+ headers.set("X-Content-Type-Options", "nosniff");
337
+ headers.set(PREVIEW_REFUSAL_HEADER, state.code);
338
+ const body = `<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="robots" content="noindex">` +
339
+ `<title>Preview unavailable</title></head><body><main><h1>Per-person preview is unavailable</h1>` +
340
+ `<p><code>${escapeHtml(state.code)}</code></p>` +
341
+ (state.message ? `<p>${escapeHtml(state.message)}</p>` : "") +
342
+ `</main></body></html>`;
343
+ return new Response(request.method === "HEAD" ? null : body, {
344
+ status: state.status,
345
+ headers,
346
+ });
347
+ };
@@ -0,0 +1,8 @@
1
+ import type { PreviewHeaders } from "../headers.js";
2
+ import type { PreviewSession } from "../kit.js";
3
+ import { type ParheliaPreviewNext } from "./index.js";
4
+ /** The ticket header map of this render (`{}` without a preview session); throws `ParheliaPreviewError` when a session cannot serve. */
5
+ export declare const previewHeaders: (instance?: ParheliaPreviewNext) => Promise<PreviewHeaders>;
6
+ /** The live preview session of this render, or null; throws `ParheliaPreviewError` when a session cannot serve. */
7
+ export declare const readPreviewSession: (instance?: ParheliaPreviewNext) => Promise<PreviewSession | null>;
8
+ //# sourceMappingURL=app.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../src/next/app.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAA0B,KAAK,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAE9E,wIAAwI;AACxI,eAAO,MAAM,cAAc,cACf,mBAAmB,KAC5B,OAAO,CAAC,cAAc,CAAgD,CAAC;AAE1E,mHAAmH;AACnH,eAAO,MAAM,kBAAkB,cACnB,mBAAmB,KAC5B,OAAO,CAAC,cAAc,GAAG,IAAI,CACiB,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * `@parhelia/preview-ticket/next/app` — App Router server code (server components, route handlers,
3
+ * server actions): reads the handle from `cookies()` and the ticket from the head's store.
4
+ *
5
+ * const client = createClient({ ...config, headers: await previewHeaders() });
6
+ *
7
+ * Reading cookies makes the route dynamic, which a per-person preview must be anyway.
8
+ */
9
+ import { cookies } from "next/headers.js";
10
+ import { defaultParheliaPreview } from "./index.js";
11
+ /** The ticket header map of this render (`{}` without a preview session); throws `ParheliaPreviewError` when a session cannot serve. */
12
+ export const previewHeaders = async (instance = defaultParheliaPreview()) => instance.previewHeadersFor(await cookies());
13
+ /** The live preview session of this render, or null; throws `ParheliaPreviewError` when a session cannot serve. */
14
+ export const readPreviewSession = async (instance = defaultParheliaPreview()) => instance.readPreviewSessionFor(await cookies());
@@ -0,0 +1,58 @@
1
+ /**
2
+ * `@parhelia/preview-ticket/next` — the Next.js middleware (App Router, Pages Router, Next 16
3
+ * `proxy.ts`) and the Pages Router / route-handler readers. App Router server components read the
4
+ * ticket with `@parhelia/preview-ticket/next/app` (it imports `next/headers`, which the Pages
5
+ * Router must not import).
6
+ *
7
+ * Opt in with one line — `export { parheliaPreview as proxy } from "@parhelia/preview-ticket/next";`
8
+ * (Next 16) or `export { parheliaPreview as middleware } …` — or wrap an existing one:
9
+ * `export default withParheliaPreview(existingProxy);`.
10
+ */
11
+ import { NextResponse, type NextRequest } from "next/server.js";
12
+ import type { PreviewKitOptions } from "../config.js";
13
+ import { type PreviewHeaders } from "../headers.js";
14
+ import { type CookieSource, type PreviewKit, type PreviewSession } from "../kit.js";
15
+ type Awaitable<T> = T | Promise<T>;
16
+ /** What a Next.js middleware / proxy function may return. */
17
+ export type NextMiddlewareResult = NextResponse | Response | null | undefined | void;
18
+ /** A Node response (`getServerSideProps`' or an API route's `res`). */
19
+ export interface HeaderSink {
20
+ setHeader(name: string, value: string): unknown;
21
+ }
22
+ /** A JSS 22 middleware plugin (`src/lib/middleware/plugins/*`). */
23
+ export interface ParheliaPreviewPlugin {
24
+ readonly order: number;
25
+ exec(req: NextRequest, res?: NextResponse): Promise<NextResponse>;
26
+ }
27
+ export interface ParheliaPreviewNext {
28
+ readonly kit: PreviewKit;
29
+ /** The middleware / proxy function: answers the 303 or a named refusal, else lets the request through. */
30
+ readonly middleware: (request: NextRequest) => Promise<NextResponse | undefined>;
31
+ /** Runs the preview step before `inner` (an existing middleware / proxy); `inner` is not called when the step answers. */
32
+ wrap<Rest extends unknown[]>(inner: (request: NextRequest, ...rest: Rest) => Awaitable<NextMiddlewareResult>): (request: NextRequest, ...rest: Rest) => Promise<NextMiddlewareResult>;
33
+ /** The same step as a JSS 22 middleware plugin (prefer `wrap` in `proxy.ts`: later plugins cannot undo it there). */
34
+ plugin(order?: number): ParheliaPreviewPlugin;
35
+ /**
36
+ * Pages Router / route handlers / API routes: the live session of this request, or null. Pass
37
+ * `getServerSideProps`' (or an API route's) `res`: a request with a handle cookie then makes the
38
+ * response `private, no-store` (a route's own caching header would otherwise win over the middleware's).
39
+ */
40
+ readPreviewSessionFor(source: CookieSource, res?: HeaderSink): Promise<PreviewSession | null>;
41
+ /** Pages Router / route handlers / API routes: the ticket header map (`{}` without a session); `res` as above. */
42
+ previewHeadersFor(source: CookieSource, res?: HeaderSink): Promise<PreviewHeaders>;
43
+ }
44
+ export declare const createParheliaPreview: (options?: PreviewKitOptions) => ParheliaPreviewNext;
45
+ /** The instance configured from `PARHELIA_PREVIEW_URL` / `PARHELIA_PREVIEW_KEY` with the shared in-memory store. */
46
+ export declare const defaultParheliaPreview: () => ParheliaPreviewNext;
47
+ /** Middleware / proxy with the default configuration. */
48
+ export declare const parheliaPreview: (request: NextRequest) => Promise<NextResponse | undefined>;
49
+ /** Wraps an existing middleware / proxy with the default configuration. */
50
+ export declare const withParheliaPreview: <Rest extends unknown[]>(inner: (request: NextRequest, ...rest: Rest) => Awaitable<NextMiddlewareResult>) => ((request: NextRequest, ...rest: Rest) => Promise<NextMiddlewareResult>);
51
+ /** Pages Router / API routes, default configuration. */
52
+ export declare const readPreviewSessionFor: (source: CookieSource, res?: HeaderSink) => Promise<PreviewSession | null>;
53
+ /** Pages Router / API routes, default configuration. */
54
+ export declare const previewHeadersFor: (source: CookieSource, res?: HeaderSink) => Promise<PreviewHeaders>;
55
+ export type { CookieSource, PreviewSession } from "../kit.js";
56
+ export type { PreviewHeaders } from "../headers.js";
57
+ export type { PreviewKitOptions } from "../config.js";
58
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/next/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,YAAY,EAAE,KAAK,W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