@pithy-sh/core 0.5.0 → 0.6.1
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/dist/capability/manifest.d.ts +13 -2
- package/dist/capability/manifest.d.ts.map +1 -1
- package/dist/capability/manifest.js +15 -6
- package/dist/error/http.d.ts +84 -0
- package/dist/error/http.d.ts.map +1 -1
- package/dist/error/payload.d.ts +168 -0
- package/dist/error/payload.d.ts.map +1 -1
- package/dist/error/payload.js +56 -0
- package/dist/image/storedImage.d.ts +150 -0
- package/dist/image/storedImage.d.ts.map +1 -0
- package/dist/image/storedImage.js +181 -0
- package/dist/logger/record.d.ts +49 -0
- package/dist/logger/record.d.ts.map +1 -1
- package/dist/seed/devLogin.d.ts +16 -9
- package/dist/seed/devLogin.d.ts.map +1 -1
- package/dist/seed/devLogin.js +21 -14
- package/dist/version.generated.d.ts +1 -1
- package/dist/version.generated.js +1 -1
- package/package.json +1 -1
- package/src/capability/manifest.ts +13 -0
- package/src/error/payload.ts +120 -0
- package/src/image/storedImage.ts +209 -0
- package/src/seed/devLogin.ts +22 -16
- package/src/version.generated.ts +1 -1
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2026 Pithy
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
/**
|
|
5
|
+
* What may be stored as an image, and how it is served — stated once, for every capability that holds
|
|
6
|
+
* a small picture in a column.
|
|
7
|
+
*
|
|
8
|
+
* Two capabilities hold one: `@pithy-sh/auth` keeps a person's face, `@pithy-sh/organization` keeps an
|
|
9
|
+
* account's mark. They are the same object at different scales, and **two answers to *what may be
|
|
10
|
+
* stored as an image* is one of them being wrong.** So the allowlist, the ceiling, the derived byte
|
|
11
|
+
* figure and the serving split live here and are imported, exactly as `normalizeAddress` moved here in
|
|
12
|
+
* `#280`.
|
|
13
|
+
*
|
|
14
|
+
* ## Stored, not linked
|
|
15
|
+
*
|
|
16
|
+
* A remote URL means the page fetching an attacker-chosen host from a screen listing people, leaking
|
|
17
|
+
* the viewer's IP and referrer before they had done anything, and it needs a CSP hole to render at all.
|
|
18
|
+
* A bounded `data:` URL in a column has no third party in it.
|
|
19
|
+
*
|
|
20
|
+
* ## Rendered through `<img>`, never inlined
|
|
21
|
+
*
|
|
22
|
+
* A browser disables scripting inside an `<img>` by specification, and that is the entire basis for
|
|
23
|
+
* accepting SVG here at all. Nothing in the kit writes one of these values into a document.
|
|
24
|
+
*
|
|
25
|
+
* ## Rasters get a URL, vectors never do — and that is the security answer, not a mitigation
|
|
26
|
+
*
|
|
27
|
+
* A `data:` URL has one property it cannot have: **it cannot be cached.** It is inline in the response
|
|
28
|
+
* body, so a roster of twenty faces re-sends twenty images on every read, forever. Serving from the
|
|
29
|
+
* app's own origin fixes that and costs one real hazard — **an SVG fetched by *navigation* runs script
|
|
30
|
+
* in the origin that served it.** An `<img src>` is inert; a URL is navigable.
|
|
31
|
+
*
|
|
32
|
+
* So a vector never gets a URL. {@link storedImageBytes} answers null for one, the serving route 404s
|
|
33
|
+
* on null, and there is no arrangement of ids and versions that makes the origin return an SVG. The
|
|
34
|
+
* class of attack is removed rather than managed with headers, and there is no header anybody has to
|
|
35
|
+
* keep right.
|
|
36
|
+
*/
|
|
37
|
+
/**
|
|
38
|
+
* The image types a stored picture may be.
|
|
39
|
+
*
|
|
40
|
+
* Three rasters and one vector. The vector is here because `<img>` renders it inertly and a mark drawn
|
|
41
|
+
* as one is a few hundred bytes; every rule below that treats it differently is treating *navigability*
|
|
42
|
+
* differently, not the format.
|
|
43
|
+
*/
|
|
44
|
+
export declare const STORED_IMAGE_TYPES: readonly ["image/png", "image/jpeg", "image/webp", "image/svg+xml"];
|
|
45
|
+
/** One of {@link STORED_IMAGE_TYPES}. */
|
|
46
|
+
export type StoredImageType = (typeof STORED_IMAGE_TYPES)[number];
|
|
47
|
+
/**
|
|
48
|
+
* The types that stay inline whatever else happens.
|
|
49
|
+
*
|
|
50
|
+
* One entry, and the module note argues it at length. Written as a list rather than as a comparison so
|
|
51
|
+
* that a second scriptable format added to {@link STORED_IMAGE_TYPES} one day is added here too, next
|
|
52
|
+
* to the reason.
|
|
53
|
+
*/
|
|
54
|
+
export declare const INLINE_IMAGE_TYPES: readonly string[];
|
|
55
|
+
/**
|
|
56
|
+
* The ceiling on a stored image, in characters of `data:` URL.
|
|
57
|
+
*
|
|
58
|
+
* 32KB of base64, which is about 24KB of image. A face drawn at 34px does not need more, and the
|
|
59
|
+
* ceiling is what stops one row making every read expensive: the record, the account menu and the
|
|
60
|
+
* chooser all carry it.
|
|
61
|
+
*/
|
|
62
|
+
export declare const MAX_STORED_IMAGE_CHARS: number;
|
|
63
|
+
/**
|
|
64
|
+
* The longest `data:<type>;base64,` a stored image can begin with, in characters.
|
|
65
|
+
*
|
|
66
|
+
* Derived from the allowlist rather than written down, so a longer type name added above cannot leave a
|
|
67
|
+
* ceiling below it stale. `image/svg+xml` is the long one today, at 26 characters.
|
|
68
|
+
*/
|
|
69
|
+
export declare const LONGEST_STORED_IMAGE_PREFIX: number;
|
|
70
|
+
/**
|
|
71
|
+
* The largest file a browser may encode into that ceiling, in bytes of image.
|
|
72
|
+
*
|
|
73
|
+
* **Not `MAX_STORED_IMAGE_CHARS * 3 / 4`, and the difference is a bug that shipped once.** That is the
|
|
74
|
+
* base64 inverse, and it silently assumes the stored string is base64 and nothing else. It is not: it
|
|
75
|
+
* is `data:<type>;base64,` and *then* the base64. A file at the plain inverse encodes to 22–26
|
|
76
|
+
* characters more than the column will take, so it passes a picker's own check and is refused by Zod —
|
|
77
|
+
* the person gets a validator's sentence where the product had written them one of its own.
|
|
78
|
+
*
|
|
79
|
+
* Base64 is four characters per three bytes and rounds up to a whole group, so the arithmetic runs
|
|
80
|
+
* backwards from the characters left after the prefix: `floor((chars - prefix) / 4)` groups, three
|
|
81
|
+
* bytes each. Derived from the *longest* prefix, because one ceiling has to hold for every type a
|
|
82
|
+
* picker offers and the tightest constraint is the one that binds.
|
|
83
|
+
*
|
|
84
|
+
* **This is the figure a client-side picker checks a file against before encoding it.** The column
|
|
85
|
+
* enforces {@link MAX_STORED_IMAGE_CHARS} on the whole string, which is the bound that matters; this is
|
|
86
|
+
* the same fact stated as bytes of image, so a picker and a column cannot disagree.
|
|
87
|
+
*/
|
|
88
|
+
export declare const MAX_STORED_IMAGE_BYTES: number;
|
|
89
|
+
/**
|
|
90
|
+
* A stored image, validated at the column and therefore at every boundary that decodes a row.
|
|
91
|
+
*
|
|
92
|
+
* **The pattern is an allowlist of types, not a check that the string starts with `data:`.**
|
|
93
|
+
* `data:text/html` is a `data:` URL too, and the difference between the two is the whole of what makes
|
|
94
|
+
* this column safe to render. Anchored at both ends, so nothing follows the payload.
|
|
95
|
+
*/
|
|
96
|
+
export declare const StoredImage: z.ZodString;
|
|
97
|
+
export type StoredImage = z.output<typeof StoredImage>;
|
|
98
|
+
/** The type a stored image declares, or null when it is not a value this rule accepts. */
|
|
99
|
+
export declare function typeOfStoredImage(stored: string): StoredImageType | null;
|
|
100
|
+
/**
|
|
101
|
+
* What a screen should draw this image from.
|
|
102
|
+
*
|
|
103
|
+
* A URL for a raster, the stored value itself for a vector, and null for nothing. The caller renders
|
|
104
|
+
* whichever it gets through the same `<img src>`, so no screen has to know which it was handed.
|
|
105
|
+
*
|
|
106
|
+
* `path` is the route the owning capability serves bytes from, already carrying whatever identifies the
|
|
107
|
+
* subject — this function appends only the version, because the version is the half that has to be
|
|
108
|
+
* right for `immutable` to be honest.
|
|
109
|
+
*
|
|
110
|
+
* The version is the owning row's `updatedAt`: the URL changes whenever the image can have changed, so
|
|
111
|
+
* the response may be `immutable` and a browser never revalidates. It over-invalidates slightly — a
|
|
112
|
+
* rename busts a picture that did not change — which is one wasted fetch on a rare action, against a
|
|
113
|
+
* hash column and a migration to carry it.
|
|
114
|
+
*/
|
|
115
|
+
export declare function storedImageSource(stored: string | null, path: string, version: Date | number): string | null;
|
|
116
|
+
/** A stored image decoded into what a response body needs. */
|
|
117
|
+
export interface StoredImageBytes {
|
|
118
|
+
/** The `Content-Type` to serve it as. Always one of {@link STORED_IMAGE_TYPES}, never sniffed. */
|
|
119
|
+
readonly type: StoredImageType;
|
|
120
|
+
/** The image itself. */
|
|
121
|
+
readonly body: Uint8Array;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Decode a stored image for serving, or null when it must not be served.
|
|
125
|
+
*
|
|
126
|
+
* **Null for a vector, and that is the gate rather than a caution.** The route asks this and answers
|
|
127
|
+
* 404 when it gets null, so there is no arrangement of ids and versions that makes the origin return an
|
|
128
|
+
* SVG. The module note gives the reason.
|
|
129
|
+
*
|
|
130
|
+
* Null too for anything the allowlist does not match, which the column should have refused on the way
|
|
131
|
+
* in — this is the second place that is true, and a value that reached the column past a bug does not
|
|
132
|
+
* get served out of it.
|
|
133
|
+
*/
|
|
134
|
+
export declare function storedImageBytes(stored: string | null): StoredImageBytes | null;
|
|
135
|
+
/**
|
|
136
|
+
* The headers a served image carries.
|
|
137
|
+
*
|
|
138
|
+
* **`immutable`, which is only honest because the URL carries a version.** {@link storedImageSource}
|
|
139
|
+
* puts the owning row's `updatedAt` in the query, so a changed image is a different URL and a browser
|
|
140
|
+
* that never revalidates can never show a stale one.
|
|
141
|
+
*
|
|
142
|
+
* **`private`, because the fetch is authorized against a session.** A shared cache holding this would
|
|
143
|
+
* be one person's face served to whoever asked next.
|
|
144
|
+
*
|
|
145
|
+
* **`nosniff`, because the type is the allowlist's and must not be re-guessed.** Content sniffing is
|
|
146
|
+
* how a file served as an image gets treated as something else, and the whole safety of this route is
|
|
147
|
+
* that the type is one of three rasters.
|
|
148
|
+
*/
|
|
149
|
+
export declare const STORED_IMAGE_HEADERS: Readonly<Record<string, string>>;
|
|
150
|
+
//# sourceMappingURL=storedImage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storedImage.d.ts","sourceRoot":"","sources":["../../src/image/storedImage.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,YAAI,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,eAAe,CAAU,CAAC;AAEtG,yCAAyC;AACzC,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC;AAElE;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,EAAE,SAAS,MAAM,EAAsB,CAAC;AAEvE;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,QAAY,CAAC;AAEhD;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,QAA+E,CAAC;AAExH;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,sBAAsB,QAA6E,CAAC;AAOjH;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,aAMrB,CAAC;AACJ,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,WAAW,CAAC,CAAC;AAOvD,0FAA0F;AAC1F,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,eAAe,GAAG,IAAI,CAExE;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,CAU5G;AAED,8DAA8D;AAC9D,MAAM,WAAW,gBAAgB;IAC/B,kGAAkG;IAClG,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;IAC/B,wBAAwB;IACxB,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;CAC3B;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,gBAAgB,GAAG,IAAI,CAe/E;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAGjE,CAAC"}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2026 Pithy
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
//#region src/image/storedImage.ts
|
|
5
|
+
/**
|
|
6
|
+
* What may be stored as an image, and how it is served — stated once, for every capability that holds
|
|
7
|
+
* a small picture in a column.
|
|
8
|
+
*
|
|
9
|
+
* Two capabilities hold one: `@pithy-sh/auth` keeps a person's face, `@pithy-sh/organization` keeps an
|
|
10
|
+
* account's mark. They are the same object at different scales, and **two answers to *what may be
|
|
11
|
+
* stored as an image* is one of them being wrong.** So the allowlist, the ceiling, the derived byte
|
|
12
|
+
* figure and the serving split live here and are imported, exactly as `normalizeAddress` moved here in
|
|
13
|
+
* `#280`.
|
|
14
|
+
*
|
|
15
|
+
* ## Stored, not linked
|
|
16
|
+
*
|
|
17
|
+
* A remote URL means the page fetching an attacker-chosen host from a screen listing people, leaking
|
|
18
|
+
* the viewer's IP and referrer before they had done anything, and it needs a CSP hole to render at all.
|
|
19
|
+
* A bounded `data:` URL in a column has no third party in it.
|
|
20
|
+
*
|
|
21
|
+
* ## Rendered through `<img>`, never inlined
|
|
22
|
+
*
|
|
23
|
+
* A browser disables scripting inside an `<img>` by specification, and that is the entire basis for
|
|
24
|
+
* accepting SVG here at all. Nothing in the kit writes one of these values into a document.
|
|
25
|
+
*
|
|
26
|
+
* ## Rasters get a URL, vectors never do — and that is the security answer, not a mitigation
|
|
27
|
+
*
|
|
28
|
+
* A `data:` URL has one property it cannot have: **it cannot be cached.** It is inline in the response
|
|
29
|
+
* body, so a roster of twenty faces re-sends twenty images on every read, forever. Serving from the
|
|
30
|
+
* app's own origin fixes that and costs one real hazard — **an SVG fetched by *navigation* runs script
|
|
31
|
+
* in the origin that served it.** An `<img src>` is inert; a URL is navigable.
|
|
32
|
+
*
|
|
33
|
+
* So a vector never gets a URL. {@link storedImageBytes} answers null for one, the serving route 404s
|
|
34
|
+
* on null, and there is no arrangement of ids and versions that makes the origin return an SVG. The
|
|
35
|
+
* class of attack is removed rather than managed with headers, and there is no header anybody has to
|
|
36
|
+
* keep right.
|
|
37
|
+
*/
|
|
38
|
+
/**
|
|
39
|
+
* The image types a stored picture may be.
|
|
40
|
+
*
|
|
41
|
+
* Three rasters and one vector. The vector is here because `<img>` renders it inertly and a mark drawn
|
|
42
|
+
* as one is a few hundred bytes; every rule below that treats it differently is treating *navigability*
|
|
43
|
+
* differently, not the format.
|
|
44
|
+
*/
|
|
45
|
+
const STORED_IMAGE_TYPES = [
|
|
46
|
+
"image/png",
|
|
47
|
+
"image/jpeg",
|
|
48
|
+
"image/webp",
|
|
49
|
+
"image/svg+xml"
|
|
50
|
+
];
|
|
51
|
+
/**
|
|
52
|
+
* The types that stay inline whatever else happens.
|
|
53
|
+
*
|
|
54
|
+
* One entry, and the module note argues it at length. Written as a list rather than as a comparison so
|
|
55
|
+
* that a second scriptable format added to {@link STORED_IMAGE_TYPES} one day is added here too, next
|
|
56
|
+
* to the reason.
|
|
57
|
+
*/
|
|
58
|
+
const INLINE_IMAGE_TYPES = ["image/svg+xml"];
|
|
59
|
+
/**
|
|
60
|
+
* The ceiling on a stored image, in characters of `data:` URL.
|
|
61
|
+
*
|
|
62
|
+
* 32KB of base64, which is about 24KB of image. A face drawn at 34px does not need more, and the
|
|
63
|
+
* ceiling is what stops one row making every read expensive: the record, the account menu and the
|
|
64
|
+
* chooser all carry it.
|
|
65
|
+
*/
|
|
66
|
+
const MAX_STORED_IMAGE_CHARS = 32768;
|
|
67
|
+
/**
|
|
68
|
+
* The longest `data:<type>;base64,` a stored image can begin with, in characters.
|
|
69
|
+
*
|
|
70
|
+
* Derived from the allowlist rather than written down, so a longer type name added above cannot leave a
|
|
71
|
+
* ceiling below it stale. `image/svg+xml` is the long one today, at 26 characters.
|
|
72
|
+
*/
|
|
73
|
+
const LONGEST_STORED_IMAGE_PREFIX = Math.max(...STORED_IMAGE_TYPES.map((type) => `data:${type};base64,`.length));
|
|
74
|
+
/**
|
|
75
|
+
* The largest file a browser may encode into that ceiling, in bytes of image.
|
|
76
|
+
*
|
|
77
|
+
* **Not `MAX_STORED_IMAGE_CHARS * 3 / 4`, and the difference is a bug that shipped once.** That is the
|
|
78
|
+
* base64 inverse, and it silently assumes the stored string is base64 and nothing else. It is not: it
|
|
79
|
+
* is `data:<type>;base64,` and *then* the base64. A file at the plain inverse encodes to 22–26
|
|
80
|
+
* characters more than the column will take, so it passes a picker's own check and is refused by Zod —
|
|
81
|
+
* the person gets a validator's sentence where the product had written them one of its own.
|
|
82
|
+
*
|
|
83
|
+
* Base64 is four characters per three bytes and rounds up to a whole group, so the arithmetic runs
|
|
84
|
+
* backwards from the characters left after the prefix: `floor((chars - prefix) / 4)` groups, three
|
|
85
|
+
* bytes each. Derived from the *longest* prefix, because one ceiling has to hold for every type a
|
|
86
|
+
* picker offers and the tightest constraint is the one that binds.
|
|
87
|
+
*
|
|
88
|
+
* **This is the figure a client-side picker checks a file against before encoding it.** The column
|
|
89
|
+
* enforces {@link MAX_STORED_IMAGE_CHARS} on the whole string, which is the bound that matters; this is
|
|
90
|
+
* the same fact stated as bytes of image, so a picker and a column cannot disagree.
|
|
91
|
+
*/
|
|
92
|
+
const MAX_STORED_IMAGE_BYTES = 3 * Math.floor((MAX_STORED_IMAGE_CHARS - LONGEST_STORED_IMAGE_PREFIX) / 4);
|
|
93
|
+
/** `data:<type>;base64,<payload>` and nothing else — no bare URL, no `data:text/html`, no charset games. */
|
|
94
|
+
const STORED_IMAGE_PATTERN = new RegExp(`^data:(?:${STORED_IMAGE_TYPES.join("|").replace(/\+/g, "\\+")});base64,[A-Za-z0-9+/]+=*$`);
|
|
95
|
+
/**
|
|
96
|
+
* A stored image, validated at the column and therefore at every boundary that decodes a row.
|
|
97
|
+
*
|
|
98
|
+
* **The pattern is an allowlist of types, not a check that the string starts with `data:`.**
|
|
99
|
+
* `data:text/html` is a `data:` URL too, and the difference between the two is the whole of what makes
|
|
100
|
+
* this column safe to render. Anchored at both ends, so nothing follows the payload.
|
|
101
|
+
*/
|
|
102
|
+
const StoredImage = z.string().max(MAX_STORED_IMAGE_CHARS).regex(STORED_IMAGE_PATTERN).describe("An image held as a base64 `data:` URL of an allowed type, bounded to 32KB. Stored rather than linked, and rendered only through `<img>` — see `@pithy-sh/core/src/image/storedImage`.");
|
|
103
|
+
/** The `data:` prefix a stored image of `type` begins with. */
|
|
104
|
+
function prefixOf(type) {
|
|
105
|
+
return `data:${type};base64,`;
|
|
106
|
+
}
|
|
107
|
+
/** The type a stored image declares, or null when it is not a value this rule accepts. */
|
|
108
|
+
function typeOfStoredImage(stored) {
|
|
109
|
+
return STORED_IMAGE_TYPES.find((type) => stored.startsWith(prefixOf(type))) ?? null;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* What a screen should draw this image from.
|
|
113
|
+
*
|
|
114
|
+
* A URL for a raster, the stored value itself for a vector, and null for nothing. The caller renders
|
|
115
|
+
* whichever it gets through the same `<img src>`, so no screen has to know which it was handed.
|
|
116
|
+
*
|
|
117
|
+
* `path` is the route the owning capability serves bytes from, already carrying whatever identifies the
|
|
118
|
+
* subject — this function appends only the version, because the version is the half that has to be
|
|
119
|
+
* right for `immutable` to be honest.
|
|
120
|
+
*
|
|
121
|
+
* The version is the owning row's `updatedAt`: the URL changes whenever the image can have changed, so
|
|
122
|
+
* the response may be `immutable` and a browser never revalidates. It over-invalidates slightly — a
|
|
123
|
+
* rename busts a picture that did not change — which is one wasted fetch on a rare action, against a
|
|
124
|
+
* hash column and a migration to carry it.
|
|
125
|
+
*/
|
|
126
|
+
function storedImageSource(stored, path, version) {
|
|
127
|
+
if (stored === null) return null;
|
|
128
|
+
const type = typeOfStoredImage(stored);
|
|
129
|
+
if (type === null) return null;
|
|
130
|
+
if (INLINE_IMAGE_TYPES.includes(type)) return stored;
|
|
131
|
+
return `${path}?v=${version instanceof Date ? version.getTime() : version}`;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Decode a stored image for serving, or null when it must not be served.
|
|
135
|
+
*
|
|
136
|
+
* **Null for a vector, and that is the gate rather than a caution.** The route asks this and answers
|
|
137
|
+
* 404 when it gets null, so there is no arrangement of ids and versions that makes the origin return an
|
|
138
|
+
* SVG. The module note gives the reason.
|
|
139
|
+
*
|
|
140
|
+
* Null too for anything the allowlist does not match, which the column should have refused on the way
|
|
141
|
+
* in — this is the second place that is true, and a value that reached the column past a bug does not
|
|
142
|
+
* get served out of it.
|
|
143
|
+
*/
|
|
144
|
+
function storedImageBytes(stored) {
|
|
145
|
+
if (stored === null) return null;
|
|
146
|
+
const type = typeOfStoredImage(stored);
|
|
147
|
+
if (type === null || INLINE_IMAGE_TYPES.includes(type)) return null;
|
|
148
|
+
const payload = stored.slice(prefixOf(type).length);
|
|
149
|
+
let binary;
|
|
150
|
+
try {
|
|
151
|
+
binary = atob(payload);
|
|
152
|
+
} catch {
|
|
153
|
+
return null;
|
|
154
|
+
}
|
|
155
|
+
const body = new Uint8Array(binary.length);
|
|
156
|
+
for (let at = 0; at < binary.length; at += 1) body[at] = binary.charCodeAt(at);
|
|
157
|
+
return {
|
|
158
|
+
type,
|
|
159
|
+
body
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* The headers a served image carries.
|
|
164
|
+
*
|
|
165
|
+
* **`immutable`, which is only honest because the URL carries a version.** {@link storedImageSource}
|
|
166
|
+
* puts the owning row's `updatedAt` in the query, so a changed image is a different URL and a browser
|
|
167
|
+
* that never revalidates can never show a stale one.
|
|
168
|
+
*
|
|
169
|
+
* **`private`, because the fetch is authorized against a session.** A shared cache holding this would
|
|
170
|
+
* be one person's face served to whoever asked next.
|
|
171
|
+
*
|
|
172
|
+
* **`nosniff`, because the type is the allowlist's and must not be re-guessed.** Content sniffing is
|
|
173
|
+
* how a file served as an image gets treated as something else, and the whole safety of this route is
|
|
174
|
+
* that the type is one of three rasters.
|
|
175
|
+
*/
|
|
176
|
+
const STORED_IMAGE_HEADERS = {
|
|
177
|
+
"cache-control": "private, max-age=31536000, immutable",
|
|
178
|
+
"x-content-type-options": "nosniff"
|
|
179
|
+
};
|
|
180
|
+
//#endregion
|
|
181
|
+
export { INLINE_IMAGE_TYPES, LONGEST_STORED_IMAGE_PREFIX, MAX_STORED_IMAGE_BYTES, MAX_STORED_IMAGE_CHARS, STORED_IMAGE_HEADERS, STORED_IMAGE_TYPES, StoredImage, storedImageBytes, storedImageSource, typeOfStoredImage };
|
package/dist/logger/record.d.ts
CHANGED
|
@@ -798,6 +798,55 @@ export declare const LogRecord: z.ZodObject<{
|
|
|
798
798
|
detail: z.ZodOptional<z.ZodString>;
|
|
799
799
|
code: z.ZodLiteral<"controlplane/key_conflict">;
|
|
800
800
|
status: z.ZodLiteral<409>;
|
|
801
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
802
|
+
message: z.ZodString;
|
|
803
|
+
params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
|
|
804
|
+
action: z.ZodOptional<z.ZodString>;
|
|
805
|
+
detail: z.ZodOptional<z.ZodString>;
|
|
806
|
+
code: z.ZodLiteral<"organization/not_found">;
|
|
807
|
+
status: z.ZodLiteral<404>;
|
|
808
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
809
|
+
message: z.ZodString;
|
|
810
|
+
params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
|
|
811
|
+
action: z.ZodOptional<z.ZodString>;
|
|
812
|
+
detail: z.ZodOptional<z.ZodString>;
|
|
813
|
+
code: z.ZodLiteral<"organization/forbidden">;
|
|
814
|
+
status: z.ZodLiteral<403>;
|
|
815
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
816
|
+
message: z.ZodString;
|
|
817
|
+
params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
|
|
818
|
+
action: z.ZodOptional<z.ZodString>;
|
|
819
|
+
detail: z.ZodOptional<z.ZodString>;
|
|
820
|
+
code: z.ZodLiteral<"organization/invalid_role_catalog">;
|
|
821
|
+
status: z.ZodLiteral<400>;
|
|
822
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
823
|
+
message: z.ZodString;
|
|
824
|
+
params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
|
|
825
|
+
action: z.ZodOptional<z.ZodString>;
|
|
826
|
+
detail: z.ZodOptional<z.ZodString>;
|
|
827
|
+
code: z.ZodLiteral<"organization/invitation_invalid">;
|
|
828
|
+
status: z.ZodLiteral<400>;
|
|
829
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
830
|
+
message: z.ZodString;
|
|
831
|
+
params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
|
|
832
|
+
action: z.ZodOptional<z.ZodString>;
|
|
833
|
+
detail: z.ZodOptional<z.ZodString>;
|
|
834
|
+
code: z.ZodLiteral<"organization/last_administrator">;
|
|
835
|
+
status: z.ZodLiteral<409>;
|
|
836
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
837
|
+
message: z.ZodString;
|
|
838
|
+
params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
|
|
839
|
+
action: z.ZodOptional<z.ZodString>;
|
|
840
|
+
detail: z.ZodOptional<z.ZodString>;
|
|
841
|
+
code: z.ZodLiteral<"organization/slug_taken">;
|
|
842
|
+
status: z.ZodLiteral<409>;
|
|
843
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
844
|
+
message: z.ZodString;
|
|
845
|
+
params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
|
|
846
|
+
action: z.ZodOptional<z.ZodString>;
|
|
847
|
+
detail: z.ZodOptional<z.ZodString>;
|
|
848
|
+
code: z.ZodLiteral<"organization/nomination_invalid">;
|
|
849
|
+
status: z.ZodLiteral<400>;
|
|
801
850
|
}, z.core.$strip>, z.ZodObject<{
|
|
802
851
|
message: z.ZodString;
|
|
803
852
|
params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"record.d.ts","sourceRoot":"","sources":["../../src/logger/record.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB;;;;;GAKG;AAEH,4GAA4G;AAC5G,eAAO,MAAM,QAAQ;;;;;EAE4F,CAAC;AAClH,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,QAAQ,CAAC,CAAC;AAEjD;;;GAGG;AACH,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAgD,CAAC;AAEtG;;;;GAIG;AACH,eAAO,MAAM,SAAS,wCAEsF,CAAC;AAC7G,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,SAAS,CAAC,CAAC;AAEnD;;;;;GAKG;AACH,eAAO,MAAM,SAAS
|
|
1
|
+
{"version":3,"file":"record.d.ts","sourceRoot":"","sources":["../../src/logger/record.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB;;;;;GAKG;AAEH,4GAA4G;AAC5G,eAAO,MAAM,QAAQ;;;;;EAE4F,CAAC;AAClH,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,QAAQ,CAAC,CAAC;AAEjD;;;GAGG;AACH,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAgD,CAAC;AAEtG;;;;GAIG;AACH,eAAO,MAAM,SAAS,wCAEsF,CAAC;AAC7G,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,SAAS,CAAC,CAAC;AAEnD;;;;;GAKG;AACH,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAW+E,CAAC;AACtG,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,SAAS,CAAC,CAAC;AAmBnD;;;GAGG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM,CAMzD"}
|
package/dist/seed/devLogin.d.ts
CHANGED
|
@@ -9,10 +9,16 @@ import { z } from "zod";
|
|
|
9
9
|
* the seam they already share, so the shape is stated once instead of being duplicated (and drifting) at
|
|
10
10
|
* both ends.
|
|
11
11
|
*
|
|
12
|
-
* **The file holds a live credential.** A signed
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
12
|
+
* **The file holds a live credential.** A signed claim for a local database is a way in for anyone who
|
|
13
|
+
* can read it, which is why it is written under `logs/` — gitignored by the starter template, so it can
|
|
14
|
+
* never be committed — and why nothing here is ever put in a `PithyError` (the payload reaches logs
|
|
15
|
+
* verbatim).
|
|
16
|
+
*
|
|
17
|
+
* **It used to hold a session cookie, and now it holds a claim — `#572`.** The difference is what
|
|
18
|
+
* survives: a cookie names a row in `pithy_auth_sessions`, so signing out of the app revoked it and the
|
|
19
|
+
* dev login 404'd until somebody reseeded. A claim names a *user*, signed with the session secret, and
|
|
20
|
+
* the route exchanges it for a fresh session on every open. Sign-out then revokes the session it should
|
|
21
|
+
* revoke and leaves the way back in alone.
|
|
16
22
|
*/
|
|
17
23
|
/** The directory seed artifacts are written to, relative to the project root. Gitignored, so transient. */
|
|
18
24
|
export declare const SEED_ARTIFACT_DIR = "logs";
|
|
@@ -32,11 +38,13 @@ export declare const DEV_LOGIN_PATH = "logs/dev-login.json";
|
|
|
32
38
|
* anything the kit serves that is not part of a capability's public surface lives under this prefix, so
|
|
33
39
|
* a route added here can never collide with an application path someone already shipped.
|
|
34
40
|
*
|
|
35
|
-
* Registered **only** in a `dev` composition, and never under CI. It mints an authenticated session
|
|
36
|
-
*
|
|
37
|
-
* registration rather than inside the handler.
|
|
41
|
+
* Registered **only** in a `dev` composition, and never under CI. It mints an authenticated session for
|
|
42
|
+
* whoever presents a claim this project's own secret signed, which is the whole risk of the feature and
|
|
43
|
+
* the reason its gates live at registration rather than inside the handler.
|
|
38
44
|
*/
|
|
39
45
|
export declare const DEV_LOGIN_ROUTE = "/__pithy/dev-login";
|
|
46
|
+
/** The query parameter {@link DEV_LOGIN_ROUTE} takes the claim in. Spelled once, read by both ends. */
|
|
47
|
+
export declare const DEV_LOGIN_CLAIM_PARAM = "t";
|
|
40
48
|
/**
|
|
41
49
|
* A seeded dev login — everything a browser needs to be signed in as a seeded user, and nothing else.
|
|
42
50
|
* `z.input` is the JSON on disk (dates as ISO-8601 strings); `z.output` is the app shape.
|
|
@@ -44,8 +52,7 @@ export declare const DEV_LOGIN_ROUTE = "/__pithy/dev-login";
|
|
|
44
52
|
export declare const DevLogin: z.ZodObject<{
|
|
45
53
|
email: z.ZodString;
|
|
46
54
|
userId: z.ZodString;
|
|
47
|
-
|
|
48
|
-
cookieValue: z.ZodString;
|
|
55
|
+
claim: z.ZodString;
|
|
49
56
|
expiresAt: z.ZodCodec<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodDate]>, z.ZodDate>;
|
|
50
57
|
}, z.core.$strip>;
|
|
51
58
|
export type DevLogin = z.output<typeof DevLogin>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"devLogin.d.ts","sourceRoot":"","sources":["../../src/seed/devLogin.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB
|
|
1
|
+
{"version":3,"file":"devLogin.d.ts","sourceRoot":"","sources":["../../src/seed/devLogin.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB;;;;;;;;;;;;;;;;;;GAkBG;AAEH,2GAA2G;AAC3G,eAAO,MAAM,iBAAiB,SAAS,CAAC;AAExC,gHAAgH;AAChH,eAAO,MAAM,cAAc,mBAAmB,CAAC;AAE/C,uGAAuG;AACvG,eAAO,MAAM,cAAc,wBAA2C,CAAC;AAEvE;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,eAAe,uBAAuB,CAAC;AAEpD,uGAAuG;AACvG,eAAO,MAAM,qBAAqB,MAAM,CAAC;AAEzC;;;GAGG;AACH,eAAO,MAAM,QAAQ;;;;;iBAWqF,CAAC;AAC3G,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,QAAQ,CAAC,CAAC"}
|
package/dist/seed/devLogin.js
CHANGED
|
@@ -11,10 +11,16 @@ import { z } from "zod";
|
|
|
11
11
|
* the seam they already share, so the shape is stated once instead of being duplicated (and drifting) at
|
|
12
12
|
* both ends.
|
|
13
13
|
*
|
|
14
|
-
* **The file holds a live credential.** A signed
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
14
|
+
* **The file holds a live credential.** A signed claim for a local database is a way in for anyone who
|
|
15
|
+
* can read it, which is why it is written under `logs/` — gitignored by the starter template, so it can
|
|
16
|
+
* never be committed — and why nothing here is ever put in a `PithyError` (the payload reaches logs
|
|
17
|
+
* verbatim).
|
|
18
|
+
*
|
|
19
|
+
* **It used to hold a session cookie, and now it holds a claim — `#572`.** The difference is what
|
|
20
|
+
* survives: a cookie names a row in `pithy_auth_sessions`, so signing out of the app revoked it and the
|
|
21
|
+
* dev login 404'd until somebody reseeded. A claim names a *user*, signed with the session secret, and
|
|
22
|
+
* the route exchanges it for a fresh session on every open. Sign-out then revokes the session it should
|
|
23
|
+
* revoke and leaves the way back in alone.
|
|
18
24
|
*/
|
|
19
25
|
/** The directory seed artifacts are written to, relative to the project root. Gitignored, so transient. */
|
|
20
26
|
const SEED_ARTIFACT_DIR = "logs";
|
|
@@ -34,21 +40,22 @@ const DEV_LOGIN_PATH = `${SEED_ARTIFACT_DIR}/${DEV_LOGIN_FILE}`;
|
|
|
34
40
|
* anything the kit serves that is not part of a capability's public surface lives under this prefix, so
|
|
35
41
|
* a route added here can never collide with an application path someone already shipped.
|
|
36
42
|
*
|
|
37
|
-
* Registered **only** in a `dev` composition, and never under CI. It mints an authenticated session
|
|
38
|
-
*
|
|
39
|
-
* registration rather than inside the handler.
|
|
43
|
+
* Registered **only** in a `dev` composition, and never under CI. It mints an authenticated session for
|
|
44
|
+
* whoever presents a claim this project's own secret signed, which is the whole risk of the feature and
|
|
45
|
+
* the reason its gates live at registration rather than inside the handler.
|
|
40
46
|
*/
|
|
41
47
|
const DEV_LOGIN_ROUTE = "/__pithy/dev-login";
|
|
48
|
+
/** The query parameter {@link DEV_LOGIN_ROUTE} takes the claim in. Spelled once, read by both ends. */
|
|
49
|
+
const DEV_LOGIN_CLAIM_PARAM = "t";
|
|
42
50
|
/**
|
|
43
51
|
* A seeded dev login — everything a browser needs to be signed in as a seeded user, and nothing else.
|
|
44
52
|
* `z.input` is the JSON on disk (dates as ISO-8601 strings); `z.output` is the app shape.
|
|
45
53
|
*/
|
|
46
54
|
const DevLogin = z.object({
|
|
47
|
-
email: z.string().describe("The seeded user this
|
|
48
|
-
userId: z.string().describe("The seeded user's id, so a tool can correlate the
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}).describe("A seeded dev login: the signed session cookie for one seeded user, written to `logs/dev-login.json`.");
|
|
55
|
+
email: z.string().describe("The seeded user this claim signs in as. Shown on the `pithy dev` ready banner."),
|
|
56
|
+
userId: z.string().describe("The seeded user's id, so a tool can correlate the login with the seeded rows."),
|
|
57
|
+
claim: z.string().describe("The signed, URI-encoded claim naming the user to sign in as. A live credential for the local database — never logged, never committed, never in an error payload. **Not a session:** it names a user and the route mints a session against it, so revoking a session leaves it working."),
|
|
58
|
+
expiresAt: JsonDate.describe("When the claim stops being accepted. ISO-8601 text on disk; a `Date` in app code.")
|
|
59
|
+
}).describe("A seeded dev login: the signed claim for one seeded user, written to `logs/dev-login.json`.");
|
|
53
60
|
//#endregion
|
|
54
|
-
export { DEV_LOGIN_FILE, DEV_LOGIN_PATH, DEV_LOGIN_ROUTE, DevLogin, SEED_ARTIFACT_DIR };
|
|
61
|
+
export { DEV_LOGIN_CLAIM_PARAM, DEV_LOGIN_FILE, DEV_LOGIN_PATH, DEV_LOGIN_ROUTE, DevLogin, SEED_ARTIFACT_DIR };
|
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
/** This package's npm name — the join key against a release feed. */
|
|
4
4
|
export declare const PACKAGE_NAME = "@pithy-sh/core";
|
|
5
5
|
/** This package's version, stamped from its own package.json at generation time. */
|
|
6
|
-
export declare const PACKAGE_VERSION = "0.
|
|
6
|
+
export declare const PACKAGE_VERSION = "0.6.1";
|
|
7
7
|
//# sourceMappingURL=version.generated.d.ts.map
|
|
@@ -4,6 +4,6 @@
|
|
|
4
4
|
/** This package's npm name — the join key against a release feed. */
|
|
5
5
|
const PACKAGE_NAME = "@pithy-sh/core";
|
|
6
6
|
/** This package's version, stamped from its own package.json at generation time. */
|
|
7
|
-
const PACKAGE_VERSION = "0.
|
|
7
|
+
const PACKAGE_VERSION = "0.6.1";
|
|
8
8
|
//#endregion
|
|
9
9
|
export { PACKAGE_NAME, PACKAGE_VERSION };
|
package/package.json
CHANGED
|
@@ -497,6 +497,13 @@ export const CONFIG_SEAMS = {
|
|
|
497
497
|
describe:
|
|
498
498
|
"Which organization this caller is acting for. Scaffolded unimplemented — this Worker refuses to boot until src/billing/subject.ts answers it.",
|
|
499
499
|
},
|
|
500
|
+
organizationRoles: {
|
|
501
|
+
binding: "roles",
|
|
502
|
+
module: "src/organization/roles.ts",
|
|
503
|
+
specifier: "./src/organization/roles",
|
|
504
|
+
describe:
|
|
505
|
+
"Who may do what here. Scaffolded with a starter matrix — the role names and the powers they hold are this product's, and only this project's code can state them.",
|
|
506
|
+
},
|
|
500
507
|
} as const satisfies Record<string, ConfigSeamSpec>;
|
|
501
508
|
|
|
502
509
|
/** Which scaffolded seam a choice needs, by key. */
|
|
@@ -681,6 +688,12 @@ export const CapabilityManifest = z
|
|
|
681
688
|
.describe(
|
|
682
689
|
"Every secret from this capability's registry that declares how it comes to exist and how it is replaced. The route `devSecrets` proved: a client reads it without executing the package, so `pithy doctor` says *not set — run this* or *not set — get it here*, and no client keeps its own table of names. A secret declaring neither axis is absent, which reads as *nothing is known*, not as *nothing can help*.",
|
|
683
690
|
),
|
|
691
|
+
seams: z
|
|
692
|
+
.array(ConfigSeam)
|
|
693
|
+
.default([])
|
|
694
|
+
.describe(
|
|
695
|
+
"Seams this capability needs **always**, rather than under one choice of one option. `pithy add` writes each module into the Worker, imports it, and passes it to the factory beside the config values — the same machinery `choicesNeedingSeam` drives, without the condition. `organization`'s role catalog is the one: a tenancy capability has no answer to *who may do what* that is not the adopter's, so there is no configuration under which the module is unnecessary and nothing to make it conditional on. Named from `CONFIG_SEAMS`, so nothing a manifest states is written into generated source unquoted (#183).",
|
|
696
|
+
),
|
|
684
697
|
scaffold: z.array(z.string()).default([]).describe("Human-readable scaffold steps the CLI performs or explains."),
|
|
685
698
|
configOptions: z
|
|
686
699
|
.array(ConfigOption)
|