@atelic-action/ui 3.16.0 → 4.0.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,7 +45,7 @@ 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 |
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
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) |
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) |
@@ -274,7 +274,7 @@ export const POST = createRequestLink({ noun: "preview" });
274
274
  | Env | Read by | What it does |
275
275
  |---|---|---|
276
276
  | `GATE_SESSION_SECRET` | all three | The signing secret, and the switch: unset, the gate is off. Use 32 random bytes or more |
277
- | `GATE_ALLOWLIST` | all three | Comma separated emails that may receive a link, or a whole domain as `@example.com`, which admits every address on it. Taking an entry off, then redeploying, refuses its outstanding links and ends their sessions |
277
+ | `GATE_ALLOWLIST` | all three | Comma separated entries that may receive a link. An address matches itself exactly; the business's domain, written `example.com` or `@example.com`, admits every address on it but none on its subdomains. Case never matters, and an empty entry or a word with no dot matches nothing. Taking an entry off, then redeploying, refuses its outstanding links and ends their sessions |
278
278
  | `RESEND_API_KEY` | request link | The sending only key the link goes out on |
279
279
  | `GATE_BASE_URL` | request link | The host the link points at; a bare host is read as https, and plain http is refused unless it is local. Unset, production uses the project's own domain and a preview uses the deployment it was asked on |
280
280
  | `GATE_FROM`, `GATE_SUBJECT`, `GATE_LINK_TTL_MIN` | request link | Sender, subject, and link lifetime in minutes (15, a day at most) |
