create-bcp-app 0.2.4 → 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 +52 -13
- package/package.json +1 -1
- package/template/README.md +55 -0
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.
|
|
95
|
+
"frameworkPackage": "npm:@chidchanun/bcp@0.2.6",
|
|
96
96
|
"createdWith": {
|
|
97
97
|
"package": "create-bcp-app",
|
|
98
|
-
"version": "0.2.
|
|
98
|
+
"version": "0.2.6"
|
|
99
99
|
},
|
|
100
100
|
"packageManager": "npm",
|
|
101
101
|
"presets": {
|
|
@@ -277,6 +277,55 @@ Set this to a cryptographically random secret of at least 32 bytes before real a
|
|
|
277
277
|
|
|
278
278
|
The generated `authenticateCredentials(email, password)` returns `null` until the application connects it to its own user store and password-hash verification.
|
|
279
279
|
|
|
280
|
+
Generated auth stays in backward-compatible stateless JWT-cookie mode by default.
|
|
281
|
+
|
|
282
|
+
BCP `0.2.5+` can opt into revocable server-side auth state without changing the generated auth route structure:
|
|
283
|
+
|
|
284
|
+
```ts
|
|
285
|
+
import {
|
|
286
|
+
createAuth,
|
|
287
|
+
createMemoryAuthSessionStore,
|
|
288
|
+
} from "bcp/auth";
|
|
289
|
+
|
|
290
|
+
const sessionStore =
|
|
291
|
+
createMemoryAuthSessionStore();
|
|
292
|
+
|
|
293
|
+
const frameworkAuth =
|
|
294
|
+
createAuth<AuthenticatedUser>({
|
|
295
|
+
store: sessionStore,
|
|
296
|
+
idleTimeout: 60 * 30,
|
|
297
|
+
});
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
The memory store is intended for development/tests. Multi-process production deployments should implement `AuthSessionStore` using shared durable storage.
|
|
301
|
+
|
|
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.
|
|
328
|
+
|
|
280
329
|
## Application Packaging — 0.2.4+
|
|
281
330
|
|
|
282
331
|
Generated projects include:
|
|
@@ -311,8 +360,6 @@ npm ci --omit=dev
|
|
|
311
360
|
npm start
|
|
312
361
|
```
|
|
313
362
|
|
|
314
|
-
If the package manifest reports that no lockfile was included, use the install command recorded in `bcp.package.json`.
|
|
315
|
-
|
|
316
363
|
## Project generators after creation
|
|
317
364
|
|
|
318
365
|
```bash
|
|
@@ -331,14 +378,6 @@ bcp generate middleware
|
|
|
331
378
|
bcp generate migration create_users
|
|
332
379
|
```
|
|
333
380
|
|
|
334
|
-
From PowerShell:
|
|
335
|
-
|
|
336
|
-
```powershell
|
|
337
|
-
npm exec -- bcp-framework generate page dashboard/users
|
|
338
|
-
```
|
|
339
|
-
|
|
340
|
-
Use `--force` only when intentionally replacing an existing page/API/middleware scaffold.
|
|
341
|
-
|
|
342
381
|
## Options
|
|
343
382
|
|
|
344
383
|
```text
|
|
@@ -368,5 +407,5 @@ npx create-bcp-app my-app --yes
|
|
|
368
407
|
The `--bcp` option is mainly for prerelease/local package verification:
|
|
369
408
|
|
|
370
409
|
```bash
|
|
371
|
-
npx create-bcp-app my-app --bcp file:../chidchanun-bcp-0.2.
|
|
410
|
+
npx create-bcp-app my-app --bcp file:../chidchanun-bcp-0.2.6.tgz
|
|
372
411
|
```
|
package/package.json
CHANGED
package/template/README.md
CHANGED
|
@@ -39,6 +39,61 @@ It records non-secret scaffold choices such as Tailwind, database, authenticatio
|
|
|
39
39
|
|
|
40
40
|
Commit this file with the project. Do not put passwords, access keys, session secrets or tokens in it.
|
|
41
41
|
|
|
42
|
+
## Authentication — BCP 0.2.5+
|
|
43
|
+
|
|
44
|
+
Projects created with the `JWT Cookie` preset remain stateless by default and use the generated `lib/auth.ts` helpers.
|
|
45
|
+
|
|
46
|
+
BCP Authentication Platform v2 can opt into revocable server-side session state:
|
|
47
|
+
|
|
48
|
+
```ts
|
|
49
|
+
import {
|
|
50
|
+
createAuth,
|
|
51
|
+
createMemoryAuthSessionStore,
|
|
52
|
+
} from "bcp/auth";
|
|
53
|
+
|
|
54
|
+
const sessionStore =
|
|
55
|
+
createMemoryAuthSessionStore();
|
|
56
|
+
|
|
57
|
+
export const appAuth =
|
|
58
|
+
createAuth({
|
|
59
|
+
store: sessionStore,
|
|
60
|
+
idleTimeout: 60 * 30,
|
|
61
|
+
});
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
The memory store is intended for local development/tests. Use a shared durable `AuthSessionStore` implementation for multi-process or multi-container production deployments.
|
|
65
|
+
|
|
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.
|
|
96
|
+
|
|
42
97
|
## Generate framework files
|
|
43
98
|
|
|
44
99
|
BCP can generate common project files:
|