talizen 0.2.17 → 0.2.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -157,21 +157,23 @@ await invoke("booking", { email: "hi@talizen.com" });
157
157
 
158
158
  ### Server-side page context
159
159
 
160
- In `getServerSideProps`, use the injected server context for request metadata
161
- and cookies. Do not import `talizen/auth` or `talizen/func`, and do not read
162
- auth state or call Func from server-side page code:
160
+ In `getServerSideProps`, use the injected server context for request metadata,
161
+ cookies, and auth. Do not import `talizen/auth` or `talizen/func`, and do not
162
+ call Func from server-side page code:
163
163
 
164
164
  ```ts
165
165
  import type { TalizenServerSideContext } from "talizen/server-runtime";
166
166
 
167
167
  export async function getServerSideProps(ctx: TalizenServerSideContext) {
168
- return { props: { path: ctx.request.path } };
168
+ const user = ctx.auth.currentUser();
169
+ return { props: { path: ctx.request.path, user } };
169
170
  }
170
171
  ```
171
172
 
172
- Server-side context supports `ctx.request` and `ctx.cookies`. It intentionally
173
- does not expose `ctx.auth`, `ctx.db`, `ctx.cache`, or `ctx.func`; put login UI,
174
- private business data access, and writes in browser-side SDK/Func/API flows.
173
+ Server-side context supports `ctx.request`, `ctx.cookies`, and `ctx.auth`.
174
+ It intentionally does not expose `ctx.db`, `ctx.cache`, or `ctx.func`; put
175
+ login UI, private business data writes, and custom backend actions in
176
+ browser-side SDK/Func/API flows.
175
177
 
176
178
  ### Write function runtime code
177
179
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "talizen",
3
- "version": "0.2.17",
3
+ "version": "0.2.18",
4
4
  "description": "Talizen frontend SDK types for cms, form and core.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -1,3 +1,4 @@
1
+ import type { AuthUser } from "./auth.js";
1
2
  export interface ServerReadonlyStringMap {
2
3
  get(name: string): string | null;
3
4
  }
@@ -27,6 +28,10 @@ export interface TalizenServerCookieRuntime {
27
28
  ok?: boolean;
28
29
  };
29
30
  }
31
+ export interface TalizenServerAuthRuntime {
32
+ currentUser(): AuthUser | null;
33
+ requireUser(): AuthUser;
34
+ }
30
35
  export interface TalizenServerSideContext {
31
36
  query: Record<string, string | string[]>;
32
37
  searchParams: Record<string, string | string[]>;
@@ -37,4 +42,5 @@ export interface TalizenServerSideContext {
37
42
  request: TalizenServerRequestRuntime;
38
43
  req: TalizenServerRequestRuntime;
39
44
  cookies: TalizenServerCookieRuntime;
45
+ auth: TalizenServerAuthRuntime;
40
46
  }