You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
run402-public side of openspec auth-aware-ssr tasks 8.8 + 8.10:
- cli/lib/init-astro.mjs: scaffold emits AGENTS.md template with the
brutally-small auth.* surface + four Never rules + rendering-mode quick
map. Save-page example switched from getUser() to auth.requireUser().
Task 8.8.
- astro/README.md: rendering-mode pattern matrix table (SSR / prerendered /
server-island / client-hydrate) with copy-pasteable examples for each.
Task 8.10.
- src/index.ts (MCP deploy_function tool description): swap legacy
'getUser' bullet for 'auth' so the doctor source scanner stops
R402_AUTH_UNKNOWN_EXPORT-flagging the MCP descriptor at deploy time.
Unblocks 5 cli-e2e tests that exercise tier-violation paths.
- sync.test.ts: allowlist auth.fetch() scaffold strings in init-astro.mjs
and the canonical-fix string in doctor-source-scan.mjs. Also stops
treating .test.mjs files as production interface files.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: astro/README.md
+57Lines changed: 57 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -81,6 +81,63 @@ Three options if your SSR route needs request-time config:
81
81
82
82
The Run402 anon key + service key + project ID + JWT secret + API base ARE auto-injected at deploy time (you'll see `RUN402_ANON_KEY`, `RUN402_SERVICE_KEY`, `RUN402_PROJECT_ID`, `RUN402_JWT_SECRET`, `RUN402_API_BASE` in `process.env` from inside the SSR runtime — those are the platform-managed channel).
83
83
84
+
### Rendering-mode pattern matrix
85
+
86
+
Astro supports four rendering modes; `auth.*` calls have different semantics in each. Pick the right mode per page and the rest follows.
87
+
88
+
| Mode | How to opt in | When to use | Auth + cache |
| SSR (default) | The default in v1.0; no flag needed. | Personalized pages that read the actor. |`auth.user()` returns the actor; `auth.*` helpers taint the response so cache bypasses on Set-Cookie / auth. |
91
+
| Prerendered |`export const prerender = true;` in the page. | Pure marketing / docs pages that never see the actor. |`auth.*` throws `R402_AUTH_PRERENDERED`. The page is built once and served as a static asset. |
92
+
| Server island |`<Component server:defer />` inside a page. | Mostly-static page with a personalized slot (e.g. user dropdown). |`auth.*` is available **inside** the island. The shell is still cacheable. |
93
+
| Client hydrate |`<SignedIn client:load>…</SignedIn>`. | Cookie-aware visibility without an SSR pass at all. | Component fetches `/auth/v1/session` from the browser. No server `auth.*` call. |
94
+
95
+
Pattern picker:
96
+
97
+
```astro
98
+
---
99
+
// Personalized SSR (default in this scaffold)
100
+
import { auth } from "@run402/functions";
101
+
const user = await auth.requireUser(); // 303 to /auth/sign-in if anonymous
102
+
---
103
+
<h1>Hello, {user.email}</h1>
104
+
```
105
+
106
+
```astro
107
+
---
108
+
// Prerendered marketing page
109
+
export const prerender = true;
110
+
// Do NOT call auth.user() here — it throws R402_AUTH_PRERENDERED at build time
111
+
---
112
+
<h1>Welcome to the product</h1>
113
+
```
114
+
115
+
```astro
116
+
---
117
+
// Server-island mix: shell is cacheable, island streams in
118
+
import UserDropdown from "../components/UserDropdown.astro";
119
+
---
120
+
<header>
121
+
<nav>...</nav>
122
+
<UserDropdown server:defer>
123
+
<span slot="fallback">Loading…</span>
124
+
</UserDropdown>
125
+
</header>
126
+
```
127
+
128
+
```astro
129
+
---
130
+
// Client-hydrated visibility-only (no SSR auth read)
131
+
import { SignedIn, SignedOut, SignIn, UserButton } from "@run402/astro";
132
+
---
133
+
<SignedIn client:load>
134
+
<UserButton />
135
+
</SignedIn>
136
+
<SignedOut client:load>
137
+
<SignIn returnTo="/" />
138
+
</SignedOut>
139
+
```
140
+
84
141
## `<Run402Picture>` — runtime CMS images
85
142
86
143
For images coming from a DB row at SSR time (the common CMS pattern), use `<Run402Picture asset={page.hero_asset}>`. The `asset` prop is the `AssetRef` JSONB that `r.assets.put()` returned at upload time — store the whole object, not just the URL, then render directly.
Copy file name to clipboardExpand all lines: src/index.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -357,7 +357,7 @@ server.tool(
357
357
358
358
server.tool(
359
359
"deploy_function",
360
-
"Deploy a serverless function (Node 22) to a project. Handler signature: export default async (req: Request) => Response. The function can `import { db, adminDb, getUser, email, ai } from '@run402/functions'` — auto-bundled by the platform. Additional npm packages are bundled at deploy time when listed in `deps` (bare names resolve to latest; pinned/range specs are honored verbatim; `@run402/functions` and `run402-functions` rejected; max 30 entries; native binaries rejected). The response includes `runtime_version` (the bundled `@run402/functions` version — surface as 'Functions runtime version', never bare 'runtime'), `deps_resolved` (map of dep name → installed concrete version), and an optional top-level `warnings` array (sibling to the function record).",
360
+
"Deploy a serverless function (Node 22) to a project. Handler signature: export default async (req: Request) => Response. The function can `import { db, adminDb, auth, email, ai } from '@run402/functions'` — auto-bundled by the platform. Additional npm packages are bundled at deploy time when listed in `deps` (bare names resolve to latest; pinned/range specs are honored verbatim; `@run402/functions` and `run402-functions` rejected; max 30 entries; native binaries rejected). The response includes `runtime_version` (the bundled `@run402/functions` version — surface as 'Functions runtime version', never bare 'runtime'), `deps_resolved` (map of dep name → installed concrete version), and an optional top-level `warnings` array (sibling to the function record).",
0 commit comments