@@ -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` |
@@ -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
  }
@@ -3,9 +3,13 @@
3
3
  * sign in functions and the middleware, so each reads a value the same way.
4
4
  */
5
5
  /**
6
- * Whether an address is on the comma separated allowlist. An entry is an
7
- * address, or a whole domain written as `@example.com`, which admits every
8
- * address on it (the business's own people, whoever the page is forwarded to).
6
+ * Whether an address is on the comma separated allowlist. An entry is either
7
+ * a full address, which matches that address exactly, or the business's
8
+ * domain, written bare (`example.com`) or with a leading at (`@example.com`),
9
+ * which admits every address whose part after the `@` is that domain (the
10
+ * business's own people, whoever the page is forwarded to). A domain never
11
+ * admits its subdomains, and everything is compared case folded. An entry
12
+ * that is empty, or is no address and holds no dot, matches nothing.
9
13
  */
10
14
  export declare function isAllowed(email: string, allowlist: string | undefined): boolean;
11
15
  /**
@@ -3,23 +3,43 @@
3
3
  * sign in functions and the middleware, so each reads a value the same way.
4
4
  */
5
5
  /**
6
- * Whether an address is on the comma separated allowlist. An entry is an
7
- * address, or a whole domain written as `@example.com`, which admits every
8
- * address on it (the business's own people, whoever the page is forwarded to).
6
+ * Whether an address is on the comma separated allowlist. An entry is either
7
+ * a full address, which matches that address exactly, or the business's
8
+ * domain, written bare (`example.com`) or with a leading at (`@example.com`),
9
+ * which admits every address whose part after the `@` is that domain (the
10
+ * business's own people, whoever the page is forwarded to). A domain never
11
+ * admits its subdomains, and everything is compared case folded. An entry
12
+ * that is empty, or is no address and holds no dot, matches nothing.
9
13
  */
10
14
  export function isAllowed(email, allowlist) {
11
15
  const wanted = email.trim().toLowerCase();
12
- // A domain entry only admits one plain address (one `@`, a local part, no
16
+ // Only one plain address is ever admitted (one `@`, a local part, no
13
17
  // whitespace or list and quoting characters), so a crafted string such as
14
18
  // `a@evil.example,b@widget.example` can never ride a domain match into a send.
15
19
  const plain = /^[^@\s,;<>()"\\]+@[^@\s,;<>()"\\]+$/.test(wanted);
16
20
  if (!plain)
17
21
  return false;
18
- const domain = wanted.slice(wanted.indexOf("@"));
22
+ const domain = wanted.slice(wanted.lastIndexOf("@") + 1);
19
23
  return (allowlist ?? "")
20
24
  .split(",")
21
25
  .map((entry) => entry.trim().toLowerCase())
22
- .some((entry) => entry === wanted || (entry.length > 1 && entry === domain));
26
+ .some((entry) => {
27
+ if (entry.length === 0)
28
+ return false;
29
+ const named = domainOf(entry);
30
+ return named === undefined ? entry === wanted : named === domain;
31
+ });
32
+ }
33
+ /**
34
+ * The domain a domain entry names, or undefined when the entry is a full
35
+ * address. A domain entry has to look like one (labels joined by dots), so a
36
+ * stray word or a bare `@` names a domain no address can be on.
37
+ */
38
+ function domainOf(entry) {
39
+ const bare = entry.startsWith("@") ? entry.slice(1) : entry;
40
+ if (bare.includes("@"))
41
+ return undefined;
42
+ return /^[^.\s@]+(\.[^.\s@]+)+$/.test(bare) ? bare : "";
23
43
  }
24
44
  /**
25
45
  * A setting that has to be a positive, finite number, or its default. A
@@ -8,7 +8,8 @@
8
8
  *
9
9
  * Env (set on the Vercel project):
10
10
  * - GATE_SESSION_SECRET signing secret; also the gate's on and off switch
11
- * - GATE_ALLOWLIST comma separated emails allowed to receive a link, or a whole domain as @example.com
11
+ * - GATE_ALLOWLIST comma separated entries allowed to receive a link: an address,
12
+ * or the business's domain (example.com or @example.com)
12
13
  * - RESEND_API_KEY sending only Resend key
13
14
  * - GATE_FROM sender display name (optional)
14
15
  * - GATE_SUBJECT email subject (optional)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atelic-action/ui",
3
- "version": "3.16.0",
3
+ "version": "4.0.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
  }
@@ -4,22 +4,41 @@
4
4
  */
5
5
 
6
6
  /**
7
- * Whether an address is on the comma separated allowlist. An entry is an
8
- * address, or a whole domain written as `@example.com`, which admits every
9
- * address on it (the business's own people, whoever the page is forwarded to).
7
+ * Whether an address is on the comma separated allowlist. An entry is either
8
+ * a full address, which matches that address exactly, or the business's
9
+ * domain, written bare (`example.com`) or with a leading at (`@example.com`),
10
+ * which admits every address whose part after the `@` is that domain (the
11
+ * business's own people, whoever the page is forwarded to). A domain never
12
+ * admits its subdomains, and everything is compared case folded. An entry
13
+ * that is empty, or is no address and holds no dot, matches nothing.
10
14
  */
11
15
  export function isAllowed(email: string, allowlist: string | undefined): boolean {
12
16
  const wanted = email.trim().toLowerCase();
13
- // A domain entry only admits one plain address (one `@`, a local part, no
17
+ // Only one plain address is ever admitted (one `@`, a local part, no
14
18
  // whitespace or list and quoting characters), so a crafted string such as
15
19
  // `a@evil.example,b@widget.example` can never ride a domain match into a send.
16
20
  const plain = /^[^@\s,;<>()"\\]+@[^@\s,;<>()"\\]+$/.test(wanted);
17
21
  if (!plain) return false;
18
- const domain = wanted.slice(wanted.indexOf("@"));
22
+ const domain = wanted.slice(wanted.lastIndexOf("@") + 1);
19
23
  return (allowlist ?? "")
20
24
  .split(",")
21
25
  .map((entry) => entry.trim().toLowerCase())
22
- .some((entry) => entry === wanted || (entry.length > 1 && entry === domain));
26
+ .some((entry) => {
27
+ if (entry.length === 0) return false;
28
+ const named = domainOf(entry);
29
+ return named === undefined ? entry === wanted : named === domain;
30
+ });
31
+ }
32
+
33
+ /**
34
+ * The domain a domain entry names, or undefined when the entry is a full
35
+ * address. A domain entry has to look like one (labels joined by dots), so a
36
+ * stray word or a bare `@` names a domain no address can be on.
37
+ */
38
+ function domainOf(entry: string): string | undefined {
39
+ const bare = entry.startsWith("@") ? entry.slice(1) : entry;
40
+ if (bare.includes("@")) return undefined;
41
+ return /^[^.\s@]+(\.[^.\s@]+)+$/.test(bare) ? bare : "";
23
42
  }
24
43
 
25
44
  /**
@@ -8,7 +8,8 @@
8
8
  *
9
9
  * Env (set on the Vercel project):
10
10
  * - GATE_SESSION_SECRET signing secret; also the gate's on and off switch
11
- * - GATE_ALLOWLIST comma separated emails allowed to receive a link, or a whole domain as @example.com
11
+ * - GATE_ALLOWLIST comma separated entries allowed to receive a link: an address,
12
+ * or the business's domain (example.com or @example.com)
12
13
  * - RESEND_API_KEY sending only Resend key
13
14
  * - GATE_FROM sender display name (optional)
14
15
  * - GATE_SUBJECT email subject (optional)
@@ -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 {};