@atelic-action/ui 3.17.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 +3 -3
- package/bin/atelic-reader-link.ts +1 -1
- package/dist/artifact/readers.d.ts +20 -26
- package/dist/artifact/readers.js +18 -101
- package/package.json +2 -4
- package/src/artifact/artifactConfig.ts +2 -22
- package/src/artifact/index.ts +1 -9
- package/src/artifact/readers.ts +17 -126
- package/src/scripts/reader-link.ts +81 -74
- package/dist/artifact/artifactConfig.d.ts +0 -138
- package/dist/artifact/artifactConfig.js +0 -10
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
|
-
| `
|
|
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) |
|
|
@@ -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:** `
|
|
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] [--
|
|
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] [--
|
|
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
|
-
*
|
|
12
|
-
*
|
|
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
|
-
*
|
|
15
|
-
*
|
|
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
|
-
*
|
|
23
|
-
*
|
|
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
|
-
}):
|
|
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;
|
package/dist/artifact/readers.js
CHANGED
|
@@ -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
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
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
|
|
22
|
-
*
|
|
23
|
-
*
|
|
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
|
-
*
|
|
90
|
-
*
|
|
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
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
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
|
+
"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
|
-
*
|
|
117
|
-
*
|
|
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;
|
package/src/artifact/index.ts
CHANGED
|
@@ -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";
|
package/src/artifact/readers.ts
CHANGED
|
@@ -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
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
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
|
|
24
|
-
*
|
|
25
|
-
*
|
|
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
|
-
*
|
|
113
|
-
*
|
|
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
|
|
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
|
-
}):
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
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
|
}
|
|
@@ -1,108 +1,115 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Mint
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
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
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
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
|
-
*
|
|
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
|
|
22
|
-
*
|
|
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 {
|
|
26
|
-
import
|
|
27
|
-
import {
|
|
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
|
-
|
|
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
|
|
36
|
+
/** The page the link lands on, one leading slash, its query kept. */
|
|
37
37
|
path: string;
|
|
38
|
-
/**
|
|
39
|
-
|
|
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
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
const
|
|
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
|
-
|
|
56
|
-
const path = `/${givenPath.replace(/^\/+|\/+$/g, "")}`;
|
|
49
|
+
if (!email?.includes("@") || rest.length > 2) return undefined;
|
|
57
50
|
|
|
58
|
-
|
|
59
|
-
|
|
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
|
|
64
|
-
*
|
|
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 {};
|