create-bcp-app 0.2.5 → 0.2.6

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
@@ -92,10 +92,10 @@ Example:
92
92
  "schemaVersion": 1,
93
93
  "framework": "bcp",
94
94
  "projectName": "my-app",
95
- "frameworkPackage": "npm:@chidchanun/bcp@0.2.5",
95
+ "frameworkPackage": "npm:@chidchanun/bcp@0.2.6",
96
96
  "createdWith": {
97
97
  "package": "create-bcp-app",
98
- "version": "0.2.5"
98
+ "version": "0.2.6"
99
99
  },
100
100
  "packageManager": "npm",
101
101
  "presets": {
@@ -292,16 +292,39 @@ const sessionStore =
292
292
 
293
293
  const frameworkAuth =
294
294
  createAuth<AuthenticatedUser>({
295
- store:
296
- sessionStore,
297
- idleTimeout:
298
- 60 * 30,
295
+ store: sessionStore,
296
+ idleTimeout: 60 * 30,
299
297
  });
300
298
  ```
301
299
 
302
300
  The memory store is intended for development/tests. Multi-process production deployments should implement `AuthSessionStore` using shared durable storage.
303
301
 
304
- Authentication Platform v2 also provides `logoutAll()`, session/user revocation APIs and `createGuestGuard()` for login/register pages.
302
+ ## Authorization & request security 0.2.6+
303
+
304
+ Generated applications can add permissions to their application user shape and use server-side permission guards without changing the auth preset routes:
305
+
306
+ ```ts
307
+ import {
308
+ createPermissionGuard,
309
+ hasPermission,
310
+ } from "bcp/auth";
311
+ ```
312
+
313
+ For resource-specific decisions, use `defineAuthorizationPolicy()`, `can()` or `authorize()`.
314
+
315
+ Cookie-authenticated mutation routes can opt into same-origin and CSRF protection through `bcp/server`:
316
+
317
+ ```ts
318
+ import {
319
+ createCsrfToken,
320
+ requireCsrfRequest,
321
+ requireSameOriginRequest,
322
+ } from "bcp/server";
323
+ ```
324
+
325
+ `createCsrfToken()` uses `BCP_CSRF_SECRET` when configured and otherwise falls back to `BCP_SESSION_SECRET`, so the generated JWT auth preset does not require another environment variable to get started. Production applications may define a separate `BCP_CSRF_SECRET` for independent key rotation.
326
+
327
+ Authorization and CSRF checks must remain on the server; hiding UI controls in client code is not an authorization boundary.
305
328
 
306
329
  ## Application Packaging — 0.2.4+
307
330
 
@@ -337,8 +360,6 @@ npm ci --omit=dev
337
360
  npm start
338
361
  ```
339
362
 
340
- If the package manifest reports that no lockfile was included, use the install command recorded in `bcp.package.json`.
341
-
342
363
  ## Project generators after creation
343
364
 
344
365
  ```bash
@@ -357,14 +378,6 @@ bcp generate middleware
357
378
  bcp generate migration create_users
358
379
  ```
359
380
 
360
- From PowerShell:
361
-
362
- ```powershell
363
- npm exec -- bcp-framework generate page dashboard/users
364
- ```
365
-
366
- Use `--force` only when intentionally replacing an existing page/API/middleware scaffold.
367
-
368
381
  ## Options
369
382
 
370
383
  ```text
@@ -394,5 +407,5 @@ npx create-bcp-app my-app --yes
394
407
  The `--bcp` option is mainly for prerelease/local package verification:
395
408
 
396
409
  ```bash
397
- npx create-bcp-app my-app --bcp file:../chidchanun-bcp-0.2.5.tgz
410
+ npx create-bcp-app my-app --bcp file:../chidchanun-bcp-0.2.6.tgz
398
411
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-bcp-app",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
4
4
  "description": "Create a new BCP Framework application.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -56,16 +56,43 @@ const sessionStore =
56
56
 
57
57
  export const appAuth =
58
58
  createAuth({
59
- store:
60
- sessionStore,
61
- idleTimeout:
62
- 60 * 30,
59
+ store: sessionStore,
60
+ idleTimeout: 60 * 30,
63
61
  });
64
62
  ```
65
63
 
66
64
  The memory store is intended for local development/tests. Use a shared durable `AuthSessionStore` implementation for multi-process or multi-container production deployments.
67
65
 
68
- Authentication Platform v2 also provides session revocation, `logoutAll()`, rotation with revocation, and `createGuestGuard()` for guest-only pages such as login/register routes.
66
+ ## Authorization & request security BCP 0.2.6+
67
+
68
+ Server-side permission guards:
69
+
70
+ ```ts
71
+ import {
72
+ createPermissionGuard,
73
+ } from "bcp/auth";
74
+
75
+ export const guard =
76
+ createPermissionGuard(
77
+ "dashboard.read"
78
+ );
79
+ ```
80
+
81
+ For ownership or resource-specific rules, use `defineAuthorizationPolicy()`, `can()` and `authorize()` from `bcp/auth`.
82
+
83
+ Cookie-authenticated mutation routes can validate browser origin and CSRF state:
84
+
85
+ ```ts
86
+ import {
87
+ createCsrfToken,
88
+ requireCsrfRequest,
89
+ requireSameOriginRequest,
90
+ } from "bcp/server";
91
+ ```
92
+
93
+ `createCsrfToken()` uses `BCP_CSRF_SECRET` when configured and otherwise falls back to `BCP_SESSION_SECRET`.
94
+
95
+ Authorization must always be enforced server-side. Client UI visibility is not a security boundary.
69
96
 
70
97
  ## Generate framework files
71
98