@atelic-action/ui 3.17.0 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -45,8 +45,8 @@ Every export, grouped by the entry it is imported from. The gallery column links
45
45
  | `ArtifactShell` | `@atelic-action/ui/artifact` | The chrome around a document page: skip link, dark header, credit band, watermark | [#site-header](https://ui.atelic.me/#site-header) (its dark bar) |
46
46
  | `AppErrorBoundary`, `ErrorFallback` | `@atelic-action/ui/artifact` | The error boundary and the page it falls back to | none |
47
47
  | `buildPageHead`, `canonicalURL`, `newTabProps`, the `ArtifactConfig` types | `@atelic-action/ui/artifact` | A page's head, a link's new tab props, and a site's contract | none |
48
- | `mintToken`, `sealReader`, `openReader`, `readerId`, `readerLink`, `whoIsReading` | `@atelic-action/ui/artifact` and `@atelic-action/ui/artifact/readers` | Who opened a document; the second entry is the same six, built, for what Node runs | none |
49
- | `Masthead`, `TitleCard`, `Footer`, `FailurePage` | `@atelic-action/ui/email` | An email's frame: the wordmark row, the title card, the foot, the failure page | [#email](https://ui.atelic.me/#email) |
48
+ | `whoIsReading` | `@atelic-action/ui/artifact` and `@atelic-action/ui/artifact/readers` | Who opened a document, by the email they signed in with; the second entry is the same function, built, for what Node runs | none |
49
+ | `Masthead`, `TitleCard`, `Footer`, `FailurePage` | `@atelic-action/ui/email` | An email's frame: the wordmark row, the title card, the foot, the failure page (plain, or structured by a step and a fix) | [#email](https://ui.atelic.me/#email) |
50
50
  | `Card`, `Row`, `FoldRow`, `Eyebrow`, `SubEyebrow`, `Fold`, `BigFold` | `@atelic-action/ui/email` | The containers and labels an email's sections sit in | [#email](https://ui.atelic.me/#email) |
51
51
  | `Item`, `TitleLine`, `Note`, `EmptyRow`, `Stat`, `StatsRow`, `List`, `ListRow`, `LeadRow`, `MonoTable`, `ReadBlock`, `Badge` | `@atelic-action/ui/email` | The rows inside a card | [#email](https://ui.atelic.me/#email) |
52
52
  | `Scoreboard`, `GroupRow`, `TargetRow`, `Bar`, `WhatMoved`, `DayStrip`, `StatStrip` | `@atelic-action/ui/email` | Targets against what was logged, what moved, and the week by day | [#email](https://ui.atelic.me/#email) |
@@ -346,7 +346,7 @@ The two pieces a reader sees are ordinary components, in `@atelic-action/ui/comp
346
346
  - **The pieces:** `GradeChip` and `gradeLabel` with the `WriteupGrade` type, `SignOff` with the `WriteupPerson` type, `Shot` with the `WriteupShot` type (a crop taller than it is wide is measured in the browser, marked `data-portrait`, and held to 200px wide on screen and 1.8in in print; a layout that sizes its shots itself sets `--op-shot-portrait-max: none` to opt out, on screen and in print alike), and the plain data text (`Paragraph`, `Runs`, `ArtifactAnchor`, and `isEmpty`, with the `ArtifactLink` and `ArtifactParagraph` types: a paragraph is a string or runs of text and `{ text, href }` links, so a routine can write a document as JSON).
347
347
  - **The shell:** `ArtifactShell`, the `.atelic-ui` scope with the skip link, the dark header, the credit band, and the watermark around a page.
348
348
  - **The contract and the head:** the `ArtifactConfig` types, and `buildPageHead` and `canonicalURL` with their `PageMeta` type.
349
- - **Who opened it:** `mintToken`, `sealReader`, `openReader`, `readerId`, `readerLink`, and `whoIsReading`. The same six are also built and exported alone as `@atelic-action/ui/artifact/readers`, because a Playwright spec and a script run under Node, which compiles nothing inside `node_modules`.
349
+ - **Who opened it:** `whoIsReading`, the email a reader signed in with at the wall, by the form or by the sign in a send carried, and nobody on the sender's own domain. It is also built and exported alone as `@atelic-action/ui/artifact/readers`, because a Playwright spec runs under Node, which compiles nothing inside `node_modules`.
350
350
  - **The error boundary:** `AppErrorBoundary` and its `ErrorFallback`.
351
351
  - **`newTabProps`,** for the links a content module writes.
352
352
 
@@ -404,7 +404,7 @@ The package installs the scripts every artifact site used to carry as files, so
404
404
  | `atelic-stamp-health` | Writes `dist/client/health.json` with the status, the commit, and the build time | Last step of `build` |
405
405
  | `atelic-check-links` | Asks for every external link in the prerendered pages and exits 1 when one is dead | `check:links`, after a build |
406
406
  | `atelic-check-wall <host> [path ...]` | Asks a deployed host for each document and held file with no cookie, and passes only when the wall answers every one and the sign in functions respond | `check:wall`, before any private link goes out |
407
- | `atelic-reader-link <email> [path] [--token <token>] [--qr \| --no-qr]` | Mints a named reader: prints the sealed line for `analytics.identify` and the link to send, and writes `public/images/qr.png` for a public read's first reader | `reader` |
407
+ | `atelic-reader-link <email> [path] [--days <n>]` | Mints the sign in a send carries: a link that signs the reader in at the wall and lands them on the page (query kept), good on every open for 14 days by default and 30 at most. Signs with `GATE_SESSION_SECRET` and refuses an address `GATE_ALLOWLIST` would not admit, both read from the environment | `reader` |
408
408
  | `atelic-serve-static` | Serves `dist/client` on `127.0.0.1` the way Vercel does, on `PORT` or 4173 | The `webServer` command in `playwright.config.ts` |
409
409
  | `atelic-print-sheets <url or dist/client> <out.pdf> [sheets] [page] [port]` | Prints a page to PDF with headless Chrome, reports the sheet count, and fails when a count is given and missed | `print` |
410
410
  | `atelic-seal-document <config.json> [out.json]` | Seals a document into the payload that `@atelic-action/artifact`'s `Gate` reads, one wrapped key for each reader. The payload names no one: no address, and readers numbered `r1`, `r2` whatever the config calls them | `seal` |
@@ -650,6 +650,19 @@ const text = recordStackText(records);
650
650
 
651
651
  `renderEmail` builds the document shell itself and puts only the rows through React, because React emits no doctype, React 19 hoists and reorders head tags, and it would escape the `>` in `details>summary`. `renderFailureEmail` is the same shell around `FailurePage`. Both live at `@atelic-action/ui/email/render`, apart from the components, so a site that mounts a component on a page never pulls React's server renderer into its browser bundle.
652
652
 
653
+ The failure page takes two optional strings (4.1.0): `step`, what failed as a short label (`"Claude model call"`), and `fix`, what to do in a sentence or two that may hold a command. Given either, the reason line under the headline becomes a labelled block, one row per fact on a hairline with a faint eyebrow over its value: What Failed (the step), Why (the reason), and What to Do (the fix, its label in the accent and its value in mono), then the log tail under its own Log eyebrow. A row whose value is empty or only whitespace is left out, so an empty reason leaves no bare Why. The preheader leads with the step when there is one (`Claude model call: OAuth token revoked`). Given neither, the page is byte for byte what it was before, held by a frozen copy in `tst/email/frozen/`.
654
+
655
+ ```ts
656
+ renderFailureEmail({
657
+ runnerTitle: "Brief",
658
+ eyebrowText: "Week 47",
659
+ step: "Claude model call",
660
+ reason: "OAuth token revoked, status 401",
661
+ fix: "Run claude setup-token, then push the new token to the vault.",
662
+ logTail,
663
+ });
664
+ ```
665
+
653
666
  ### The Mapping
654
667
 
655
668
  Where the jq takes a pre rendered html string (`$rows`, `$body_html`, `$cells_html`, a records cell's `html`, a stat's caption), the React prop is `children` or a `ReactNode`. Where the jq escapes a string argument, the prop is a plain string and React does the escaping.
@@ -688,7 +701,7 @@ Where the jq takes a pre rendered html string (`$rows`, `$body_html`, `$cells_ht
688
701
  | `title_card` | `TitleCard` | `eyebrowText`, `headlineLines`, `lede`, `stats` (the rows under the lede, in place of the jq's `$stats_html`) |
689
702
  | `footer` | `Footer` | `meta` |
690
703
  | `page` | `renderEmail` | `title`, `preheader`, `children`, `palette`, `fonts` |
691
- | `failure_page` | `renderFailureEmail`, or `FailurePage` as body rows | `runnerTitle`, `eyebrowText`, `reason`, `logTail` |
704
+ | `failure_page` | `renderFailureEmail`, or `FailurePage` as body rows | `runnerTitle`, `eyebrowText`, `reason`, `logTail`, and since 4.1.0 the optional `step` and `fix` (no jq counterpart) |
692
705
 
693
706
  The plain text alternative part ports as plain functions with no React anywhere in them: `spaces`, `rpad`, `lpad`, `wrap`, `textRule`, `textSection`, `textRead`, `textBar`, `textTarget`, `textTableGrid`, `textTable`, `recordStackText`, `textWidth`, plus `asciiUpcase` and `asciiDowncase`. Every width counts Unicode codepoints, the way jq's `length` does.
694
707
 
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env bun
2
- // atelic-reader-link <email> [path] [--token <token>] [--qr | --no-qr]: mints a reader link and its QR.
2
+ // atelic-reader-link <email> [path] [--days <n>]: mints the sign in link a send carries.
3
3
  import { main } from "../src/scripts/reader-link";
4
4
 
5
5
  await main(process.argv.slice(2));
@@ -1,33 +1,27 @@
1
- import type { ArtifactReader } from "./artifactConfig.js";
2
- /** What a config lists a token under: a digest, so the token itself never ships. */
3
- export declare function readerId(token: string): Promise<string>;
4
- /** A fresh token for one reader's links: twelve characters, safe in a URL. */
5
- export declare function mintToken(): string;
6
- /** Seal a reader's email under their token: the entry site.config.ts lists. */
7
- export declare function sealReader(email: string, token: string): Promise<ArtifactReader>;
8
- /** The email a link's token opens, or undefined when it opens nobody's. */
9
- export declare function openReader(readers: ArtifactReader[] | undefined, token: string | null | undefined): Promise<string | undefined>;
10
1
  /**
11
- * The email this visit should be identified as, or undefined to leave it
12
- * anonymous.
2
+ * Who opened it. An artifact reports every open to the practice's HubSpot
3
+ * portal, and an open lands on a person's contact record only when the visit
4
+ * says who they are. A visit says so one way: the reader signed in at the
5
+ * wall, by the form or by the sign in link a send carried, and the email
6
+ * they signed in with is in the `gate_email` cookie the sign in set. A link
7
+ * never names its reader any other way (FOOTPRINT.md, Privacy).
13
8
  *
14
- * On a private artifact the sign in decides, and a link's token never
15
- * overrides it: the wall checked who this is, and a token only says who a
16
- * link was sent to. So a signed in reader is identified by their own email,
17
- * and a reader on the sender's domain is nobody's open even through someone
18
- * else's link, since that is the practice reading its own document. A
19
- * visit with no sign in (the wall not armed, as in local dev) falls back to
20
- * the link.
9
+ * Nothing here touches the page or the network, so it tests without a
10
+ * browser. The root route does the one impure thing, the push to HubSpot.
21
11
  *
22
- * A public artifact has no wall, so a `gate_email` cookie there proves
23
- * nothing and is never read: the link's token is the only identity.
12
+ * This file is also built to dist/ and exported on its own as
13
+ * `@atelic-action/ui/artifact/readers`, because a site's browser tests
14
+ * import it under Node, which runs no TypeScript inside node_modules. So it
15
+ * keeps the built corner's rules: no JSX, and `.js` on its relative imports.
16
+ */
17
+ /**
18
+ * The email this visit should be identified as, or undefined to leave it
19
+ * anonymous: the address the reader signed in with, unless it is on the
20
+ * sender's domain, since that is the practice reading its own document. A
21
+ * visit with no sign in (the note, which stays open, or local dev with the
22
+ * wall dormant) is anonymous.
24
23
  */
25
24
  export declare function whoIsReading(visit: {
26
- readers: ArtifactReader[] | undefined;
27
- search: string;
28
- access: "public" | "private";
29
25
  gateEmail: string;
30
26
  senderEmail: string;
31
- }): Promise<string | undefined>;
32
- /** The link to send a reader: the artifact's page with their token on it. */
33
- export declare function readerLink(siteURL: string, token: string, path?: string): string;
27
+ }): string | undefined;
@@ -1,117 +1,34 @@
1
1
  /**
2
2
  * Who opened it. An artifact reports every open to the practice's HubSpot
3
3
  * portal, and an open lands on a person's contact record only when the visit
4
- * says who they are. A visit says so one of two ways:
5
- *
6
- * - **Their link.** Every link sent to a named person carries
7
- * `?k=<their token>`, and site.config.ts lists that reader.
8
- * - **The wall.** A reader who signed in on a private host is known by the
9
- * email they signed in with, read from the `gate_email` cookie.
10
- *
11
- * site.config.ts ships in the script every page loads, so a reader is listed
12
- * sealed, never in the clear: `id` is a digest of the token, and `sealed` is
13
- * the email encrypted under a key derived from the token. Only the link can
14
- * open it, and the link is in one person's inbox. Reading the page's source
15
- * gives nobody's address.
4
+ * says who they are. A visit says so one way: the reader signed in at the
5
+ * wall, by the form or by the sign in link a send carried, and the email
6
+ * they signed in with is in the `gate_email` cookie the sign in set. A link
7
+ * never names its reader any other way (FOOTPRINT.md, Privacy).
16
8
  *
17
9
  * Nothing here touches the page or the network, so it tests without a
18
10
  * browser. The root route does the one impure thing, the push to HubSpot.
19
11
  *
20
12
  * This file is also built to dist/ and exported on its own as
21
- * `@atelic-action/ui/artifact/readers`, because a site's browser tests and
22
- * its reader script import it under Node, which runs no TypeScript inside
23
- * node_modules. So it keeps the built corner's rules: no JSX, and `.js` on
24
- * its relative imports.
13
+ * `@atelic-action/ui/artifact/readers`, because a site's browser tests
14
+ * import it under Node, which runs no TypeScript inside node_modules. So it
15
+ * keeps the built corner's rules: no JSX, and `.js` on its relative imports.
25
16
  */
26
- const encoder = new TextEncoder();
27
- const decoder = new TextDecoder();
28
- function toBase64URL(bytes) {
29
- return btoa(String.fromCharCode(...bytes))
30
- .replaceAll("+", "-")
31
- .replaceAll("/", "_")
32
- .replaceAll("=", "");
33
- }
34
- function fromBase64URL(text) {
35
- const padded = text.replaceAll("-", "+").replaceAll("_", "/");
36
- return Uint8Array.from(atob(padded), (char) => char.charCodeAt(0));
37
- }
38
- async function digest(text) {
39
- return crypto.subtle.digest("SHA-256", encoder.encode(text));
40
- }
41
- /** What a config lists a token under: a digest, so the token itself never ships. */
42
- export async function readerId(token) {
43
- const bytes = new Uint8Array(await digest(`id:${token}`));
44
- return Array.from(bytes.slice(0, 8), (byte) => byte.toString(16).padStart(2, "0")).join("");
45
- }
46
- async function keyFor(token) {
47
- return crypto.subtle.importKey("raw", await digest(`key:${token}`), "AES-GCM", false, [
48
- "encrypt",
49
- "decrypt",
50
- ]);
51
- }
52
- /** A fresh token for one reader's links: twelve characters, safe in a URL. */
53
- export function mintToken() {
54
- return toBase64URL(crypto.getRandomValues(new Uint8Array(9)));
55
- }
56
- /** Seal a reader's email under their token: the entry site.config.ts lists. */
57
- export async function sealReader(email, token) {
58
- const iv = crypto.getRandomValues(new Uint8Array(12));
59
- const sealed = new Uint8Array(await crypto.subtle.encrypt({ name: "AES-GCM", iv }, await keyFor(token), encoder.encode(email)));
60
- const packed = new Uint8Array(iv.length + sealed.length);
61
- packed.set(iv);
62
- packed.set(sealed, iv.length);
63
- return { id: await readerId(token), sealed: toBase64URL(packed) };
64
- }
65
- /** The email a link's token opens, or undefined when it opens nobody's. */
66
- export async function openReader(readers, token) {
67
- if (!token || !readers?.length)
68
- return undefined;
69
- const id = await readerId(token);
70
- const reader = readers.find((entry) => entry.id === id);
71
- if (!reader)
72
- return undefined;
73
- try {
74
- const packed = fromBase64URL(reader.sealed);
75
- const opened = await crypto.subtle.decrypt({ name: "AES-GCM", iv: packed.slice(0, 12) }, await keyFor(token), packed.slice(12));
76
- return decoder.decode(opened);
77
- }
78
- catch {
79
- return undefined;
80
- }
81
- }
82
17
  function domainOf(email) {
83
18
  return email.slice(email.lastIndexOf("@") + 1).toLowerCase();
84
19
  }
85
20
  /**
86
21
  * The email this visit should be identified as, or undefined to leave it
87
- * anonymous.
88
- *
89
- * On a private artifact the sign in decides, and a link's token never
90
- * overrides it: the wall checked who this is, and a token only says who a
91
- * link was sent to. So a signed in reader is identified by their own email,
92
- * and a reader on the sender's domain is nobody's open even through someone
93
- * else's link, since that is the practice reading its own document. A
94
- * visit with no sign in (the wall not armed, as in local dev) falls back to
95
- * the link.
96
- *
97
- * A public artifact has no wall, so a `gate_email` cookie there proves
98
- * nothing and is never read: the link's token is the only identity.
22
+ * anonymous: the address the reader signed in with, unless it is on the
23
+ * sender's domain, since that is the practice reading its own document. A
24
+ * visit with no sign in (the note, which stays open, or local dev with the
25
+ * wall dormant) is anonymous.
99
26
  */
100
- export async function whoIsReading(visit) {
101
- if (visit.access === "private") {
102
- const signedIn = visit.gateEmail.trim();
103
- if (signedIn.includes("@")) {
104
- if (domainOf(signedIn) === domainOf(visit.senderEmail))
105
- return undefined;
106
- return signedIn;
107
- }
108
- }
109
- const token = new URLSearchParams(visit.search).get("k");
110
- return openReader(visit.readers, token);
111
- }
112
- /** The link to send a reader: the artifact's page with their token on it. */
113
- export function readerLink(siteURL, token, path = "/the-read") {
114
- const url = new URL(path, siteURL);
115
- url.searchParams.set("k", token);
116
- return url.toString();
27
+ export function whoIsReading(visit) {
28
+ const signedIn = visit.gateEmail.trim();
29
+ if (!signedIn.includes("@"))
30
+ return undefined;
31
+ if (domainOf(signedIn) === domainOf(visit.senderEmail))
32
+ return undefined;
33
+ return signedIn;
117
34
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atelic-action/ui",
3
- "version": "3.17.0",
3
+ "version": "4.1.0",
4
4
  "description": "Shared UI for the Atelic templates: site chrome, base styles, the component library, the access gate, and the app shell they install",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",
@@ -102,8 +102,7 @@
102
102
  },
103
103
  "dependencies": {
104
104
  "@radix-ui/react-tabs": "^1.2.1",
105
- "jose": "^6.2.12",
106
- "qrcode": "^1.5.4"
105
+ "jose": "^6.2.12"
107
106
  },
108
107
  "peerDependencies": {
109
108
  "@radix-ui/react-accordion": "^1.2.12",
@@ -262,7 +261,6 @@
262
261
  "@testing-library/user-event": "^14.6.1",
263
262
  "@types/bun": "^1.4.2",
264
263
  "@types/node": "^24.0.0",
265
- "@types/qrcode": "^1.5.6",
266
264
  "@types/react": "^19.0.0",
267
265
  "@types/react-dom": "^19.0.0",
268
266
  "@vitejs/plugin-react": "^6.1.1",
@@ -27,17 +27,6 @@ export interface GateConfig {
27
27
  contactEmail?: string;
28
28
  }
29
29
 
30
- /**
31
- * A named reader, sealed. This config ships in the script every page loads,
32
- * so it lists neither the reader's email nor their token: `id` is a digest
33
- * of the token, and `sealed` is the email encrypted under a key derived from
34
- * it. Only the reader's own link opens it (readers.ts).
35
- */
36
- export interface ArtifactReader {
37
- id: string;
38
- sealed: string;
39
- }
40
-
41
30
  /**
42
31
  * Who the document is from: the practice, on every artifact. The lockup in
43
32
  * the header renders from `logo` exactly as the marketing chrome's does, so
@@ -113,21 +102,12 @@ export interface ArtifactConfig {
113
102
  * picks the loader host and defaults to "na1"; na2 portals load from
114
103
  * js-na2.hs-scripts.com.
115
104
  *
116
- * `identify` says who each link identifies, and every cut says it: a
117
- * reader for every named person a link goes to, or an empty list. When a
118
- * visit arrives with `?k=<token>` (the token on that person's link), the
119
- * visitor is identified to HubSpot by their email, so the open lands on
120
- * their contact timeline. Visits without a token stay anonymous. Mint a
121
- * reader with `bun run reader <email>`.
122
- *
123
- * A private artifact needs nobody listed: its readers sign in at the
124
- * wall and are identified by the email they signed in with. DEPLOY.md,
125
- * Who Opened It, is the procedure.
105
+ * Nobody is listed: a reader is identified by the email they signed in
106
+ * with at the wall (readers.ts). DEPLOY.md, Who Opened It, is the procedure.
126
107
  */
127
108
  analytics?: {
128
109
  hubspotPortalId: string;
129
110
  hubspotRegion?: "na1" | "na2" | "eu1";
130
- identify: ArtifactReader[];
131
111
  };
132
112
  /** Copy for the access-gate login screen (see GateConfig). */
133
113
  gate?: GateConfig;
@@ -9,7 +9,6 @@ export { AppErrorBoundary } from "./AppErrorBoundary";
9
9
  export { ArtifactShell, type ArtifactShellProps } from "./ArtifactShell";
10
10
  export type {
11
11
  ArtifactConfig,
12
- ArtifactReader,
13
12
  ArtifactRecipient,
14
13
  ArtifactSender,
15
14
  GateConfig,
@@ -25,13 +24,6 @@ export {
25
24
  Runs,
26
25
  } from "./Paragraph";
27
26
  export { buildPageHead, canonicalURL, type PageMeta } from "./pageHead";
28
- export {
29
- mintToken,
30
- openReader,
31
- readerId,
32
- readerLink,
33
- sealReader,
34
- whoIsReading,
35
- } from "./readers";
27
+ export { whoIsReading } from "./readers";
36
28
  export { Shot, type WriteupShot } from "./Shot";
37
29
  export { SignOff, type WriteupPerson } from "./SignOff";
@@ -1,146 +1,37 @@
1
- import type { ArtifactReader } from "./artifactConfig.js";
2
-
3
1
  /**
4
2
  * Who opened it. An artifact reports every open to the practice's HubSpot
5
3
  * portal, and an open lands on a person's contact record only when the visit
6
- * says who they are. A visit says so one of two ways:
7
- *
8
- * - **Their link.** Every link sent to a named person carries
9
- * `?k=<their token>`, and site.config.ts lists that reader.
10
- * - **The wall.** A reader who signed in on a private host is known by the
11
- * email they signed in with, read from the `gate_email` cookie.
12
- *
13
- * site.config.ts ships in the script every page loads, so a reader is listed
14
- * sealed, never in the clear: `id` is a digest of the token, and `sealed` is
15
- * the email encrypted under a key derived from the token. Only the link can
16
- * open it, and the link is in one person's inbox. Reading the page's source
17
- * gives nobody's address.
4
+ * says who they are. A visit says so one way: the reader signed in at the
5
+ * wall, by the form or by the sign in link a send carried, and the email
6
+ * they signed in with is in the `gate_email` cookie the sign in set. A link
7
+ * never names its reader any other way (FOOTPRINT.md, Privacy).
18
8
  *
19
9
  * Nothing here touches the page or the network, so it tests without a
20
10
  * browser. The root route does the one impure thing, the push to HubSpot.
21
11
  *
22
12
  * This file is also built to dist/ and exported on its own as
23
- * `@atelic-action/ui/artifact/readers`, because a site's browser tests and
24
- * its reader script import it under Node, which runs no TypeScript inside
25
- * node_modules. So it keeps the built corner's rules: no JSX, and `.js` on
26
- * its relative imports.
13
+ * `@atelic-action/ui/artifact/readers`, because a site's browser tests
14
+ * import it under Node, which runs no TypeScript inside node_modules. So it
15
+ * keeps the built corner's rules: no JSX, and `.js` on its relative imports.
27
16
  */
28
17
 
29
- const encoder = new TextEncoder();
30
- const decoder = new TextDecoder();
31
-
32
- function toBase64URL(bytes: Uint8Array): string {
33
- return btoa(String.fromCharCode(...bytes))
34
- .replaceAll("+", "-")
35
- .replaceAll("/", "_")
36
- .replaceAll("=", "");
37
- }
38
-
39
- function fromBase64URL(text: string): Uint8Array<ArrayBuffer> {
40
- const padded = text.replaceAll("-", "+").replaceAll("_", "/");
41
- return Uint8Array.from(atob(padded), (char) => char.charCodeAt(0));
42
- }
43
-
44
- async function digest(text: string): Promise<ArrayBuffer> {
45
- return crypto.subtle.digest("SHA-256", encoder.encode(text));
46
- }
47
-
48
- /** What a config lists a token under: a digest, so the token itself never ships. */
49
- export async function readerId(token: string): Promise<string> {
50
- const bytes = new Uint8Array(await digest(`id:${token}`));
51
- return Array.from(bytes.slice(0, 8), (byte) => byte.toString(16).padStart(2, "0")).join("");
52
- }
53
-
54
- async function keyFor(token: string): Promise<CryptoKey> {
55
- return crypto.subtle.importKey("raw", await digest(`key:${token}`), "AES-GCM", false, [
56
- "encrypt",
57
- "decrypt",
58
- ]);
59
- }
60
-
61
- /** A fresh token for one reader's links: twelve characters, safe in a URL. */
62
- export function mintToken(): string {
63
- return toBase64URL(crypto.getRandomValues(new Uint8Array(9)));
64
- }
65
-
66
- /** Seal a reader's email under their token: the entry site.config.ts lists. */
67
- export async function sealReader(email: string, token: string): Promise<ArtifactReader> {
68
- const iv = crypto.getRandomValues(new Uint8Array(12));
69
- const sealed = new Uint8Array(
70
- await crypto.subtle.encrypt(
71
- { name: "AES-GCM", iv },
72
- await keyFor(token),
73
- encoder.encode(email),
74
- ),
75
- );
76
- const packed = new Uint8Array(iv.length + sealed.length);
77
- packed.set(iv);
78
- packed.set(sealed, iv.length);
79
- return { id: await readerId(token), sealed: toBase64URL(packed) };
80
- }
81
-
82
- /** The email a link's token opens, or undefined when it opens nobody's. */
83
- export async function openReader(
84
- readers: ArtifactReader[] | undefined,
85
- token: string | null | undefined,
86
- ): Promise<string | undefined> {
87
- if (!token || !readers?.length) return undefined;
88
- const id = await readerId(token);
89
- const reader = readers.find((entry) => entry.id === id);
90
- if (!reader) return undefined;
91
- try {
92
- const packed = fromBase64URL(reader.sealed);
93
- const opened = await crypto.subtle.decrypt(
94
- { name: "AES-GCM", iv: packed.slice(0, 12) },
95
- await keyFor(token),
96
- packed.slice(12),
97
- );
98
- return decoder.decode(opened);
99
- } catch {
100
- return undefined;
101
- }
102
- }
103
-
104
18
  function domainOf(email: string): string {
105
19
  return email.slice(email.lastIndexOf("@") + 1).toLowerCase();
106
20
  }
107
21
 
108
22
  /**
109
23
  * The email this visit should be identified as, or undefined to leave it
110
- * anonymous.
111
- *
112
- * On a private artifact the sign in decides, and a link's token never
113
- * overrides it: the wall checked who this is, and a token only says who a
114
- * link was sent to. So a signed in reader is identified by their own email,
115
- * and a reader on the sender's domain is nobody's open even through someone
116
- * else's link, since that is the practice reading its own document. A
117
- * visit with no sign in (the wall not armed, as in local dev) falls back to
118
- * the link.
119
- *
120
- * A public artifact has no wall, so a `gate_email` cookie there proves
121
- * nothing and is never read: the link's token is the only identity.
24
+ * anonymous: the address the reader signed in with, unless it is on the
25
+ * sender's domain, since that is the practice reading its own document. A
26
+ * visit with no sign in (the note, which stays open, or local dev with the
27
+ * wall dormant) is anonymous.
122
28
  */
123
- export async function whoIsReading(visit: {
124
- readers: ArtifactReader[] | undefined;
125
- search: string;
126
- access: "public" | "private";
29
+ export function whoIsReading(visit: {
127
30
  gateEmail: string;
128
31
  senderEmail: string;
129
- }): Promise<string | undefined> {
130
- if (visit.access === "private") {
131
- const signedIn = visit.gateEmail.trim();
132
- if (signedIn.includes("@")) {
133
- if (domainOf(signedIn) === domainOf(visit.senderEmail)) return undefined;
134
- return signedIn;
135
- }
136
- }
137
- const token = new URLSearchParams(visit.search).get("k");
138
- return openReader(visit.readers, token);
139
- }
140
-
141
- /** The link to send a reader: the artifact's page with their token on it. */
142
- export function readerLink(siteURL: string, token: string, path = "/the-read"): string {
143
- const url = new URL(path, siteURL);
144
- url.searchParams.set("k", token);
145
- return url.toString();
32
+ }): string | undefined {
33
+ const signedIn = visit.gateEmail.trim();
34
+ if (!signedIn.includes("@")) return undefined;
35
+ if (domainOf(signedIn) === domainOf(visit.senderEmail)) return undefined;
36
+ return signedIn;
146
37
  }
@@ -188,14 +188,50 @@ export type FailurePageProps = {
188
188
  eyebrowText: string;
189
189
  reason: string;
190
190
  logTail: string;
191
+ /** What failed, as a short label ("Claude model call"). */
192
+ step?: string;
193
+ /** What to do about it, a sentence or two that may hold a command. */
194
+ fix?: string;
191
195
  };
192
196
 
197
+ /** True for a string with something in it besides whitespace. */
198
+ function filled(value: string | undefined): value is string {
199
+ return value !== undefined && value.trim() !== "";
200
+ }
201
+
202
+ /** One long token (a path, a URL) wraps instead of widening the column. */
203
+ const wrapLong = { overflowWrap: "anywhere", wordBreak: "break-word" } as const;
204
+
205
+ type FailureFact = { label: string; value: string; kind: "step" | "reason" | "fix" };
206
+
193
207
  /**
194
208
  * The body rows of the failure page, in the same cream, so a bad week reads
195
- * like a good one with the reason on top and the log's tail beneath.
209
+ * like a good one with the reason on top and the log's tail beneath. With a
210
+ * `step` or a `fix` the reason becomes a labelled block of what failed, why,
211
+ * and what to do, and the log sits under its own label; without either the
212
+ * page is exactly the plain one.
196
213
  */
197
- export function FailurePage({ runnerTitle, eyebrowText, reason, logTail }: FailurePageProps) {
214
+ export function FailurePage({
215
+ runnerTitle,
216
+ eyebrowText,
217
+ reason,
218
+ logTail,
219
+ step,
220
+ fix,
221
+ }: FailurePageProps) {
198
222
  const { palette, fonts } = useEmailTheme();
223
+ if (filled(step) || filled(fix)) {
224
+ return (
225
+ <StructuredFailurePage
226
+ runnerTitle={runnerTitle}
227
+ eyebrowText={eyebrowText}
228
+ reason={reason}
229
+ logTail={logTail}
230
+ step={step}
231
+ fix={fix}
232
+ />
233
+ );
234
+ }
199
235
  return (
200
236
  <>
201
237
  <Masthead title={runnerTitle} />
@@ -254,3 +290,119 @@ export function FailurePage({ runnerTitle, eyebrowText, reason, logTail }: Failu
254
290
  </>
255
291
  );
256
292
  }
293
+
294
+ /**
295
+ * The structured failure page: the same eyebrow and headline, then one row per
296
+ * fact that has a value, each a faint eyebrow over its value on a hairline,
297
+ * and the log's tail last under its own eyebrow. The fix's label wears the
298
+ * accent, as an accented `Note` does, and its value is set in mono because it
299
+ * so often holds a command.
300
+ */
301
+ function StructuredFailurePage({
302
+ runnerTitle,
303
+ eyebrowText,
304
+ reason,
305
+ logTail,
306
+ step,
307
+ fix,
308
+ }: FailurePageProps) {
309
+ const { palette, fonts } = useEmailTheme();
310
+ const facts: FailureFact[] = [];
311
+ if (filled(step)) facts.push({ label: "What Failed", value: step, kind: "step" });
312
+ if (filled(reason)) facts.push({ label: "Why", value: reason, kind: "reason" });
313
+ if (filled(fix)) facts.push({ label: "What to Do", value: fix, kind: "fix" });
314
+ const hasLog = filled(logTail);
315
+ const cell = { padding: "14px 0", borderTop: `1px solid ${palette.line}` };
316
+ const valueStyle = (kind: FailureFact["kind"]) => {
317
+ if (kind === "fix") {
318
+ return {
319
+ marginTop: "6px",
320
+ fontFamily: fonts.mono,
321
+ fontSize: "13px",
322
+ lineHeight: "1.6",
323
+ color: palette.ink,
324
+ whiteSpace: "pre-wrap" as const,
325
+ ...wrapLong,
326
+ };
327
+ }
328
+ return {
329
+ marginTop: "6px",
330
+ fontFamily: fonts.sans,
331
+ fontSize: "15px",
332
+ lineHeight: "1.5",
333
+ color: kind === "step" ? palette.ink : palette.dim,
334
+ ...wrapLong,
335
+ ...(kind === "step" ? { fontWeight: "600" } : {}),
336
+ };
337
+ };
338
+ return (
339
+ <>
340
+ <Masthead title={runnerTitle} />
341
+ <Card>
342
+ <tr>
343
+ <td style={{ padding: "26px 26px 6px", ...eyebrowStyle(fonts), color: palette.faint }}>
344
+ {eyebrowText}
345
+ </td>
346
+ </tr>
347
+ <tr>
348
+ <td
349
+ style={{
350
+ padding: "0 26px",
351
+ fontFamily: fonts.sans,
352
+ fontSize: "30px",
353
+ fontWeight: "600",
354
+ letterSpacing: "-0.03em",
355
+ lineHeight: "1.1",
356
+ color: palette.ink,
357
+ }}
358
+ >
359
+ {`The ${asciiDowncase(runnerTitle)} did not run.`}
360
+ </td>
361
+ </tr>
362
+ <tr>
363
+ <td style={{ padding: "22px 26px 12px" }}>
364
+ <table {...tableReset} width="100%">
365
+ <tbody>
366
+ {facts.map((fact) => (
367
+ <tr key={fact.kind}>
368
+ <td style={cell}>
369
+ <div
370
+ style={{
371
+ ...eyebrowStyle(fonts),
372
+ color: fact.kind === "fix" ? palette.accent : palette.faint,
373
+ }}
374
+ >
375
+ {fact.label}
376
+ </div>
377
+ <div style={valueStyle(fact.kind)}>{fact.value}</div>
378
+ </td>
379
+ </tr>
380
+ ))}
381
+ {hasLog ? (
382
+ <tr>
383
+ <td style={cell}>
384
+ <div style={{ ...eyebrowStyle(fonts), color: palette.faint }}>Log</div>
385
+ <pre
386
+ style={{
387
+ fontFamily: fonts.mono,
388
+ fontSize: "12px",
389
+ lineHeight: "1.5",
390
+ whiteSpace: "pre-wrap",
391
+ ...wrapLong,
392
+ color: palette.dim,
393
+ margin: "6px 0 0",
394
+ }}
395
+ >
396
+ {logTail}
397
+ </pre>
398
+ </td>
399
+ </tr>
400
+ ) : null}
401
+ </tbody>
402
+ </table>
403
+ </td>
404
+ </tr>
405
+ </Card>
406
+ </>
407
+ );
408
+ }
@@ -77,22 +77,42 @@ export type RenderFailureEmailOptions = {
77
77
  eyebrowText: string;
78
78
  reason: string;
79
79
  logTail: string;
80
+ /** What failed, as a short label; it also leads the preheader. */
81
+ step?: string;
82
+ /** What to do about it, a sentence or two that may hold a command. */
83
+ fix?: string;
80
84
  palette?: Palette;
81
85
  fonts?: Fonts;
82
86
  };
83
87
 
84
- /** The failure page: the reason on top and the log's tail beneath. */
88
+ /**
89
+ * The inbox preview: the reason alone, or led by the step when there is one
90
+ * ("Claude model call: OAuth token revoked").
91
+ */
92
+ function failurePreheader(reason: string, step: string | undefined): string {
93
+ const label = step?.trim() ?? "";
94
+ if (label === "") return reason;
95
+ const why = reason.trim();
96
+ return why === "" ? label : `${label}: ${why}`;
97
+ }
98
+
99
+ /**
100
+ * The failure page: the reason on top and the log's tail beneath, or with a
101
+ * `step` or a `fix` the labelled block of what failed, why, and what to do.
102
+ */
85
103
  export function renderFailureEmail({
86
104
  runnerTitle,
87
105
  eyebrowText,
88
106
  reason,
89
107
  logTail,
108
+ step,
109
+ fix,
90
110
  palette,
91
111
  fonts,
92
112
  }: RenderFailureEmailOptions): string {
93
113
  return renderEmail({
94
114
  title: `${runnerTitle}: did not run`,
95
- preheader: reason,
115
+ preheader: failurePreheader(reason, step),
96
116
  palette,
97
117
  fonts,
98
118
  children: (
@@ -101,6 +121,8 @@ export function renderFailureEmail({
101
121
  eyebrowText={eyebrowText}
102
122
  reason={reason}
103
123
  logTail={logTail}
124
+ step={step}
125
+ fix={fix}
104
126
  />
105
127
  ),
106
128
  });
@@ -1,108 +1,115 @@
1
1
  /**
2
- * Mint a named reader and print the two things that come of it: the line
3
- * that goes in site.config.ts and the link that goes in the email. Every
4
- * link sent to a named person carries their token, so their open lands on
5
- * their contact in HubSpot (DEPLOY.md, Who Opened It).
2
+ * Mint the sign in a send carries: a link that signs its named reader in at
3
+ * the wall and lands them on the page, so the person a page was written to
4
+ * never sees the form (FOOTPRINT.md, Privacy). It is the wall's own link
5
+ * token, the one the form emails, with a window sized for a send instead of
6
+ * a sitting, and like that token it keeps working on every open inside its
7
+ * window, because mail clients open links before the reader does.
6
8
  *
7
- * The config line holds the reader sealed: a digest of the token and the
8
- * email encrypted under it. The token itself appears only in the link, so
9
- * keep the link; it cannot be printed again.
9
+ * It signs with the host's own secret and checks the host's own list, read
10
+ * from the environment as the wall reads them (`GATE_SESSION_SECRET`,
11
+ * `GATE_ALLOWLIST`), so a link for an address the wall would refuse is never
12
+ * minted. The practice's artifact command fills both from the vault and the
13
+ * folder's wall.json; nothing here reads either.
10
14
  *
11
- * A read's reader also gets the printed copy's QR: public/images/qr.png
12
- * is written to carry the same link, so a scan of the sheet lands on that
13
- * person's contact as an emailed open does. Mint the reader before printing.
14
- *
15
- * The sheet belongs to the first reader named. A later reader never
16
- * repoints it: with a reader already in analytics.identify the QR is left
17
- * alone unless --qr asks for it.
18
- *
19
- * Usage: atelic-reader-link <email> [path] [--token <existing token>] [--qr | --no-qr],
15
+ * Usage: atelic-reader-link <email> [path] [--days <n>],
20
16
  * or `bun run reader <email>` in a site, from the site's root.
21
- * path defaults to /the-read. --token seals an email under a token that is
22
- * already in a sent link, so that link keeps working. --qr writes the QR
23
- * for this reader even when another is already named; --no-qr never writes it.
17
+ * path defaults to /the-read and keeps its query (`/the-read?tab=plan`).
18
+ * --days is the link's window, 14 by default and 30 at most.
24
19
  */
25
- import { resolve } from "node:path";
26
- import QRCode from "qrcode";
27
- import { mintToken, readerLink, sealReader } from "../artifact/readers";
20
+ import { isAllowed, positive } from "../gate/config";
21
+ import { safeNext } from "../gate/next";
22
+ import { signToken } from "../gate/tokens";
28
23
  import { loadSite } from "./site-config";
29
24
 
30
- export const USAGE =
31
- "Usage: bun run reader <email> [path] [--token <existing token>] [--qr | --no-qr]";
25
+ export const USAGE = "Usage: bun run reader <email> [path] [--days <n>]";
26
+
27
+ /** A send's link holds for two weeks unless the command says otherwise. */
28
+ export const DEFAULT_DAYS = 14;
29
+
30
+ /** Past a month a sign in link is a standing key, not a send. */
31
+ export const LONGEST_DAYS = 30;
32
32
 
33
33
  /** What the command line asked for. */
34
34
  export interface ReaderArgs {
35
35
  email: string;
36
- /** The page the link opens, always with one leading slash and none trailing. */
36
+ /** The page the link lands on, one leading slash, its query kept. */
37
37
  path: string;
38
- /** A token already in a sent link, when --token gave one. */
39
- token?: string;
40
- /** --qr: write the QR for this reader even when another is already named. */
41
- forceQR: boolean;
42
- /** --no-qr: never write the QR. */
43
- noQR: boolean;
38
+ /** The link's window in days, held to the ceiling. */
39
+ days: number;
44
40
  }
45
41
 
46
42
  /** Reads the command line; undefined when it does not name a reader, which is a usage error. */
47
43
  export function parseReaderArgs(flags: string[]): ReaderArgs | undefined {
48
- const noQR = flags.includes("--no-qr");
49
- const forceQR = flags.includes("--qr");
50
- const args = flags.filter((flag) => flag !== "--no-qr" && flag !== "--qr");
51
- const at = args.indexOf("--token");
52
- const given = at === -1 ? undefined : args[at + 1];
53
- const rest = at === -1 ? args : args.filter((_, index) => index !== at && index !== at + 1);
44
+ const at = flags.indexOf("--days");
45
+ const given = at === -1 ? undefined : flags[at + 1];
46
+ if (at !== -1 && given === undefined) return undefined;
47
+ const rest = at === -1 ? flags : flags.filter((_, index) => index !== at && index !== at + 1);
54
48
  const [email, givenPath = "/the-read"] = rest;
55
- // "the-read", "/the-read", and "/the-read/" are one page.
56
- const path = `/${givenPath.replace(/^\/+|\/+$/g, "")}`;
49
+ if (!email?.includes("@") || rest.length > 2) return undefined;
57
50
 
58
- if (!email?.includes("@") || (at !== -1 && !given)) return undefined;
59
- return { email, path, token: given, forceQR, noQR };
51
+ // "the-read", "/the-read", and "/the-read/" are one page; a query rides along.
52
+ const query = givenPath.indexOf("?");
53
+ const page = query === -1 ? givenPath : givenPath.slice(0, query);
54
+ const search = query === -1 ? "" : givenPath.slice(query);
55
+ const path = `/${page.replace(/^\/+|\/+$/g, "")}${search}`;
56
+ if (safeNext(path) !== path) return undefined;
57
+
58
+ // A window that is no number, or none at all, is a typo, never the default.
59
+ if (given !== undefined && !(Number(given) > 0)) return undefined;
60
+ const days = positive(given, DEFAULT_DAYS, LONGEST_DAYS);
61
+ return { email: email.trim().toLowerCase(), path, days };
60
62
  }
61
63
 
62
64
  /**
63
- * The command. The config it reads and the QR it writes are the site's,
64
- * found from the working directory.
65
+ * The link a send carries for this reader on this host. Throws one line when
66
+ * the wall is not armed, or when the wall would not admit the address, so a
67
+ * dead link never reaches a draft.
65
68
  */
69
+ export async function sendLink(
70
+ reader: ReaderArgs,
71
+ host: { url: string; secret: string | undefined; allowlist: string | undefined },
72
+ now: number = Date.now(),
73
+ ): Promise<string> {
74
+ if (!host.secret) {
75
+ throw new Error("no GATE_SESSION_SECRET in the environment, so no link can be signed.");
76
+ }
77
+ if (!isAllowed(reader.email, host.allowlist)) {
78
+ throw new Error(
79
+ `${reader.email} is not on GATE_ALLOWLIST, so the wall would refuse its link. Put the address or its domain on the wall first.`,
80
+ );
81
+ }
82
+ const token = await signToken(
83
+ {
84
+ e: reader.email,
85
+ x: Math.floor(now / 1000) + Math.round(reader.days * 24 * 60 * 60),
86
+ p: "link",
87
+ n: reader.path,
88
+ },
89
+ host.secret,
90
+ );
91
+ const link = new URL("/api/auth/verify", host.url);
92
+ link.searchParams.set("token", token);
93
+ return link.toString();
94
+ }
95
+
96
+ /** The command. The site's address comes from its config, found from the working directory. */
66
97
  export async function main(flags: string[], cwd: string = process.cwd()): Promise<void> {
67
98
  const parsed = parseReaderArgs(flags);
68
99
  if (!parsed) {
69
100
  console.error(USAGE);
70
101
  process.exit(1);
71
102
  }
72
- const { email, path, forceQR, noQR } = parsed;
73
- let site: Awaited<ReturnType<typeof loadSite>>;
74
103
  try {
75
- site = await loadSite(cwd);
104
+ const site = await loadSite(cwd);
105
+ const link = await sendLink(parsed, {
106
+ url: site.url,
107
+ secret: process.env.GATE_SESSION_SECRET,
108
+ allowlist: process.env.GATE_ALLOWLIST,
109
+ });
110
+ console.log(link);
76
111
  } catch (error) {
77
112
  console.error(`[reader] ${(error as Error).message}`);
78
113
  process.exit(1);
79
114
  }
80
-
81
- const token = parsed.token ?? mintToken();
82
- const reader = await sealReader(email, token);
83
- console.log("Add to analytics.identify in src/site.config.ts:");
84
- console.log(` { id: "${reader.id}", sealed: "${reader.sealed}" }, // ${email.split("@")[1]}`);
85
- console.log("");
86
- console.log("Send this link, and only to that person. Keep it: it cannot be printed again.");
87
- const link = readerLink(site.url, token, path);
88
- console.log(` ${link}`);
89
-
90
- // The sheet's QR is the reader's link. A private artifact identifies by sign
91
- // in and never by a token, so its QR stays on the bare host.
92
- const named = site.analytics?.identify.length ?? 0;
93
- const sheetIsFree = named === 0 || forceQR;
94
- if (path === "/the-read" && !noQR && site.access === "public" && !sheetIsFree) {
95
- console.log("");
96
- console.log(
97
- "Left public/images/qr.png alone: a reader is already named, and the sheet is theirs. Pass --qr to give the sheet to this reader.",
98
- );
99
- }
100
- if (path === "/the-read" && !noQR && site.access === "public" && sheetIsFree) {
101
- const qr = resolve(cwd, "public/images/qr.png");
102
- await QRCode.toFile(qr, link, { width: 330, margin: 4, errorCorrectionLevel: "M" });
103
- console.log("");
104
- console.log(
105
- "Wrote public/images/qr.png with that link. Print the sheet after this, never before.",
106
- );
107
- }
108
115
  }
@@ -1,138 +0,0 @@
1
- /**
2
- * The contract between an artifact and the components that host it.
3
- *
4
- * An artifact is a document, not a business's website, so this is a fraction
5
- * of a marketing site's config: who it is from, who it was prepared for,
6
- * where it is hosted, who may read it, and whether an open reports to the
7
- * CRM. Everything a reader sees on the page itself arrives as content, never
8
- * from here.
9
- */
10
- /**
11
- * Copy for the access-gate login screen. Present in the config so the login
12
- * page is themed and worded per artifact with no code edits. The gate itself
13
- * is turned on by setting GATE_SESSION_SECRET on the Vercel project, not by
14
- * this block; `access` below says whether it must be. See ACCESS-GATE.md.
15
- */
16
- export interface GateConfig {
17
- /** Mono eyebrow above the headline, e.g. "Private preview". */
18
- eyebrow?: string;
19
- /** Login headline. */
20
- headline: string;
21
- /** Sub-lead under the headline. */
22
- lead: string;
23
- /** Fine-print attribution, e.g. "Built by Jane Maker". Defaults to the sender's name. */
24
- builtBy?: string;
25
- /** Contact email shown in the fine print. Defaults to the sender's email. */
26
- contactEmail?: string;
27
- }
28
- /**
29
- * A named reader, sealed. This config ships in the script every page loads,
30
- * so it lists neither the reader's email nor their token: `id` is a digest
31
- * of the token, and `sealed` is the email encrypted under a key derived from
32
- * it. Only the reader's own link opens it (readers.ts).
33
- */
34
- export interface ArtifactReader {
35
- id: string;
36
- sealed: string;
37
- }
38
- /**
39
- * Who the document is from: the practice, on every artifact. The lockup in
40
- * the header renders from `logo` exactly as the marketing chrome's does, so
41
- * a client branded artifact host keeps the sender's chrome over the client's
42
- * palette (GATE.md, Branding an Artifact Host).
43
- */
44
- export interface ArtifactSender {
45
- /** The sender's name, worn in the header and the gate's fine print. */
46
- name: string;
47
- /**
48
- * The chrome identity. `src` is the mark image; omit it for a pure text
49
- * wordmark. `tile` renders a CSS glyph tile instead of an image (a dark
50
- * rounded square bearing the given character in the brand's own webfont,
51
- * with the accent bar beneath, since an SVG-as-img mark cannot load
52
- * webfonts). `wordmark` overrides the rendered text when it should differ
53
- * from `name`; `run` appends the trailing fade bar after it.
54
- */
55
- logo: {
56
- src?: string;
57
- alt: string;
58
- tile?: string;
59
- wordmark?: string;
60
- run?: boolean;
61
- };
62
- /** Where the header lockup points; the sender's own site. */
63
- href?: string;
64
- /** Reply address, shown in the access gate's fine print. */
65
- email: string;
66
- }
67
- /** Who the document was prepared for; the business's name suffixes every title. */
68
- export interface ArtifactRecipient {
69
- name: string;
70
- /**
71
- * The recipient's mark for the header lockup ("atelic × <mark>"), cut for
72
- * the dark bar (a light mark on transparent). Unset, the header wears the
73
- * sender's lockup alone. ArtifactShell passes it to the ui header as
74
- * `brand.recipient` (@atelic-action/ui 0.6.0 and later).
75
- *
76
- * A logo is a brand mark, not a private signal, so the file lives under
77
- * public/brand/, which the access wall leaves open: the router's pending
78
- * page carries the header, so every page preloads this mark, the login
79
- * page included, and one under public/images/ would be held there. The
80
- * writeup's printed copy is white paper, so the lockup it prints in place
81
- * of the header takes a mark cut for a light ground (`recipient.logoSrc`
82
- * in the writeup's content).
83
- */
84
- logo?: {
85
- src: string;
86
- alt: string;
87
- };
88
- }
89
- export interface ArtifactConfig {
90
- /** Canonical origin of the hosted twin, no trailing slash, e.g. "https://og.atelic.me". */
91
- url: string;
92
- /**
93
- * Who may read it, which decides where it may be hosted (the practice's
94
- * FOOTPRINT.md, Privacy). "public" when everything on it was read from
95
- * public signals, a prospect's writeup; "private" when anything came from
96
- * the owner's own consoles, which is every customer's writeup and every
97
- * monthly page. A private artifact deploys only behind the armed wall:
98
- * the build fails on Vercel without the wall's variables
99
- * (scripts/check-access.ts), and scripts/check-wall.ts proves the live
100
- * host answers with the wall before any link goes out (ACCESS-GATE.md).
101
- */
102
- access: "public" | "private";
103
- sender: ArtifactSender;
104
- recipient: ArtifactRecipient;
105
- /** Social card image; a site-relative path resolves against `url`. */
106
- ogImage?: string;
107
- /**
108
- * Robots line for every page. Artifacts default to "noindex, nofollow"
109
- * and there is no reason to raise it: a document handed to one business
110
- * is never search inventory.
111
- */
112
- robots?: string;
113
- /**
114
- * Analytics wiring. When `hubspotPortalId` is set, the HubSpot tracking
115
- * code loads and records the open; because an artifact lives on its own
116
- * host, every visit is attributable to that engagement. `hubspotRegion`
117
- * picks the loader host and defaults to "na1"; na2 portals load from
118
- * js-na2.hs-scripts.com.
119
- *
120
- * `identify` says who each link identifies, and every cut says it: a
121
- * reader for every named person a link goes to, or an empty list. When a
122
- * visit arrives with `?k=<token>` (the token on that person's link), the
123
- * visitor is identified to HubSpot by their email, so the open lands on
124
- * their contact timeline. Visits without a token stay anonymous. Mint a
125
- * reader with `bun run reader <email>`.
126
- *
127
- * A private artifact needs nobody listed: its readers sign in at the
128
- * wall and are identified by the email they signed in with. DEPLOY.md,
129
- * Who Opened It, is the procedure.
130
- */
131
- analytics?: {
132
- hubspotPortalId: string;
133
- hubspotRegion?: "na1" | "na2" | "eu1";
134
- identify: ArtifactReader[];
135
- };
136
- /** Copy for the access-gate login screen (see GateConfig). */
137
- gate?: GateConfig;
138
- }
@@ -1,10 +0,0 @@
1
- /**
2
- * The contract between an artifact and the components that host it.
3
- *
4
- * An artifact is a document, not a business's website, so this is a fraction
5
- * of a marketing site's config: who it is from, who it was prepared for,
6
- * where it is hosted, who may read it, and whether an open reports to the
7
- * CRM. Everything a reader sees on the page itself arrives as content, never
8
- * from here.
9
- */
10
- export {};