astronaut-cms 0.0.1 → 1.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/LICENSE +21 -0
- package/README.md +84 -3
- package/dist/admin/THIRD_PARTY_LICENSES.md +7598 -0
- package/dist/admin/assets/assistant-DkS355co.js +201 -0
- package/dist/admin/assets/badge-BXsOvOPX.js +1 -0
- package/dist/admin/assets/changes-Ba0G_GN1.js +1 -0
- package/dist/admin/assets/client-VKp75fDU.js +5 -0
- package/dist/admin/assets/clsx-DB0hHKMi.js +1 -0
- package/dist/admin/assets/collapsible-B6P_J0Bg.js +1 -0
- package/dist/admin/assets/collapsible-item-UaoJaaPw.js +1 -0
- package/dist/admin/assets/collections._collection-BE1enDCq.js +1 -0
- package/dist/admin/assets/collections._collection._entry-D3UksnCo.js +52 -0
- package/dist/admin/assets/collections._collection.index-BN5d8UIY.js +1 -0
- package/dist/admin/assets/component-lookup-CUCiK8Xh.js +4 -0
- package/dist/admin/assets/config-Pm_BHLNT.js +1 -0
- package/dist/admin/assets/copy-DezZzPMV.js +1 -0
- package/dist/admin/assets/css-BGIxQoYs.js +1 -0
- package/dist/admin/assets/css-DgaLhXQH.js +1 -0
- package/dist/admin/assets/diff-woXpYk--.js +1 -0
- package/dist/admin/assets/dist-DzkcSBZl.js +1 -0
- package/dist/admin/assets/dist-UbA1s2kM.js +1 -0
- package/dist/admin/assets/docx-BctAmX91.js +56 -0
- package/dist/admin/assets/editor-FGqMznBK.js +2 -0
- package/dist/admin/assets/empty-DSBYiI_7.js +1 -0
- package/dist/admin/assets/entry-link-CQLN2Zpf.js +158 -0
- package/dist/admin/assets/error-banner-yskeRXe8.js +159 -0
- package/dist/admin/assets/errors-DkJ5E_ak.js +1 -0
- package/dist/admin/assets/field-BDK5tt3J.js +41 -0
- package/dist/admin/assets/field-schema-CacrjSYw.js +1 -0
- package/dist/admin/assets/file-text-BzBif8ui.js +1 -0
- package/dist/admin/assets/github-dark-C-LZuMrd.js +1 -0
- package/dist/admin/assets/github-light-EUqPIrTm.js +1 -0
- package/dist/admin/assets/highlighted-body-JLMTFACH-CIQujGv2.js +1 -0
- package/dist/admin/assets/html-CvFb5cGI.js +1 -0
- package/dist/admin/assets/javascript-BzbQS41l.js +1 -0
- package/dist/admin/assets/javascript-CpIGwZ_Y.js +1 -0
- package/dist/admin/assets/json-qhed-kSA.js +1 -0
- package/dist/admin/assets/jsx-Bz0zcwM4.js +1 -0
- package/dist/admin/assets/lib-CMURo-7A.js +21 -0
- package/dist/admin/assets/library-Cr3f75Es.js +1 -0
- package/dist/admin/assets/list-skeleton-BdTNfVXs.js +1 -0
- package/dist/admin/assets/markdown-BYOwaDjH.js +1 -0
- package/dist/admin/assets/matchContext-Bq5Es9aD.js +2 -0
- package/dist/admin/assets/media-browser-9-CPTCks.js +1 -0
- package/dist/admin/assets/media._library-BfFaEZLR.js +1 -0
- package/dist/admin/assets/mermaid-WFAXDIZX-CJ3hhA0i.js +1 -0
- package/dist/admin/assets/page-header-B4nvAsVA.js +1 -0
- package/dist/admin/assets/pdf-DgessaF0.js +106 -0
- package/dist/admin/assets/python-gzcpVVnB.js +1 -0
- package/dist/admin/assets/react-kbcsfQYH.js +1 -0
- package/dist/admin/assets/rolldown-runtime-BWaJ3C7D.js +1 -0
- package/dist/admin/assets/routes-CBt04sNR.js +1 -0
- package/dist/admin/assets/routes-D7tEdYGV.js +1 -0
- package/dist/admin/assets/save-actions-Cz0TkpcP.js +32 -0
- package/dist/admin/assets/select-Bv2EoLhN.js +1 -0
- package/dist/admin/assets/separator-DlYj_PoQ.js +3 -0
- package/dist/admin/assets/shell-DBEiq06l.js +1 -0
- package/dist/admin/assets/shellscript-CLZ0U2zV.js +1 -0
- package/dist/admin/assets/skeleton-CKiqTaRh.js +1 -0
- package/dist/admin/assets/sql-CEbI0hMM.js +1 -0
- package/dist/admin/assets/syntax-BAXqRKRO.js +8 -0
- package/dist/admin/assets/toggle-Y2UpJZyU.js +1 -0
- package/dist/admin/assets/toml-BPTmHmyx.js +1 -0
- package/dist/admin/assets/tsx-udAQXfEw.js +1 -0
- package/dist/admin/assets/typescript-bsJCZSQ-.js +1 -0
- package/dist/admin/assets/ui.module.css-WaO_77ml.js +56 -0
- package/dist/admin/assets/use-entries-B2lsaiK9.js +1 -0
- package/dist/admin/assets/useSelector-CWr3iU9K.js +1 -0
- package/dist/admin/assets/yaml-rwi0_p6S.js +1 -0
- package/dist/admin/assets/zwitch-Wwuax-dJ.js +1 -0
- package/dist/admin/bootstrap.d.ts +1 -0
- package/dist/admin/bootstrap.js +1 -0
- package/dist/admin/editor.d.ts +57 -0
- package/dist/admin/editor.js +1 -0
- package/dist/server/assets.d.ts +2 -0
- package/dist/server/assets.js +30 -0
- package/dist/server/chunks/anchors-DuZ1fokt.js +86 -0
- package/dist/server/chunks/auth-DJP9ryVd.js +44 -0
- package/dist/server/chunks/cms-markers-CUqrOnfA.js +78 -0
- package/dist/server/chunks/component-lookup-DAFg_Qg8.js +128 -0
- package/dist/server/chunks/config-WQqG4mNH.d.ts +193 -0
- package/dist/server/chunks/digest-BYzWNJea.js +753 -0
- package/dist/server/chunks/entry-checks-CKMag1G4.js +608 -0
- package/dist/server/chunks/field-schema-CfdN75jT.js +48 -0
- package/dist/server/chunks/http-BnsNh57m.d.ts +35 -0
- package/dist/server/chunks/i18n-BPmx7ESy.d.ts +15 -0
- package/dist/server/chunks/index-CYbkNvu5.d.ts +22 -0
- package/dist/server/chunks/media-BhqUVVYY.js +223 -0
- package/dist/server/chunks/paths-CEW9fvg8.js +17 -0
- package/dist/server/chunks/paths-Dztx2eUw.js +13 -0
- package/dist/server/chunks/types-DOR5XaJO.js +397 -0
- package/dist/server/chunks/types-Dkx4Xovf.d.ts +359 -0
- package/dist/server/chunks/types-DwA-C6Br.d.ts +266 -0
- package/dist/server/chunks/user-config-DoypbpQf.js +283 -0
- package/dist/server/chunks/xml-D8qPILJU.js +81 -0
- package/dist/server/config.d.ts +3 -0
- package/dist/server/config.js +18 -0
- package/dist/server/content.d.ts +48 -0
- package/dist/server/content.js +89 -0
- package/dist/server/endpoint.d.ts +11 -0
- package/dist/server/endpoint.js +2712 -0
- package/dist/server/integration.d.ts +7 -0
- package/dist/server/integration.js +1174 -0
- package/dist/server/internal.d.ts +65 -0
- package/dist/server/internal.js +30 -0
- package/dist/server/server-local.d.ts +453 -0
- package/dist/server/server-local.js +336 -0
- package/dist/styles/THIRD_PARTY_LICENSES.md +193 -0
- package/dist/styles/assets/geist-cyrillic-ext-wght-normal-DjL33-gN.woff2 +0 -0
- package/dist/styles/assets/geist-cyrillic-wght-normal-BEAKL7Jp.woff2 +0 -0
- package/dist/styles/assets/geist-latin-ext-wght-normal-DC-KSUi6.woff2 +0 -0
- package/dist/styles/assets/geist-latin-wght-normal-BgDaEnEv.woff2 +0 -0
- package/dist/styles/assets/geist-vietnamese-wght-normal-6IgcOCM7.woff2 +0 -0
- package/dist/styles/styles.css +3 -0
- package/package.json +151 -5
- package/src/astro/Image.astro +28 -0
- package/src/astro/Video.astro +44 -0
- package/src/astro/admin.astro +137 -0
- package/src/astro/licenses.ts +5 -0
package/package.json
CHANGED
|
@@ -1,14 +1,160 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astronaut-cms",
|
|
3
|
-
"version": "0.0
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A Git-native headless CMS built as an Astro integration.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"astro",
|
|
7
|
+
"astro-integration",
|
|
8
|
+
"cms",
|
|
9
|
+
"git",
|
|
10
|
+
"headless-cms",
|
|
11
|
+
"mdx",
|
|
12
|
+
"zod"
|
|
13
|
+
],
|
|
14
|
+
"homepage": "https://mirkolenz.github.io/astronaut-cms/",
|
|
15
|
+
"license": "MIT",
|
|
5
16
|
"repository": {
|
|
6
17
|
"type": "git",
|
|
7
18
|
"url": "git+https://github.com/mirkolenz/astronaut-cms.git"
|
|
8
19
|
},
|
|
9
|
-
"
|
|
20
|
+
"workspaces": [
|
|
21
|
+
"docs",
|
|
22
|
+
"demo"
|
|
23
|
+
],
|
|
10
24
|
"files": [
|
|
11
|
-
"
|
|
25
|
+
"dist",
|
|
26
|
+
"src/astro/*.astro",
|
|
27
|
+
"src/astro/licenses.ts"
|
|
12
28
|
],
|
|
13
|
-
"
|
|
29
|
+
"type": "module",
|
|
30
|
+
"exports": {
|
|
31
|
+
".": "./dist/server/integration.js",
|
|
32
|
+
"./config": "./dist/server/config.js",
|
|
33
|
+
"./assets": "./dist/server/assets.js",
|
|
34
|
+
"./content": "./dist/server/content.js",
|
|
35
|
+
"./editor": "./dist/admin/editor.js",
|
|
36
|
+
"./*.astro": "./src/astro/*.astro",
|
|
37
|
+
"./styles.css": "./dist/styles/styles.css",
|
|
38
|
+
"./bootstrap": "./dist/admin/bootstrap.js",
|
|
39
|
+
"./internal": "./dist/server/internal.js",
|
|
40
|
+
"./endpoint": "./dist/server/endpoint.js",
|
|
41
|
+
"./server-local": "./dist/server/server-local.js",
|
|
42
|
+
"./licenses": "./src/astro/licenses.ts"
|
|
43
|
+
},
|
|
44
|
+
"publishConfig": {
|
|
45
|
+
"access": "public",
|
|
46
|
+
"provenance": true
|
|
47
|
+
},
|
|
48
|
+
"scripts": {
|
|
49
|
+
"dev": "vite build --watch --no-emptyOutDir",
|
|
50
|
+
"build": "vite build",
|
|
51
|
+
"typecheck": "tsc",
|
|
52
|
+
"test": "vitest run",
|
|
53
|
+
"prepack": "npm run build",
|
|
54
|
+
"shadcnup": "shadcn add --yes --overwrite $(basename -s .tsx src/client/components/ui/*.tsx)"
|
|
55
|
+
},
|
|
56
|
+
"dependencies": {
|
|
57
|
+
"@types/mdast": "^4",
|
|
58
|
+
"acorn": "^8",
|
|
59
|
+
"aws4fetch": "^1",
|
|
60
|
+
"fast-xml-parser": "^5",
|
|
61
|
+
"github-slugger": "^2",
|
|
62
|
+
"jose": "^6",
|
|
63
|
+
"mdast-util-from-markdown": "^2",
|
|
64
|
+
"mdast-util-frontmatter": "^2",
|
|
65
|
+
"mdast-util-mdx": "^3",
|
|
66
|
+
"micromark-extension-frontmatter": "^2",
|
|
67
|
+
"micromark-extension-mdxjs": "^3",
|
|
68
|
+
"mime": "^4",
|
|
69
|
+
"pathe": "^2",
|
|
70
|
+
"picomatch": "^4",
|
|
71
|
+
"smol-toml": "^1",
|
|
72
|
+
"yaml": "^2"
|
|
73
|
+
},
|
|
74
|
+
"devDependencies": {
|
|
75
|
+
"@ai-sdk/openai-compatible": "^3",
|
|
76
|
+
"@ai-sdk/react": "^4",
|
|
77
|
+
"@astrojs/react": "^7",
|
|
78
|
+
"@codemirror/lang-css": "^6",
|
|
79
|
+
"@codemirror/lang-html": "^6",
|
|
80
|
+
"@codemirror/lang-javascript": "^6",
|
|
81
|
+
"@codemirror/lang-json": "^6",
|
|
82
|
+
"@codemirror/lang-markdown": "^6",
|
|
83
|
+
"@codemirror/lang-yaml": "^6",
|
|
84
|
+
"@codemirror/language": "^6",
|
|
85
|
+
"@codemirror/legacy-modes": "^6",
|
|
86
|
+
"@fontsource-variable/geist": "^5",
|
|
87
|
+
"@lexical/history": "^0.53",
|
|
88
|
+
"@mdxeditor/editor": "^4",
|
|
89
|
+
"@shadcn/react": "^0.3",
|
|
90
|
+
"@tailwindcss/typography": "^0.5",
|
|
91
|
+
"@tailwindcss/vite": "^4",
|
|
92
|
+
"@tanstack/react-query": "^5",
|
|
93
|
+
"@tanstack/react-router": "^1",
|
|
94
|
+
"@tanstack/router-plugin": "^1",
|
|
95
|
+
"@types/estree": "^1",
|
|
96
|
+
"@types/node": "^26",
|
|
97
|
+
"@types/picomatch": "^4",
|
|
98
|
+
"@types/react": "^19",
|
|
99
|
+
"@types/react-dom": "^19",
|
|
100
|
+
"ai": "^7",
|
|
101
|
+
"astro": "^7",
|
|
102
|
+
"class-variance-authority": "^0.7",
|
|
103
|
+
"cmdk": "^1",
|
|
104
|
+
"cn": "^0.5",
|
|
105
|
+
"i18next": "^26",
|
|
106
|
+
"lexical": "^0.53",
|
|
107
|
+
"lucide-react": "^1",
|
|
108
|
+
"mammoth": "^1",
|
|
109
|
+
"mdast-util-to-markdown": "^2",
|
|
110
|
+
"nanoid": "^6",
|
|
111
|
+
"next-themes": "^0.4",
|
|
112
|
+
"radix-ui": "^1",
|
|
113
|
+
"react": "^19",
|
|
114
|
+
"react-dom": "^19",
|
|
115
|
+
"react-i18next": "^17",
|
|
116
|
+
"rolldown-plugin-dts": "^0.29",
|
|
117
|
+
"scule": "^1",
|
|
118
|
+
"shiki": "^4",
|
|
119
|
+
"sonner": "^2",
|
|
120
|
+
"streamdown": "^2",
|
|
121
|
+
"tailwindcss": "^4",
|
|
122
|
+
"tw-animate-css": "^1",
|
|
123
|
+
"typescript": "^7",
|
|
124
|
+
"unpdf": "^2",
|
|
125
|
+
"vite": "^8",
|
|
126
|
+
"vitest": "^5",
|
|
127
|
+
"zod": "^4",
|
|
128
|
+
"zustand": "^5"
|
|
129
|
+
},
|
|
130
|
+
"peerDependencies": {
|
|
131
|
+
"@astrojs/react": "^7",
|
|
132
|
+
"astro": "^7",
|
|
133
|
+
"react": "^19",
|
|
134
|
+
"react-dom": "^19",
|
|
135
|
+
"vite": "^8",
|
|
136
|
+
"zod": "^4"
|
|
137
|
+
},
|
|
138
|
+
"overrides": {
|
|
139
|
+
"@mdxeditor/editor": {
|
|
140
|
+
"lexical": "^0.53",
|
|
141
|
+
"@lexical/clipboard": "^0.53",
|
|
142
|
+
"@lexical/extension": "^0.53",
|
|
143
|
+
"@lexical/history": "^0.53",
|
|
144
|
+
"@lexical/link": "^0.53",
|
|
145
|
+
"@lexical/list": "^0.53",
|
|
146
|
+
"@lexical/markdown": "^0.53",
|
|
147
|
+
"@lexical/plain-text": "^0.53",
|
|
148
|
+
"@lexical/react": "^0.53",
|
|
149
|
+
"@lexical/rich-text": "^0.53",
|
|
150
|
+
"@lexical/selection": "^0.53",
|
|
151
|
+
"@lexical/utils": "^0.53"
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
"engines": {
|
|
155
|
+
"node": ">=26"
|
|
156
|
+
},
|
|
157
|
+
"allowScripts": {
|
|
158
|
+
"fsevents": false
|
|
159
|
+
}
|
|
14
160
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { Image as AstroImage } from "astro:assets";
|
|
3
|
+
import { resolveImage } from "astronaut-cms/assets";
|
|
4
|
+
import type { ImageMetadata, LocalImageProps } from "astro";
|
|
5
|
+
|
|
6
|
+
type Props = Omit<LocalImageProps, "src"> & {
|
|
7
|
+
src: string | ImageMetadata;
|
|
8
|
+
/** Content file the `src` is relative to (e.g. `entry.filePath`). Only needed for relative paths. */
|
|
9
|
+
base?: string;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const { src, base, ...rest } = Astro.props;
|
|
13
|
+
const resolved = typeof src === "string" ? await resolveImage(src, base) : src;
|
|
14
|
+
|
|
15
|
+
// A resolved string means the media library lives in an object store, so this is
|
|
16
|
+
// a remote image and astro needs its dimensions. `inferSize` reads them from the
|
|
17
|
+
// image itself, at build time for a prerendered page, so neither the schema nor
|
|
18
|
+
// the editor has to carry them. An explicit width and height still win.
|
|
19
|
+
const inferSize = rest.width == null || rest.height == null;
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
{
|
|
23
|
+
typeof resolved === "string" ? (
|
|
24
|
+
<AstroImage src={resolved} inferSize={inferSize} {...rest} />
|
|
25
|
+
) : (
|
|
26
|
+
<AstroImage src={resolved} {...rest} />
|
|
27
|
+
)
|
|
28
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { getImage } from "astro:assets";
|
|
3
|
+
import { resolveFile, resolveImage } from "astronaut-cms/assets";
|
|
4
|
+
import type { ImageMetadata, ImageOutputFormat } from "astro";
|
|
5
|
+
import type { HTMLAttributes } from "astro/types";
|
|
6
|
+
|
|
7
|
+
type Props = Omit<HTMLAttributes<"video">, "src" | "poster"> & {
|
|
8
|
+
/** A `file()` value naming the video. */
|
|
9
|
+
src: string;
|
|
10
|
+
/** An `image()` value or an imported image, shown until the video plays. */
|
|
11
|
+
poster?: string | ImageMetadata;
|
|
12
|
+
/** Width the poster is optimized to, its own when unset. */
|
|
13
|
+
posterWidth?: number;
|
|
14
|
+
/** Format the poster is encoded in, webp like astro's `<Image>` when unset. */
|
|
15
|
+
posterFormat?: ImageOutputFormat;
|
|
16
|
+
/** Content file the paths are relative to (e.g. `entry.filePath`). Only needed for relative paths. */
|
|
17
|
+
base?: string;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const { src, poster, posterWidth, posterFormat = "webp", base, ...rest } = Astro.props;
|
|
21
|
+
const [url, image] = await Promise.all([
|
|
22
|
+
resolveFile(src, base),
|
|
23
|
+
typeof poster === "string" ? resolveImage(poster, base) : poster,
|
|
24
|
+
]);
|
|
25
|
+
|
|
26
|
+
// The poster is the only part of a video astro can optimize, and it carries the
|
|
27
|
+
// video's proportions, so its dimensions also keep the box from jumping. They
|
|
28
|
+
// come off the result: reading them off the source would mark the original as
|
|
29
|
+
// referenced and keep it in the build output.
|
|
30
|
+
const still =
|
|
31
|
+
image &&
|
|
32
|
+
(await getImage({
|
|
33
|
+
width: posterWidth,
|
|
34
|
+
format: posterFormat,
|
|
35
|
+
...(typeof image === "string" ? { src: image, inferSize: true } : { src: image }),
|
|
36
|
+
}));
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
<video
|
|
40
|
+
src={url}
|
|
41
|
+
poster={still?.src}
|
|
42
|
+
width={still?.attributes.width}
|
|
43
|
+
height={still?.attributes.height}
|
|
44
|
+
{...rest}><slot /></video>
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
---
|
|
2
|
+
import "astronaut-cms/styles.css";
|
|
3
|
+
import { client as config, server } from "virtual:astronaut-cms/server";
|
|
4
|
+
import { ADMIN_ROOT_ID, HARDENING_HEADERS } from "astronaut-cms/internal";
|
|
5
|
+
|
|
6
|
+
// A shell. It reads no session and carries no configuration: the bootstrap it
|
|
7
|
+
// loads asks the server who is asking, and only then imports the admin. That is
|
|
8
|
+
// what keeps the session cookie scoped to the API alone, since a page that had
|
|
9
|
+
// to read the cookie would need it scoped wide enough to reach this path, which
|
|
10
|
+
// means sending it with every request for the site's own pages.
|
|
11
|
+
//
|
|
12
|
+
// An anonymous visitor therefore gets this markup, the stylesheet and a
|
|
13
|
+
// bootstrap of a few hundred bytes. A session that lapses with the tab open
|
|
14
|
+
// lands here too: the API answers 401, the admin reloads, and the bootstrap
|
|
15
|
+
// reveals the sign-in panel below.
|
|
16
|
+
|
|
17
|
+
// The admin holds no credential, so a script that got in here can act as the
|
|
18
|
+
// editor while the tab is open but has nothing to send anywhere: every provider
|
|
19
|
+
// call is made by the server, and `connect-src 'self'` is the whole of it.
|
|
20
|
+
// `script-src 'self'` with no inline scripts is what carries the weight, by
|
|
21
|
+
// keeping injected markup from becoming script in the first place.
|
|
22
|
+
//
|
|
23
|
+
// The exceptions are the two places bytes deliberately do not pass through this
|
|
24
|
+
// deployment: a presigned upload, which goes browser-to-store, and an assistant
|
|
25
|
+
// whose editors bring their own key, which goes browser-to-gateway. Both origins
|
|
26
|
+
// have to be reachable or the browser refuses the request before sending it, and
|
|
27
|
+
// both are configuration this page cannot hold back, since a policy has to be in
|
|
28
|
+
// place before any script runs.
|
|
29
|
+
|
|
30
|
+
// Dev serves inline scripts this page does not write, such as Astro's toolbar,
|
|
31
|
+
// beside the Fast Refresh preamble below, so only dev admits them. A production
|
|
32
|
+
// page has none.
|
|
33
|
+
const dev = import.meta.env.DEV;
|
|
34
|
+
|
|
35
|
+
const connectSrc = ["'self'"];
|
|
36
|
+
|
|
37
|
+
if (config.media.s3) connectSrc.push(config.media.s3.storeOrigin);
|
|
38
|
+
|
|
39
|
+
// Named as an origin rather than the full base, which is all a policy can say,
|
|
40
|
+
// and all it needs to, since the key only ever travels to this one host.
|
|
41
|
+
if (config.ai?.byok) connectSrc.push(new URL(config.ai.byok.baseUrl).origin);
|
|
42
|
+
|
|
43
|
+
const csp = [
|
|
44
|
+
"default-src 'none'",
|
|
45
|
+
`script-src 'self'${dev ? " 'unsafe-inline'" : ""}`,
|
|
46
|
+
"style-src 'self' 'unsafe-inline'",
|
|
47
|
+
"img-src 'self' data: blob: https:",
|
|
48
|
+
"media-src 'self' https:",
|
|
49
|
+
"font-src 'self' data:",
|
|
50
|
+
`connect-src ${connectSrc.join(" ")}`,
|
|
51
|
+
// Workers start only from blobs, which inherit this policy (see `extractInWorker`).
|
|
52
|
+
"worker-src blob:",
|
|
53
|
+
"frame-src 'none'",
|
|
54
|
+
"frame-ancestors 'none'",
|
|
55
|
+
"base-uri 'none'",
|
|
56
|
+
// Sign-in is a link to the CMS's own route, which then redirects to the
|
|
57
|
+
// provider, so nothing here ever posts off-origin.
|
|
58
|
+
"form-action 'self'",
|
|
59
|
+
].join("; ");
|
|
60
|
+
|
|
61
|
+
// The CMS needs an SSR adapter, so this page always renders on demand and the
|
|
62
|
+
// policy always reaches the browser as a header, which is what lets it carry
|
|
63
|
+
// `frame-ancestors`, something a meta policy cannot.
|
|
64
|
+
for (const [name, value] of Object.entries({
|
|
65
|
+
...HARDENING_HEADERS,
|
|
66
|
+
"content-security-policy": csp,
|
|
67
|
+
// Admits `document.modelContext` while WebMCP is an origin trial. It is a
|
|
68
|
+
// public, origin-bound token, and the API it unlocks exposes nothing the
|
|
69
|
+
// editor could not already do in this tab.
|
|
70
|
+
...(config.webmcp?.originTrialToken && { "origin-trial": config.webmcp.originTrialToken }),
|
|
71
|
+
// For the handful of agents that still read only this one.
|
|
72
|
+
"x-frame-options": "DENY",
|
|
73
|
+
// The page is the same for everyone, but it carries a policy that has to
|
|
74
|
+
// match what is served, so nothing may keep it.
|
|
75
|
+
"cache-control": "private, no-store",
|
|
76
|
+
})) {
|
|
77
|
+
Astro.response.headers.set(name, value);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// The admin mounts React from an external module script (see body) rather than an
|
|
81
|
+
// Astro island, so a production page ships no inline scripts at all and runs
|
|
82
|
+
// under the strict `script-src 'self'` CSP above. The trade-off: Astro's React
|
|
83
|
+
// integration only injects the Fast Refresh preamble on island pages, so in dev
|
|
84
|
+
// we install it ourselves. It is dev-only, production builds carry no Fast Refresh
|
|
85
|
+
// transform, so no preamble is needed and the CSP stays inline-script free.
|
|
86
|
+
//
|
|
87
|
+
// Copied verbatim from @vitejs/plugin-react's `preambleCode`, the same string
|
|
88
|
+
// @astrojs/react injects via injectScript("before-hydration", ...), with its
|
|
89
|
+
// `__BASE__` placeholder resolved to `/` rather than the configured `base`. Vite
|
|
90
|
+
// serves the refresh runtime at the base-less `/@react-refresh` in dev (and the
|
|
91
|
+
// transform appends imports to that exact path), so prefixing `import.meta.env.BASE_URL`
|
|
92
|
+
// would 404 under a non-root base. @astrojs/react hardcodes `/` for the same reason.
|
|
93
|
+
// Keep in sync with the installed version at node_modules/@vitejs/plugin-react/dist/index.js:
|
|
94
|
+
// the Fast Refresh transform throws unless `window.$RefreshReg$` is defined, which this
|
|
95
|
+
// preamble provides.
|
|
96
|
+
const fastRefreshPreamble = `import { injectIntoGlobalHook } from "/@react-refresh";
|
|
97
|
+
injectIntoGlobalHook(window);
|
|
98
|
+
window.$RefreshReg$ = () => {};
|
|
99
|
+
window.$RefreshSig$ = () => (type) => type;`;
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
<!-- The shell states only what it needs before the probe answers, and the
|
|
103
|
+
admin's language is not that: the bootstrap sets it from the config. -->
|
|
104
|
+
<html lang="en">
|
|
105
|
+
<head>
|
|
106
|
+
<meta charset="UTF-8" />
|
|
107
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
108
|
+
{dev && <script is:inline type="module" set:html={fastRefreshPreamble} />}
|
|
109
|
+
<title>Astronaut CMS</title>
|
|
110
|
+
<meta name="robots" content="noindex, nofollow" />
|
|
111
|
+
</head>
|
|
112
|
+
<body>
|
|
113
|
+
<div
|
|
114
|
+
id={ADMIN_ROOT_ID}
|
|
115
|
+
data-base={import.meta.env.BASE_URL}
|
|
116
|
+
data-trailing-slash={server.trailingSlash}
|
|
117
|
+
></div>
|
|
118
|
+
<!-- The whole of the anonymous admin, rendered here rather than built in
|
|
119
|
+
script: the shell already emits HTML, so the sign-in screen costs no
|
|
120
|
+
second rendering path and no escaping of the provider's message. Hidden
|
|
121
|
+
until the bootstrap knows there is no session. -->
|
|
122
|
+
<main id="astronaut-cms-signin" hidden class="grid min-h-screen place-items-center p-4">
|
|
123
|
+
<div class="text-center">
|
|
124
|
+
<h1 class="text-lg font-semibold">Astronaut CMS</h1>
|
|
125
|
+
<p hidden class="mx-auto mt-2 max-w-md text-sm text-destructive"></p>
|
|
126
|
+
<a
|
|
127
|
+
href=""
|
|
128
|
+
class="mt-4 inline-block rounded-md bg-primary px-4 py-2 text-primary-foreground no-underline"
|
|
129
|
+
>Sign in</a
|
|
130
|
+
>
|
|
131
|
+
</div>
|
|
132
|
+
</main>
|
|
133
|
+
<script>
|
|
134
|
+
import "astronaut-cms/bootstrap";
|
|
135
|
+
</script>
|
|
136
|
+
</body>
|
|
137
|
+
</html>
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// Shipped as source, since the notices it serves are written by the package's own build.
|
|
2
|
+
import admin from "../../dist/admin/THIRD_PARTY_LICENSES.md?raw";
|
|
3
|
+
import styles from "../../dist/styles/THIRD_PARTY_LICENSES.md?raw";
|
|
4
|
+
|
|
5
|
+
export const GET = () => new Response(`${admin}\n${styles}`);
|