@certrev/cert-block 1.2.0-canary.7 → 1.2.1-canary.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +155 -63
- package/README.md +130 -21
- package/dist/builder/card-reader-css.d.ts +14 -0
- package/dist/builder/card-reader-css.d.ts.map +1 -0
- package/dist/builder/card-reader-css.js +17 -0
- package/dist/builder/card-reader-css.js.map +1 -0
- package/dist/builder/cert-review-card.d.ts +8 -0
- package/dist/builder/cert-review-card.d.ts.map +1 -1
- package/dist/builder/cert-review-card.js +271 -41
- package/dist/builder/cert-review-card.js.map +1 -1
- package/dist/builder/delivery-runtime.d.ts +15 -1
- package/dist/builder/delivery-runtime.d.ts.map +1 -1
- package/dist/builder/delivery-runtime.js +31 -3
- package/dist/builder/delivery-runtime.js.map +1 -1
- package/dist/builder/ssr-seed.d.ts +168 -0
- package/dist/builder/ssr-seed.d.ts.map +1 -0
- package/dist/builder/ssr-seed.js +421 -0
- package/dist/builder/ssr-seed.js.map +1 -0
- package/dist/verify/cache.d.ts +39 -2
- package/dist/verify/cache.d.ts.map +1 -1
- package/dist/verify/cache.js +61 -12
- package/dist/verify/cache.js.map +1 -1
- package/dist/verify/get-verified-delivery.d.ts +28 -3
- package/dist/verify/get-verified-delivery.d.ts.map +1 -1
- package/dist/verify/get-verified-delivery.js +46 -9
- package/dist/verify/get-verified-delivery.js.map +1 -1
- package/package.json +112 -112
- package/src/builder/card-reader-css.ts +19 -0
- package/src/builder/cert-review-card.tsx +359 -56
- package/src/builder/delivery-runtime.ts +33 -3
- package/src/builder/ssr-seed.ts +496 -0
- package/src/verify/cache.ts +87 -11
- package/src/verify/get-verified-delivery.ts +77 -11
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The server render's envelope seed (1.2.0): what lets a hydrated delivery card paint with NO browser read.
|
|
3
|
+
*
|
|
4
|
+
* Through 1.1.1 the browser re-read the Delivery API for every card it hydrated, because nothing handed the server's
|
|
5
|
+
* read to it. A storefront whose Content-Security-Policy `connect-src` does not name the CertREV origin (e.l.f.'s
|
|
6
|
+
* Hydrogen store is one) blocked that read, the read settled as a suppress, and the card the server had painted
|
|
7
|
+
* vanished. So the painted face now carries the envelope it was painted from, as one attribute on its wrapper:
|
|
8
|
+
* `data-certrev-envelope` = `{ v: 1, baseUrl, externalId, design?, payload, signature?, renderDef }`. `payload` is the
|
|
9
|
+
* signed envelope's payload as the Delivery API served it, less the fields the def hides (below); `renderDef` is the
|
|
10
|
+
* def the face was painted with; `design` is the design pin the read was made with (the canary replica's `?design=N`),
|
|
11
|
+
* present only on a pinned read. React escapes the attribute like any other, so no `<script>` and no CSP `script-src`
|
|
12
|
+
* are involved.
|
|
13
|
+
*
|
|
14
|
+
* HIDDEN FIELDS ARE ABSENT FROM THE PAGE, NOT JUST FROM THE FACE. A def's `hidden` set (`reviewerPhoto`, `memo`) is the
|
|
15
|
+
* brand's statement that the page does not show those fields; a seed that carried them would put the reviewer's photo
|
|
16
|
+
* URL or the memo text in the page source all the same. So `withoutHiddenContent` removes them from the payload
|
|
17
|
+
* BEFORE the card paints and before it serializes, and both the server's face and the browser's are painted from the
|
|
18
|
+
* stripped payload (so they are identical, and a hidden memo is not on the page in either place):
|
|
19
|
+
* - `reviewerPhoto` hides `content.expert.photoUrl` and the author's `content.author.photoUrl` (the reader face paints
|
|
20
|
+
* the author's photo under the same switch);
|
|
21
|
+
* - `memo` hides `content.memo`.
|
|
22
|
+
* `display.showExpertPhoto: false` is the payload's own switch for the same photos and is stripped the same way (the
|
|
23
|
+
* portal never writes the URL for it either): both photo URLs go, as for `reviewerPhoto`, whatever the def hides.
|
|
24
|
+
* `content.expert.compensationCue` is NEVER touched: the cue is a locked disclosure no def can hide, and the face
|
|
25
|
+
* paints "Compensated expert" from it in the banner, the memo and the sidebar (the floating pill's own markup has
|
|
26
|
+
* no disclosure line, as in the portal's snippets; its modal paints the cue from the same field).
|
|
27
|
+
*
|
|
28
|
+
* THE SIGNATURE IS LEFT OUT WHENEVER ANYTHING WAS STRIPPED. The signature signs the full payload, so a payload with a
|
|
29
|
+
* field removed no longer verifies against it, and a seed that carried both would hand a verifier a pair that fails.
|
|
30
|
+
* Leaving it out costs nothing: the browser never re-checks a seed's signature (next paragraph), it re-runs only
|
|
31
|
+
* `renderVerdict` (lifecycle and subject) at its own clock, and neither reads a field the strip removes. A seed whose
|
|
32
|
+
* payload was not stripped keeps the signature, so a verifier can still check the page's HTML against the issuer key.
|
|
33
|
+
*
|
|
34
|
+
* The browser trusts a seed as far as it trusts the server HTML the seed sits in: whoever can write that HTML can
|
|
35
|
+
* already write any card they like, so the signature is NOT re-verified here (which would make hydration async, and
|
|
36
|
+
* Ed25519 in WebCrypto is not in every browser). The client still re-runs the lifecycle and subject policy
|
|
37
|
+
* (`renderVerdict`) at its own clock once hydration is done; `cert-review-card.tsx` does that.
|
|
38
|
+
*
|
|
39
|
+
* A PINNED CARD TAKES ONLY A SEED WITH THE SAME PIN (and an unpinned card only an unpinned one): the pin is part of
|
|
40
|
+
* the seed's key, as it is part of the read's, so the canary replica's `?design=7` card never paints the design the
|
|
41
|
+
* page carried for another version.
|
|
42
|
+
*
|
|
43
|
+
* WHEN THE SERVER HAD NO ENVELOPE TO PAINT (1.2.0) the same attribute carries a fallback record instead of a seed:
|
|
44
|
+
* `{ v: 1, baseUrl, externalId, design?, face }`, where `face` is `'options'` (CertREV could not be reached, so the
|
|
45
|
+
* server painted the block's own options face) or `'none'` (the server painted nothing: revoked, expired, unverifiable,
|
|
46
|
+
* for another entry). A browser that renders the card again (hydration, or React's client re-render after a hydration
|
|
47
|
+
* error elsewhere on the page) paints what the record says, so it neither reads the Delivery API nor shows a card the
|
|
48
|
+
* server withheld. A record holds no payload, so `parseSeed` never takes one for a seed. A `'none'` record sits on a
|
|
49
|
+
* `hidden` element with nothing in it.
|
|
50
|
+
*
|
|
51
|
+
* React-free and browser-only in effect: with no `document` (a server) `pageSeedFor` finds nothing, so a server never
|
|
52
|
+
* reads or keeps a seed and a multi-tenant render process holds nothing per page.
|
|
53
|
+
*/
|
|
54
|
+
import type { CertPayload, CertSignature } from '../contract/kernel.js';
|
|
55
|
+
import { type DesignPin } from '../verify/get-verified-delivery.js';
|
|
56
|
+
import type { CertChromeRenderDef } from './cert-chrome-data.js';
|
|
57
|
+
export declare const SEED_ATTRIBUTE = "data-certrev-envelope";
|
|
58
|
+
export interface DeliverySeed {
|
|
59
|
+
readonly baseUrl: string;
|
|
60
|
+
readonly externalId: string;
|
|
61
|
+
/** The design pin the read was made with; absent on an unpinned read (every production brand). */
|
|
62
|
+
readonly design?: DesignPin;
|
|
63
|
+
/** The payload as painted: with every field the def hides removed (`withoutHiddenContent`). */
|
|
64
|
+
readonly payload: CertPayload;
|
|
65
|
+
/**
|
|
66
|
+
* The envelope's signature as served; absent when the payload was stripped (it no longer verifies), and when a
|
|
67
|
+
* cache was filled by hand (a test, a custom cache).
|
|
68
|
+
*/
|
|
69
|
+
readonly signature?: CertSignature;
|
|
70
|
+
readonly renderDef: CertChromeRenderDef | null;
|
|
71
|
+
}
|
|
72
|
+
/** A seed as read from the page: the parsed seed and the attribute's exact text (re-rendered verbatim on hydration). */
|
|
73
|
+
export interface PageSeed {
|
|
74
|
+
readonly seed: DeliverySeed;
|
|
75
|
+
readonly raw: string;
|
|
76
|
+
}
|
|
77
|
+
/** What the server painted with no verified envelope: the block's options face, or nothing. */
|
|
78
|
+
export type FallbackFace = 'options' | 'none';
|
|
79
|
+
/** The record a server writes where it had no envelope to paint (the file header). */
|
|
80
|
+
export interface DeliveryFallback {
|
|
81
|
+
readonly baseUrl: string;
|
|
82
|
+
readonly externalId: string;
|
|
83
|
+
readonly design?: DesignPin;
|
|
84
|
+
readonly face: FallbackFace;
|
|
85
|
+
}
|
|
86
|
+
/** A fallback record as read from the page, with the attribute's exact text. */
|
|
87
|
+
export interface PageFallback {
|
|
88
|
+
readonly fallback: DeliveryFallback;
|
|
89
|
+
readonly raw: string;
|
|
90
|
+
}
|
|
91
|
+
/** Whatever the server wrote for one placement: a seed or a fallback record. */
|
|
92
|
+
export type PageRecord = PageSeed | PageFallback;
|
|
93
|
+
/**
|
|
94
|
+
* The payload with the named people's photo URLs removed (`null`); the same object when neither had one. The card uses
|
|
95
|
+
* it for a photo the browser could not load (a brand's CSP `img-src`, a 404), so the face repaints with the initials.
|
|
96
|
+
*/
|
|
97
|
+
export declare function withoutPhotos(payload: CertPayload, people: readonly ('expert' | 'author')[]): CertPayload;
|
|
98
|
+
/**
|
|
99
|
+
* The payload with every content field the def's `hidden` set controls removed, and whether anything was; the two
|
|
100
|
+
* photo URLs go as well when the payload's own `display.showExpertPhoto` is `false` (exactly `false`, as the reader
|
|
101
|
+
* face reads it: absent or `null` shows the photo).
|
|
102
|
+
*
|
|
103
|
+
* Only the ids in `HIDEABLE_FIELDS` count (a def may list others; the faces ignore them, so they hide nothing). A
|
|
104
|
+
* removed text field becomes `null`, so the content keeps the shape the contract types give it and every face reads it
|
|
105
|
+
* as absent. Nothing but those fields changes: the subject and lifecycle (what `renderVerdict` reads), the cue, the
|
|
106
|
+
* dates, the links and the names are the payload's own. Never throws on a hostile shape: a payload whose `expert` or
|
|
107
|
+
* `author` is not an object has no photo to strip.
|
|
108
|
+
*/
|
|
109
|
+
export declare function withoutHiddenContent(payload: CertPayload, renderDef: CertChromeRenderDef | null): {
|
|
110
|
+
readonly payload: CertPayload;
|
|
111
|
+
readonly stripped: boolean;
|
|
112
|
+
};
|
|
113
|
+
/**
|
|
114
|
+
* The seed for a verified read: the payload stripped of what the def hides, and the signature only when nothing was
|
|
115
|
+
* stripped. The card paints from this seed's payload, on the server and in the browser alike.
|
|
116
|
+
*/
|
|
117
|
+
export declare function seedFor(read: {
|
|
118
|
+
readonly baseUrl: string;
|
|
119
|
+
readonly externalId: string;
|
|
120
|
+
readonly design?: DesignPin;
|
|
121
|
+
readonly payload: CertPayload;
|
|
122
|
+
readonly signature?: CertSignature;
|
|
123
|
+
readonly renderDef: CertChromeRenderDef | null;
|
|
124
|
+
}): DeliverySeed;
|
|
125
|
+
export declare function serializeSeed(seed: DeliverySeed): string;
|
|
126
|
+
export declare function serializeFallback(fallback: DeliveryFallback): string;
|
|
127
|
+
/** The seed in one attribute value, or null for anything that is not one (never throws). */
|
|
128
|
+
export declare function parseSeed(raw: string): DeliverySeed | null;
|
|
129
|
+
/** A fallback record in one attribute value, or null for anything that is not one (a seed included; never throws). */
|
|
130
|
+
export declare function parseFallback(raw: string): DeliveryFallback | null;
|
|
131
|
+
/**
|
|
132
|
+
* The record the server wrote for this placement and pin: its seed, or its fallback record. By default: from the map,
|
|
133
|
+
* else from one scan of the document (which also records every other one on the page). With `live`, the map is not
|
|
134
|
+
* consulted: the document is scanned and decides, so what a hydrating card learns is what the server HTML in front of
|
|
135
|
+
* it carries, not what an earlier page in this process left behind. `undefined` when the page carries none, and always
|
|
136
|
+
* on a server.
|
|
137
|
+
*/
|
|
138
|
+
export declare function pageRecordFor(baseUrl: string, externalId: string, design?: DesignPin, options?: {
|
|
139
|
+
readonly live?: boolean;
|
|
140
|
+
}): PageRecord | undefined;
|
|
141
|
+
/** `pageRecordFor`, seeds only: the seed the server painted for this placement and pin. */
|
|
142
|
+
export declare function pageSeedFor(baseUrl: string, externalId: string, design?: DesignPin, options?: {
|
|
143
|
+
readonly live?: boolean;
|
|
144
|
+
}): PageSeed | undefined;
|
|
145
|
+
/**
|
|
146
|
+
* Whether the live document holds server-rendered React HTML: any Suspense boundary marker. The delivery card sits in
|
|
147
|
+
* a `<Suspense>` of its own, so a server render of one always leaves a marker, a card the server painted nothing for
|
|
148
|
+
* (revoked, expired, unreachable) included, and a client render never does. This is how a card that is hydrating tells
|
|
149
|
+
* a browser hydrating server HTML (the document holds it) from a server render that merely runs where a `document`
|
|
150
|
+
* exists (a test's jsdom, a shim): there the document does not hold the HTML being produced.
|
|
151
|
+
*/
|
|
152
|
+
export declare function pageHoldsServerHtml(): boolean;
|
|
153
|
+
/**
|
|
154
|
+
* Start watching for streamed records, once per page and only while the document is loading; a no-op otherwise. The
|
|
155
|
+
* card calls it as it renders, not from an effect: React's client render of the whole document removes the server's
|
|
156
|
+
* `<html>` in the commit that follows that render, so the watch must hold the element before then.
|
|
157
|
+
*/
|
|
158
|
+
export declare function watchStreamedRecords(): void;
|
|
159
|
+
/** `useSyncExternalStore`'s subscribe for a waiting card: told when a streamed record is kept, and when the page has loaded. */
|
|
160
|
+
export declare function subscribeStreamedRecords(listener: () => void): () => void;
|
|
161
|
+
/**
|
|
162
|
+
* A waiting card's answer: the record for its placement and pin once the page holds one (`pageRecordFor`), else
|
|
163
|
+
* `'pending'` while a watch runs and the document is still loading, else `'done'`: the page loaded with no record.
|
|
164
|
+
*/
|
|
165
|
+
export declare function streamedRecordFor(baseUrl: string, externalId: string, design?: DesignPin): PageRecord | 'pending' | 'done';
|
|
166
|
+
/** Test seam: forget every seed (a new page), and stop any watch for streamed records. */
|
|
167
|
+
export declare function forgetPageSeedsForTests(): void;
|
|
168
|
+
//# sourceMappingURL=ssr-seed.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ssr-seed.d.ts","sourceRoot":"","sources":["../../src/builder/ssr-seed.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AAGH,OAAO,KAAK,EAAe,WAAW,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AACpF,OAAO,EAAE,KAAK,SAAS,EAAkC,MAAM,oCAAoC,CAAA;AACnG,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAEhE,eAAO,MAAM,cAAc,0BAA0B,CAAA;AAErD,MAAM,WAAW,YAAY;IAC5B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,kGAAkG;IAClG,QAAQ,CAAC,MAAM,CAAC,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wBAAwB,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAQzE;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAChC,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,MAAM,CAAC,EAAE,SAAS,GAChB,UAAU,GAAG,SAAS,GAAG,MAAM,CAIjC;AAED,0FAA0F;AAC1F,wBAAgB,uBAAuB,IAAI,IAAI,CAO9C"}
|
|
@@ -0,0 +1,421 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The server render's envelope seed (1.2.0): what lets a hydrated delivery card paint with NO browser read.
|
|
3
|
+
*
|
|
4
|
+
* Through 1.1.1 the browser re-read the Delivery API for every card it hydrated, because nothing handed the server's
|
|
5
|
+
* read to it. A storefront whose Content-Security-Policy `connect-src` does not name the CertREV origin (e.l.f.'s
|
|
6
|
+
* Hydrogen store is one) blocked that read, the read settled as a suppress, and the card the server had painted
|
|
7
|
+
* vanished. So the painted face now carries the envelope it was painted from, as one attribute on its wrapper:
|
|
8
|
+
* `data-certrev-envelope` = `{ v: 1, baseUrl, externalId, design?, payload, signature?, renderDef }`. `payload` is the
|
|
9
|
+
* signed envelope's payload as the Delivery API served it, less the fields the def hides (below); `renderDef` is the
|
|
10
|
+
* def the face was painted with; `design` is the design pin the read was made with (the canary replica's `?design=N`),
|
|
11
|
+
* present only on a pinned read. React escapes the attribute like any other, so no `<script>` and no CSP `script-src`
|
|
12
|
+
* are involved.
|
|
13
|
+
*
|
|
14
|
+
* HIDDEN FIELDS ARE ABSENT FROM THE PAGE, NOT JUST FROM THE FACE. A def's `hidden` set (`reviewerPhoto`, `memo`) is the
|
|
15
|
+
* brand's statement that the page does not show those fields; a seed that carried them would put the reviewer's photo
|
|
16
|
+
* URL or the memo text in the page source all the same. So `withoutHiddenContent` removes them from the payload
|
|
17
|
+
* BEFORE the card paints and before it serializes, and both the server's face and the browser's are painted from the
|
|
18
|
+
* stripped payload (so they are identical, and a hidden memo is not on the page in either place):
|
|
19
|
+
* - `reviewerPhoto` hides `content.expert.photoUrl` and the author's `content.author.photoUrl` (the reader face paints
|
|
20
|
+
* the author's photo under the same switch);
|
|
21
|
+
* - `memo` hides `content.memo`.
|
|
22
|
+
* `display.showExpertPhoto: false` is the payload's own switch for the same photos and is stripped the same way (the
|
|
23
|
+
* portal never writes the URL for it either): both photo URLs go, as for `reviewerPhoto`, whatever the def hides.
|
|
24
|
+
* `content.expert.compensationCue` is NEVER touched: the cue is a locked disclosure no def can hide, and the face
|
|
25
|
+
* paints "Compensated expert" from it in the banner, the memo and the sidebar (the floating pill's own markup has
|
|
26
|
+
* no disclosure line, as in the portal's snippets; its modal paints the cue from the same field).
|
|
27
|
+
*
|
|
28
|
+
* THE SIGNATURE IS LEFT OUT WHENEVER ANYTHING WAS STRIPPED. The signature signs the full payload, so a payload with a
|
|
29
|
+
* field removed no longer verifies against it, and a seed that carried both would hand a verifier a pair that fails.
|
|
30
|
+
* Leaving it out costs nothing: the browser never re-checks a seed's signature (next paragraph), it re-runs only
|
|
31
|
+
* `renderVerdict` (lifecycle and subject) at its own clock, and neither reads a field the strip removes. A seed whose
|
|
32
|
+
* payload was not stripped keeps the signature, so a verifier can still check the page's HTML against the issuer key.
|
|
33
|
+
*
|
|
34
|
+
* The browser trusts a seed as far as it trusts the server HTML the seed sits in: whoever can write that HTML can
|
|
35
|
+
* already write any card they like, so the signature is NOT re-verified here (which would make hydration async, and
|
|
36
|
+
* Ed25519 in WebCrypto is not in every browser). The client still re-runs the lifecycle and subject policy
|
|
37
|
+
* (`renderVerdict`) at its own clock once hydration is done; `cert-review-card.tsx` does that.
|
|
38
|
+
*
|
|
39
|
+
* A PINNED CARD TAKES ONLY A SEED WITH THE SAME PIN (and an unpinned card only an unpinned one): the pin is part of
|
|
40
|
+
* the seed's key, as it is part of the read's, so the canary replica's `?design=7` card never paints the design the
|
|
41
|
+
* page carried for another version.
|
|
42
|
+
*
|
|
43
|
+
* WHEN THE SERVER HAD NO ENVELOPE TO PAINT (1.2.0) the same attribute carries a fallback record instead of a seed:
|
|
44
|
+
* `{ v: 1, baseUrl, externalId, design?, face }`, where `face` is `'options'` (CertREV could not be reached, so the
|
|
45
|
+
* server painted the block's own options face) or `'none'` (the server painted nothing: revoked, expired, unverifiable,
|
|
46
|
+
* for another entry). A browser that renders the card again (hydration, or React's client re-render after a hydration
|
|
47
|
+
* error elsewhere on the page) paints what the record says, so it neither reads the Delivery API nor shows a card the
|
|
48
|
+
* server withheld. A record holds no payload, so `parseSeed` never takes one for a seed. A `'none'` record sits on a
|
|
49
|
+
* `hidden` element with nothing in it.
|
|
50
|
+
*
|
|
51
|
+
* React-free and browser-only in effect: with no `document` (a server) `pageSeedFor` finds nothing, so a server never
|
|
52
|
+
* reads or keeps a seed and a multi-tenant render process holds nothing per page.
|
|
53
|
+
*/
|
|
54
|
+
import { HIDEABLE_FIELDS } from '../components/render-def.js';
|
|
55
|
+
import { parseDesignPin, parseRenderDef } from '../verify/get-verified-delivery.js';
|
|
56
|
+
export const SEED_ATTRIBUTE = 'data-certrev-envelope';
|
|
57
|
+
const isRecord = (v) => typeof v === 'object' && v !== null && !Array.isArray(v);
|
|
58
|
+
/** A value worth hiding: anything but nothing (absent, null, the empty string). */
|
|
59
|
+
const hasValue = (v) => v !== undefined && v !== null && v !== '';
|
|
60
|
+
/**
|
|
61
|
+
* The payload with the named people's photo URLs removed (`null`); the same object when neither had one. The card uses
|
|
62
|
+
* it for a photo the browser could not load (a brand's CSP `img-src`, a 404), so the face repaints with the initials.
|
|
63
|
+
*/
|
|
64
|
+
export function withoutPhotos(payload, people) {
|
|
65
|
+
let content = { ...payload.content };
|
|
66
|
+
let stripped = false;
|
|
67
|
+
for (const person of people) {
|
|
68
|
+
const fields = content[person];
|
|
69
|
+
if (isRecord(fields) && hasValue(fields.photoUrl)) {
|
|
70
|
+
content = { ...content, [person]: { ...fields, photoUrl: null } };
|
|
71
|
+
stripped = true;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return stripped ? { ...payload, content: content } : payload;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* The payload with every content field the def's `hidden` set controls removed, and whether anything was; the two
|
|
78
|
+
* photo URLs go as well when the payload's own `display.showExpertPhoto` is `false` (exactly `false`, as the reader
|
|
79
|
+
* face reads it: absent or `null` shows the photo).
|
|
80
|
+
*
|
|
81
|
+
* Only the ids in `HIDEABLE_FIELDS` count (a def may list others; the faces ignore them, so they hide nothing). A
|
|
82
|
+
* removed text field becomes `null`, so the content keeps the shape the contract types give it and every face reads it
|
|
83
|
+
* as absent. Nothing but those fields changes: the subject and lifecycle (what `renderVerdict` reads), the cue, the
|
|
84
|
+
* dates, the links and the names are the payload's own. Never throws on a hostile shape: a payload whose `expert` or
|
|
85
|
+
* `author` is not an object has no photo to strip.
|
|
86
|
+
*/
|
|
87
|
+
export function withoutHiddenContent(payload, renderDef) {
|
|
88
|
+
const hidden = (renderDef?.hidden ?? []).filter((id) => HIDEABLE_FIELDS.includes(id));
|
|
89
|
+
const display = payload.content?.display;
|
|
90
|
+
const photoOff = isRecord(display) && display.showExpertPhoto === false;
|
|
91
|
+
if (hidden.length === 0 && !photoOff)
|
|
92
|
+
return { payload, stripped: false };
|
|
93
|
+
let next = photoOff || hidden.includes('reviewerPhoto') ? withoutPhotos(payload, ['expert', 'author']) : payload;
|
|
94
|
+
if (hidden.includes('memo') && hasValue(next.content.memo)) {
|
|
95
|
+
next = { ...next, content: { ...next.content, memo: null } };
|
|
96
|
+
}
|
|
97
|
+
return { payload: next, stripped: next !== payload };
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* The seed for a verified read: the payload stripped of what the def hides, and the signature only when nothing was
|
|
101
|
+
* stripped. The card paints from this seed's payload, on the server and in the browser alike.
|
|
102
|
+
*/
|
|
103
|
+
export function seedFor(read) {
|
|
104
|
+
const { payload, stripped } = withoutHiddenContent(read.payload, read.renderDef);
|
|
105
|
+
return {
|
|
106
|
+
baseUrl: read.baseUrl,
|
|
107
|
+
externalId: read.externalId,
|
|
108
|
+
...(read.design ? { design: read.design } : {}),
|
|
109
|
+
payload,
|
|
110
|
+
...(read.signature && !stripped ? { signature: read.signature } : {}),
|
|
111
|
+
renderDef: read.renderDef,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
const serializedPin = (design) => design ? { design: { version: design.version, ...(design.brand === undefined ? {} : { brand: design.brand }) } } : {};
|
|
115
|
+
export function serializeSeed(seed) {
|
|
116
|
+
return JSON.stringify({
|
|
117
|
+
v: 1,
|
|
118
|
+
baseUrl: seed.baseUrl,
|
|
119
|
+
externalId: seed.externalId,
|
|
120
|
+
...serializedPin(seed.design),
|
|
121
|
+
payload: seed.payload,
|
|
122
|
+
...(seed.signature ? { signature: seed.signature } : {}),
|
|
123
|
+
renderDef: seed.renderDef,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
export function serializeFallback(fallback) {
|
|
127
|
+
return JSON.stringify({
|
|
128
|
+
v: 1,
|
|
129
|
+
baseUrl: fallback.baseUrl,
|
|
130
|
+
externalId: fallback.externalId,
|
|
131
|
+
...serializedPin(fallback.design),
|
|
132
|
+
face: fallback.face,
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
/** A pin a record names, judged by the same grammar the card's own pin is: undefined when absent, null when bad. */
|
|
136
|
+
function parsedPin(design) {
|
|
137
|
+
if (design === undefined)
|
|
138
|
+
return undefined;
|
|
139
|
+
const judged = isRecord(design)
|
|
140
|
+
? parseDesignPin({ design: design.version, ...(design.brand === undefined ? {} : { designBrand: design.brand }) })
|
|
141
|
+
: 'invalid';
|
|
142
|
+
return judged === 'invalid' || judged === undefined ? null : judged;
|
|
143
|
+
}
|
|
144
|
+
/** The seed in one attribute value, or null for anything that is not one (never throws). */
|
|
145
|
+
export function parseSeed(raw) {
|
|
146
|
+
let value;
|
|
147
|
+
try {
|
|
148
|
+
value = JSON.parse(raw);
|
|
149
|
+
}
|
|
150
|
+
catch {
|
|
151
|
+
return null;
|
|
152
|
+
}
|
|
153
|
+
if (!isRecord(value) || value.v !== 1)
|
|
154
|
+
return null;
|
|
155
|
+
const { baseUrl, externalId, design, payload, signature, renderDef } = value;
|
|
156
|
+
if (typeof baseUrl !== 'string' || typeof externalId !== 'string')
|
|
157
|
+
return null;
|
|
158
|
+
if (!isRecord(payload) || !isRecord(payload.subject) || !isRecord(payload.lifecycle) || !isRecord(payload.content)) {
|
|
159
|
+
return null;
|
|
160
|
+
}
|
|
161
|
+
// A pin the seed names is judged by the same grammar the card's own pin is; one that fails it is not a seed.
|
|
162
|
+
const pin = parsedPin(design);
|
|
163
|
+
if (pin === null)
|
|
164
|
+
return null;
|
|
165
|
+
return {
|
|
166
|
+
baseUrl,
|
|
167
|
+
externalId,
|
|
168
|
+
...(pin ? { design: pin } : {}),
|
|
169
|
+
payload: payload,
|
|
170
|
+
...(isRecord(signature) ? { signature: signature } : {}),
|
|
171
|
+
renderDef: parseRenderDef(renderDef),
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
/** A fallback record in one attribute value, or null for anything that is not one (a seed included; never throws). */
|
|
175
|
+
export function parseFallback(raw) {
|
|
176
|
+
let value;
|
|
177
|
+
try {
|
|
178
|
+
value = JSON.parse(raw);
|
|
179
|
+
}
|
|
180
|
+
catch {
|
|
181
|
+
return null;
|
|
182
|
+
}
|
|
183
|
+
if (!isRecord(value) || value.v !== 1 || 'payload' in value)
|
|
184
|
+
return null;
|
|
185
|
+
const { baseUrl, externalId, design, face } = value;
|
|
186
|
+
if (typeof baseUrl !== 'string' || typeof externalId !== 'string')
|
|
187
|
+
return null;
|
|
188
|
+
if (face !== 'options' && face !== 'none')
|
|
189
|
+
return null;
|
|
190
|
+
const pin = parsedPin(design);
|
|
191
|
+
if (pin === null)
|
|
192
|
+
return null;
|
|
193
|
+
return { baseUrl, externalId, ...(pin ? { design: pin } : {}), face };
|
|
194
|
+
}
|
|
195
|
+
/** One placement's key: the origin, the entry and the pin (the read's own key, so a pin never shares a seed). */
|
|
196
|
+
function seedKey(baseUrl, externalId, design) {
|
|
197
|
+
return design ? `${baseUrl}|${externalId}|design=${design.version}|${design.brand ?? ''}` : `${baseUrl}|${externalId}`;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* The seeds (and fallback records) this page's server HTML carried, by placement, for the page's lifetime: a card
|
|
201
|
+
* mounted later by a client-side render (an in-app navigation back to a server-rendered article, or React's client
|
|
202
|
+
* re-render after a hydration error) paints what the server painted, as the hydrated card it replaces would have.
|
|
203
|
+
*/
|
|
204
|
+
const pageSeeds = new Map();
|
|
205
|
+
const recordKey = (record) => {
|
|
206
|
+
const r = 'seed' in record ? record.seed : record.fallback;
|
|
207
|
+
return seedKey(r.baseUrl, r.externalId, r.design);
|
|
208
|
+
};
|
|
209
|
+
/** The record one element's attribute carries: a seed, a fallback record, or null for anything else. */
|
|
210
|
+
function recordOf(el) {
|
|
211
|
+
const raw = el.getAttribute(SEED_ATTRIBUTE);
|
|
212
|
+
if (!raw)
|
|
213
|
+
return null;
|
|
214
|
+
const seed = parseSeed(raw);
|
|
215
|
+
if (seed)
|
|
216
|
+
return { seed, raw };
|
|
217
|
+
const fallback = parseFallback(raw);
|
|
218
|
+
return fallback ? { fallback, raw } : null;
|
|
219
|
+
}
|
|
220
|
+
/** Every seed and fallback record under `root` (the root element itself included), in document order. */
|
|
221
|
+
function scanRecords(root) {
|
|
222
|
+
const found = [];
|
|
223
|
+
const elements = Array.from(root.querySelectorAll(`[${SEED_ATTRIBUTE}]`));
|
|
224
|
+
if (root.nodeType === 1 && root.hasAttribute(SEED_ATTRIBUTE))
|
|
225
|
+
elements.unshift(root);
|
|
226
|
+
for (const el of elements) {
|
|
227
|
+
const record = recordOf(el);
|
|
228
|
+
if (record)
|
|
229
|
+
found.push(record);
|
|
230
|
+
}
|
|
231
|
+
return found;
|
|
232
|
+
}
|
|
233
|
+
/** Every seed and fallback record the live document carries, in document order. */
|
|
234
|
+
function scanDocument() {
|
|
235
|
+
return scanRecords(document);
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* The record the server wrote for this placement and pin: its seed, or its fallback record. By default: from the map,
|
|
239
|
+
* else from one scan of the document (which also records every other one on the page). With `live`, the map is not
|
|
240
|
+
* consulted: the document is scanned and decides, so what a hydrating card learns is what the server HTML in front of
|
|
241
|
+
* it carries, not what an earlier page in this process left behind. `undefined` when the page carries none, and always
|
|
242
|
+
* on a server.
|
|
243
|
+
*/
|
|
244
|
+
export function pageRecordFor(baseUrl, externalId, design, options = {}) {
|
|
245
|
+
const key = seedKey(baseUrl, externalId, design);
|
|
246
|
+
if (typeof document === 'undefined')
|
|
247
|
+
return undefined;
|
|
248
|
+
const known = options.live ? undefined : pageSeeds.get(key);
|
|
249
|
+
if (known)
|
|
250
|
+
return known;
|
|
251
|
+
let inDocument = false;
|
|
252
|
+
for (const found of scanDocument()) {
|
|
253
|
+
const k = recordKey(found);
|
|
254
|
+
if (k === key)
|
|
255
|
+
inDocument = true;
|
|
256
|
+
if (options.live || !pageSeeds.has(k))
|
|
257
|
+
pageSeeds.set(k, found);
|
|
258
|
+
}
|
|
259
|
+
// A live read answers for the document alone: a record an earlier page left in the map is not one this page carries.
|
|
260
|
+
return options.live && !inDocument ? undefined : pageSeeds.get(key);
|
|
261
|
+
}
|
|
262
|
+
/** `pageRecordFor`, seeds only: the seed the server painted for this placement and pin. */
|
|
263
|
+
export function pageSeedFor(baseUrl, externalId, design, options = {}) {
|
|
264
|
+
const record = pageRecordFor(baseUrl, externalId, design, options);
|
|
265
|
+
return record && 'seed' in record ? record : undefined;
|
|
266
|
+
}
|
|
267
|
+
/** A Suspense boundary's comment marker as React's server render writes it: `$` (done), `$?` (pending), `$!`, `$~`. */
|
|
268
|
+
const BOUNDARY_MARKER = /^\$[?!~]?$/;
|
|
269
|
+
/**
|
|
270
|
+
* Whether the live document holds server-rendered React HTML: any Suspense boundary marker. The delivery card sits in
|
|
271
|
+
* a `<Suspense>` of its own, so a server render of one always leaves a marker, a card the server painted nothing for
|
|
272
|
+
* (revoked, expired, unreachable) included, and a client render never does. This is how a card that is hydrating tells
|
|
273
|
+
* a browser hydrating server HTML (the document holds it) from a server render that merely runs where a `document`
|
|
274
|
+
* exists (a test's jsdom, a shim): there the document does not hold the HTML being produced.
|
|
275
|
+
*/
|
|
276
|
+
export function pageHoldsServerHtml() {
|
|
277
|
+
if (typeof document === 'undefined' || !document.documentElement)
|
|
278
|
+
return false;
|
|
279
|
+
const walker = document.createTreeWalker(document.documentElement, 128 /* NodeFilter.SHOW_COMMENT */);
|
|
280
|
+
for (let node = walker.nextNode(); node; node = walker.nextNode()) {
|
|
281
|
+
if (BOUNDARY_MARKER.test(node.data))
|
|
282
|
+
return true;
|
|
283
|
+
}
|
|
284
|
+
return false;
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* RECORDS THAT STREAM IN AFTER THE CARD RENDERS (1.2.1). A streaming server (Hydrogen and React Router 7 stream every
|
|
288
|
+
* visitor that is not a crawler) sends the page's shell first, and a card whose read is still running after it, in a
|
|
289
|
+
* hidden `<div id="S:n">` past `</html>` that React's inline `$RC` script moves into the card's place. The browser
|
|
290
|
+
* starts hydrating as soon as its module script loads, which can be before that part arrives. React then waits for
|
|
291
|
+
* the card's boundary, but two things on a real page make it give up the server HTML and render the card on the
|
|
292
|
+
* client before the record is in the document:
|
|
293
|
+
* - an update to the waiting boundary (a parent that sets state as it mounts): React renders the boundary on the
|
|
294
|
+
* client (React error #421) and deletes its markers, so `$RC` finds no place and drops the streamed part;
|
|
295
|
+
* - a mismatch above it (a page `<style>` whose text the server escaped, #418/#425): React renders the whole document
|
|
296
|
+
* on the client (#423). It removes the server's `<html>` element and appends its own, and the parser writes the
|
|
297
|
+
* rest of the stream into the removed element, where no script runs and no query of the document looks.
|
|
298
|
+
* Either way the card rendered on the client with no record in front of it, and through 1.2.0 painted the options face
|
|
299
|
+
* at once (nothing, for a block with no options) and never looked again: the record the server wrote arrived a moment
|
|
300
|
+
* later and was thrown away. Now a card the client renders while the document is still loading, with no record for its
|
|
301
|
+
* placement, waits (`StreamedRecordCard` in `cert-review-card.tsx`): `watchStreamedRecords` watches the document, and
|
|
302
|
+
* the server's `<html>` element should React remove it, for records added while the page loads, keeps each new one
|
|
303
|
+
* as the scan does (a placement already known keeps its record), and tells the waiting cards. When the page has
|
|
304
|
+
* loaded it scans both once more, lets the removed element go and stops. A card whose record never came paints what a
|
|
305
|
+
* client mount paints. A page that never renders a card this way never starts a watch.
|
|
306
|
+
*/
|
|
307
|
+
/**
|
|
308
|
+
* The document element the page was still parsing when this module loaded: the server's `<html>`, which a card first
|
|
309
|
+
* rendered after React replaced it could not otherwise find. Held weakly, so a page that never watches keeps nothing.
|
|
310
|
+
*/
|
|
311
|
+
const rootWhileLoading = typeof document !== 'undefined' &&
|
|
312
|
+
document.readyState === 'loading' &&
|
|
313
|
+
document.documentElement &&
|
|
314
|
+
typeof WeakRef === 'function'
|
|
315
|
+
? new WeakRef(document.documentElement)
|
|
316
|
+
: null;
|
|
317
|
+
let streamWatch = null;
|
|
318
|
+
/** Keep every record under `node` whose placement the map does not hold yet; true when one was new. */
|
|
319
|
+
function keepNewRecords(node) {
|
|
320
|
+
if (node.nodeType !== 1)
|
|
321
|
+
return false;
|
|
322
|
+
let kept = false;
|
|
323
|
+
for (const record of scanRecords(node)) {
|
|
324
|
+
const key = recordKey(record);
|
|
325
|
+
if (pageSeeds.has(key))
|
|
326
|
+
continue;
|
|
327
|
+
pageSeeds.set(key, record);
|
|
328
|
+
kept = true;
|
|
329
|
+
}
|
|
330
|
+
return kept;
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* Start watching for streamed records, once per page and only while the document is loading; a no-op otherwise. The
|
|
334
|
+
* card calls it as it renders, not from an effect: React's client render of the whole document removes the server's
|
|
335
|
+
* `<html>` in the commit that follows that render, so the watch must hold the element before then.
|
|
336
|
+
*/
|
|
337
|
+
export function watchStreamedRecords() {
|
|
338
|
+
if (streamWatch || typeof document === 'undefined' || document.readyState !== 'loading')
|
|
339
|
+
return;
|
|
340
|
+
const roots = [];
|
|
341
|
+
for (const root of [rootWhileLoading?.deref(), document.documentElement]) {
|
|
342
|
+
if (root && !roots.includes(root))
|
|
343
|
+
roots.push(root);
|
|
344
|
+
}
|
|
345
|
+
const listeners = new Set();
|
|
346
|
+
const notify = () => {
|
|
347
|
+
for (const listener of Array.from(listeners))
|
|
348
|
+
listener();
|
|
349
|
+
};
|
|
350
|
+
const keepAdded = (mutations) => {
|
|
351
|
+
let kept = false;
|
|
352
|
+
for (const mutation of mutations) {
|
|
353
|
+
for (const node of Array.from(mutation.addedNodes))
|
|
354
|
+
if (keepNewRecords(node))
|
|
355
|
+
kept = true;
|
|
356
|
+
}
|
|
357
|
+
return kept;
|
|
358
|
+
};
|
|
359
|
+
const observer = typeof MutationObserver === 'function'
|
|
360
|
+
? new MutationObserver((mutations) => {
|
|
361
|
+
if (keepAdded(mutations))
|
|
362
|
+
notify();
|
|
363
|
+
})
|
|
364
|
+
: null;
|
|
365
|
+
observer?.observe(document, { childList: true, subtree: true });
|
|
366
|
+
for (const root of roots)
|
|
367
|
+
observer?.observe(root, { childList: true, subtree: true });
|
|
368
|
+
const watch = {
|
|
369
|
+
observer,
|
|
370
|
+
roots,
|
|
371
|
+
listeners,
|
|
372
|
+
loaded: false,
|
|
373
|
+
onLoaded: () => {
|
|
374
|
+
document.removeEventListener('DOMContentLoaded', watch.onLoaded);
|
|
375
|
+
if (observer) {
|
|
376
|
+
keepAdded(observer.takeRecords());
|
|
377
|
+
observer.disconnect();
|
|
378
|
+
}
|
|
379
|
+
if (document.documentElement)
|
|
380
|
+
keepNewRecords(document.documentElement);
|
|
381
|
+
for (const root of roots)
|
|
382
|
+
keepNewRecords(root);
|
|
383
|
+
roots.length = 0;
|
|
384
|
+
watch.loaded = true;
|
|
385
|
+
notify();
|
|
386
|
+
},
|
|
387
|
+
};
|
|
388
|
+
document.addEventListener('DOMContentLoaded', watch.onLoaded);
|
|
389
|
+
streamWatch = watch;
|
|
390
|
+
}
|
|
391
|
+
/** `useSyncExternalStore`'s subscribe for a waiting card: told when a streamed record is kept, and when the page has loaded. */
|
|
392
|
+
export function subscribeStreamedRecords(listener) {
|
|
393
|
+
watchStreamedRecords();
|
|
394
|
+
const watch = streamWatch;
|
|
395
|
+
if (!watch || watch.loaded)
|
|
396
|
+
return () => { };
|
|
397
|
+
watch.listeners.add(listener);
|
|
398
|
+
return () => {
|
|
399
|
+
watch.listeners.delete(listener);
|
|
400
|
+
};
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* A waiting card's answer: the record for its placement and pin once the page holds one (`pageRecordFor`), else
|
|
404
|
+
* `'pending'` while a watch runs and the document is still loading, else `'done'`: the page loaded with no record.
|
|
405
|
+
*/
|
|
406
|
+
export function streamedRecordFor(baseUrl, externalId, design) {
|
|
407
|
+
const record = pageRecordFor(baseUrl, externalId, design);
|
|
408
|
+
if (record)
|
|
409
|
+
return record;
|
|
410
|
+
return streamWatch && !streamWatch.loaded ? 'pending' : 'done';
|
|
411
|
+
}
|
|
412
|
+
/** Test seam: forget every seed (a new page), and stop any watch for streamed records. */
|
|
413
|
+
export function forgetPageSeedsForTests() {
|
|
414
|
+
pageSeeds.clear();
|
|
415
|
+
if (streamWatch) {
|
|
416
|
+
document.removeEventListener('DOMContentLoaded', streamWatch.onLoaded);
|
|
417
|
+
streamWatch.observer?.disconnect();
|
|
418
|
+
streamWatch = null;
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
//# sourceMappingURL=ssr-seed.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ssr-seed.js","sourceRoot":"","sources":["../../src/builder/ssr-seed.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAE7D,OAAO,EAAkB,cAAc,EAAE,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