@beignet/next 0.0.45 → 0.0.47

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/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @beignet/next
2
2
 
3
+ ## 0.0.47
4
+
5
+ ### Patch Changes
6
+
7
+ - 3847e21: Resolve trusted request metadata once per request from a server-level policy and share it with context factories, security hooks, rate limiting, and logging observers.
8
+ - Updated dependencies [3847e21]
9
+ - @beignet/web@0.0.47
10
+
11
+ ## 0.0.46
12
+
13
+ ### Patch Changes
14
+
15
+ - @beignet/web@0.0.46
16
+
3
17
  ## 0.0.45
4
18
 
5
19
  ### Patch Changes
package/README.md CHANGED
@@ -67,11 +67,15 @@ export const getTodo = todos
67
67
 
68
68
  This adapter quick start uses a tiny demo context. Production Beignet apps
69
69
  should use the canonical `AppContext` from the docs and generated starter:
70
- `requestId`, `actor`, `auth`, `gate`, `ports`, and optional `tenant`.
70
+ `requestId`, `actor`, `auth`, `gate`, `ports`, and optional `requestInfo` and
71
+ `tenant`.
71
72
 
72
73
  ```typescript
73
74
  // app-context.ts
75
+ import type { TrustedRequestInfo } from "@beignet/core/server";
76
+
74
77
  export type AppContext = {
78
+ requestInfo: TrustedRequestInfo;
75
79
  userId: string;
76
80
  };
77
81
  ```
@@ -140,11 +144,12 @@ export const getServer = createNextServerLoader(() =>
140
144
  createNextServer<AppContext>({
141
145
  ports: {},
142
146
  routes,
143
- context: async ({ req }) => {
147
+ context: async ({ req, requestInfo }) => {
144
148
  // DEMO ONLY: this reads an unauthenticated header to simulate identity.
145
149
  // Real applications should verify a signed token or session cookie first.
146
150
  return {
147
151
  userId: req.headers.get("x-user-id") || "anonymous",
152
+ requestInfo,
148
153
  };
149
154
  },
150
155
  mapUnhandledError: () => ({
@@ -158,6 +163,12 @@ export const getServer = createNextServerLoader(() =>
158
163
  );
159
164
  ```
160
165
 
166
+ Set `trustedProxy` on `createNextServer(...)` only when every request passes
167
+ through an edge that strips or normalizes forwarded headers. The context
168
+ factory and server hooks then receive the same resolved `requestInfo` with the
169
+ external URL, origin, host, protocol, and optional client IP. Forwarding
170
+ headers are ignored when the option is omitted.
171
+
161
172
  ### 5. Set up routes
162
173
 
163
174
  Expose ordinary application routes through one catch-all framework route. Next
@@ -269,6 +280,8 @@ Creates a Next.js server instance with the given options.
269
280
  - `mapUnhandledError`: Error handler function
270
281
  - `routes?`: Array of route configurations (contract + handler)
271
282
  - `hooks?`: Optional ordered server hooks
283
+ - `trustedProxy?`: Explicit policy for trusted edge-provided host, protocol,
284
+ and client-IP metadata; forwarding headers are ignored when omitted
272
285
  - `providers?`: Optional array of service providers
273
286
  - `providerEnv?`: Optional environment variables for providers
274
287
  - `providerConfig?`: Optional provider configuration overrides
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@beignet/next",
3
- "version": "0.0.45",
3
+ "version": "0.0.47",
4
4
  "type": "module",
5
5
  "description": "Next.js server-side handlers for Beignet",
6
6
  "main": "./dist/index.js",
@@ -61,7 +61,7 @@
61
61
  "next": "^14.0.0 || ^15.0.0 || ^16.0.0"
62
62
  },
63
63
  "dependencies": {
64
- "@beignet/web": "^0.0.45",
64
+ "@beignet/web": "^0.0.47",
65
65
  "@standard-schema/spec": "^1.0.0"
66
66
  },
67
67
  "devDependencies": {
@@ -162,7 +162,12 @@ envelope; do not add a second operational response shape.
162
162
  ## Context
163
163
 
164
164
  `server/context.ts` should use `defineServerContext`. Request context reads the
165
- session, creates an actor, attaches ports, request IDs, and trace context.
165
+ session, creates an actor, attaches ports, request IDs, trace context, and
166
+ optional `requestInfo`. Configure `trustedProxy` once on `createNextServer(...)`
167
+ when the deployment has a trusted edge; the context factory and server hooks
168
+ then receive the same external URL, origin, host, protocol, and optional client
169
+ IP. Forwarding headers remain untrusted by default, and apps choose whether to
170
+ persist client IPs in logs or audit metadata.
166
171
  Service context is for schedules, tasks, outbox drains, and background work;
167
172
  create a service actor and do not assume a request session. Focused helpers
168
173
  such as `createOutboxDrainRoute(...)`, `createScheduleRoute(...)`, and webhook