@chidchanun/bcp 0.2.4 → 0.2.5

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
@@ -2,13 +2,13 @@
2
2
 
3
3
  BCP Framework is a React full-stack framework for file-based routing, SSR, SPA navigation, server data loading, guarded application flows, API routes, authentication, database access, validation, uploads, storage and standalone Node.js production deployment.
4
4
 
5
- > **Development target:** `0.2.4Application Packaging`
5
+ > **Development target:** `0.2.5Authentication Platform v2`
6
6
  >
7
- > `0.2.4` is an unreleased development target until local validation, RC checks, tagging and npm publication complete.
7
+ > `0.2.5` is an unreleased development target until local validation, RC checks, tagging and npm publication complete.
8
8
 
9
9
  ## 0.2 platform
10
10
 
11
- `0.2.0` established the Framework Platform baseline, `0.2.1` added the Documentation Platform, `0.2.2` added Configuration & Environment v2, `0.2.3` added Database Platform v2, and `0.2.4` adds deployment-oriented application packaging without intentionally removing the existing public application model.
11
+ `0.2.0` established the Framework Platform baseline, `0.2.1` added the Documentation Platform, `0.2.2` added Configuration & Environment v2, `0.2.3` added Database Platform v2, `0.2.4` added Application Packaging, and `0.2.5` adds optional revocable authentication sessions and guest-aware route guards without intentionally removing the existing stateless JWT-cookie model.
12
12
 
13
13
  Machine-readable platform contracts:
14
14
 
@@ -31,8 +31,8 @@ docs/api-manifest.json
31
31
  | Routing | Static, dynamic, catch-all, optional catch-all and route groups |
32
32
  | Server data | Route `loader.ts`, request-scoped server APIs |
33
33
  | Mutations | Route-owned `actions.ts` and `<Form>` |
34
- | Authorization | `guard.ts`, `requireAuth()`, `requireRole()` |
35
- | Authentication | JWT cookie sessions and auth helpers |
34
+ | Authorization | `guard.ts`, `requireAuth()`, `requireGuest()`, `requireRole()` |
35
+ | Authentication | JWT cookie sessions, optional server-side session stores, revocation, logout-all, idle timeout and rotation |
36
36
  | Middleware | Middleware System v2 with onion execution |
37
37
  | Validation | Typed validators and structured validation errors |
38
38
  | Error handling | HTTP error helpers and consistent error responses |
@@ -181,12 +181,6 @@ Create a fresh production build and convert it into a deployment-oriented packag
181
181
  bcp package
182
182
  ```
183
183
 
184
- Framework-repository development can also run:
185
-
186
- ```bash
187
- npm run package
188
- ```
189
-
190
184
  Output:
191
185
 
192
186
  ```text
@@ -206,30 +200,81 @@ Output:
206
200
  └─ README.md
207
201
  ```
208
202
 
209
- The package layer:
203
+ The package layer creates production-only dependency metadata, deployment/environment manifests, SHA-256 file integrity metadata and a Node 24 Alpine Docker starter.
204
+
205
+ Read more:
210
206
 
211
- - runs a fresh `bcp build` before packaging,
212
- - strips application `devDependencies` from the deployment package,
213
- - derives a production-only npm v3 lock graph when safe,
214
- - records `npm ci --omit=dev` when the production lock is available,
215
- - falls back explicitly to `npm install --omit=dev` when a safe lock cannot be produced,
216
- - writes deployment/runtime metadata,
217
- - records environment variable names without copying `.env` values,
218
- - creates SHA-256 file integrity metadata,
219
- - generates a Node 24 Alpine Docker starter.
207
+ - [Application Packaging](docs/application-packaging.md)
208
+ - [Deployment](docs/deployment.md)
220
209
 
221
- The current package target is:
210
+ ## Authentication Platform v2 — 0.2.5
222
211
 
223
- ```text
224
- standalone-node
212
+ The existing stateless JWT-cookie mode remains available:
213
+
214
+ ```ts
215
+ import {
216
+ auth,
217
+ login,
218
+ logout,
219
+ } from "bcp/auth";
220
+ ```
221
+
222
+ Applications that need centralized revocation can add a server-side session store:
223
+
224
+ ```ts
225
+ import {
226
+ createAuth,
227
+ createMemoryAuthSessionStore,
228
+ } from "bcp/auth";
229
+
230
+ const sessionStore =
231
+ createMemoryAuthSessionStore();
232
+
233
+ export const appAuth =
234
+ createAuth({
235
+ store:
236
+ sessionStore,
237
+ idleTimeout:
238
+ 60 * 30,
239
+ });
240
+ ```
241
+
242
+ With a store configured, authentication requires both a valid signed JWT cookie and an active `sid` record.
243
+
244
+ New lifecycle APIs:
245
+
246
+ ```ts
247
+ await appAuth.logout();
248
+ await appAuth.logoutAll();
249
+ await appAuth.revokeSession(sid);
250
+ await appAuth.revokeUserSessions(userId);
251
+ await appAuth.rotateSession();
252
+ ```
253
+
254
+ `idleTimeout` is enforced only when a server-side store is configured. BCP rejects the option in stateless-only mode rather than silently pretending to enforce inactivity expiration.
255
+
256
+ Guest-only login/register routes can use:
257
+
258
+ ```ts
259
+ import {
260
+ createGuestGuard,
261
+ } from "bcp/auth";
262
+
263
+ export const guard =
264
+ createGuestGuard({
265
+ redirectTo:
266
+ "/dashboard",
267
+ });
225
268
  ```
226
269
 
227
- Native executable, desktop, Android and iOS packaging remain later roadmap work.
270
+ The built-in memory session store is intended for development/tests and process-local prototypes. Production applications running multiple processes or containers should implement `AuthSessionStore` with shared durable storage such as Redis or a database.
228
271
 
229
272
  Read more:
230
273
 
231
- - [Application Packaging](docs/application-packaging.md)
232
- - [Deployment](docs/deployment.md)
274
+ - [Authentication](docs/authentication.md)
275
+ - [Auth Session Stores](docs/auth-session-store.md)
276
+ - [Auth Route Guards](docs/auth-route-guards.md)
277
+ - [JWT Sessions](docs/session-auth.md)
233
278
 
234
279
  ## Public entrypoints
235
280
 
@@ -337,16 +382,6 @@ npm run build
337
382
  npm run start
338
383
  ```
339
384
 
340
- Output:
341
-
342
- ```text
343
- .bcp-framework/build/
344
- ├─ client/
345
- ├─ public/
346
- └─ server/
347
- └─ server.mjs
348
- ```
349
-
350
385
  Deployment package:
351
386
 
352
387
  ```bash
@@ -369,12 +404,6 @@ docs/api-manifest.json
369
404
 
370
405
  The manifests provide navigation order, routes, Markdown sources, version/release state, public entrypoints and API guide ownership.
371
406
 
372
- Read more:
373
-
374
- - [Documentation Source Map](docs/README.md)
375
- - [Documentation Platform](docs/documentation-platform.md)
376
- - [Application Packaging](docs/application-packaging.md)
377
-
378
407
  ## Release validation
379
408
 
380
409
  Framework releases must pass:
@@ -389,7 +418,7 @@ npm run test:e2e
389
418
  npm run rc:check
390
419
  ```
391
420
 
392
- `0.2.4` adds Application Packaging unit and prepared-package smoke checks covering production dependency metadata, production lock pruning, environment-value exclusion, deployment metadata and the `bcp package` CLI surface.
421
+ `0.2.5` adds Authentication Platform v2 unit and prepared-package smoke checks covering session-store registration, revocation, logout-all, idle timeout, rotation and guest guards.
393
422
 
394
423
  Do not tag or publish until the final release commit passes the complete RC sequence.
395
424
 
@@ -408,12 +437,13 @@ Do not tag or publish until the final release commit passes the complete RC sequ
408
437
  | `0.2.2` | Configuration & Environment v2 |
409
438
  | `0.2.3` | Database Platform v2 |
410
439
  | `0.2.4` | Application Packaging |
440
+ | `0.2.5` | Authentication Platform v2 |
411
441
 
412
442
  ## Roadmap
413
443
 
414
- `0.2.4Application Packaging` establishes the deployment artifact contract for the existing standalone Node.js runtime.
444
+ `0.2.5Authentication Platform v2` establishes optional revocable server-side auth state while preserving the original stateless JWT-cookie path.
415
445
 
416
- The next planned framework milestone can build on this package contract without changing the current Node.js deployment model. Native `.exe`, desktop and mobile compilation remain later roadmap work.
446
+ A later security/authorization milestone can build on this session contract for broader permission and security policy features. Native `.exe`, desktop and mobile compilation remain later roadmap work.
417
447
 
418
448
  ## License
419
449
 
package/docs/README.md CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  The `docs/` directory is the documentation source of truth for BCP Framework and is organized for **`bcp-docs-web`**.
4
4
 
5
- > **Documentation target:** BCP Framework `0.2.2`
5
+ > **Documentation target:** BCP Framework `0.2.5 — Authentication Platform v2`
6
6
  >
7
- > **Release state:** unreleased development target. Do not label `0.2.2` as published until RC validation, tagging and npm publication complete.
7
+ > **Release state:** unreleased development target until RC validation, tagging and npm publication complete.
8
8
 
9
9
  ## Documentation architecture
10
10
 
@@ -41,32 +41,73 @@ manifest-driven sync
41
41
 
42
42
  Framework source and tests remain authoritative for runtime behavior.
43
43
 
44
- ## 0.2.2 — Configuration & Environment v2
44
+ ## Current 0.2.x milestones
45
45
 
46
- `0.2.2` adds an optional typed application environment schema while preserving the established framework configuration precedence.
46
+ | Version | Milestone |
47
+ | --- | --- |
48
+ | `0.2.0` | Framework Platform |
49
+ | `0.2.1` | Documentation Platform |
50
+ | `0.2.2` | Configuration & Environment v2 |
51
+ | `0.2.3` | Database Platform v2 |
52
+ | `0.2.4` | Application Packaging |
53
+ | `0.2.5` | Authentication Platform v2 |
54
+
55
+ ## 0.2.5 — Authentication Platform v2
56
+
57
+ `0.2.5` keeps stateless signed JWT-cookie authentication as the default and adds optional server-side session state for revocation and inactivity policy.
47
58
 
48
59
  New/updated documentation sources:
49
60
 
50
61
  | Source | Purpose |
51
62
  | --- | --- |
52
- | `environment-validation.md` | `bcp.environment.*`, validation rules, CLI checks and secret/public boundaries |
53
- | `configuration.md` | Framework configuration precedence and diagnostics workflow |
54
- | `platform-manifest.json` | Declares typed environment/config diagnostics capabilities |
55
- | `api-manifest.json` | Maps `bcp/config` to configuration and environment guides |
56
- | `releases/0.2.2.md` | Configuration & Environment v2 release notes |
63
+ | `authentication.md` | Auth core, revocation, logout-all, rotation and idle timeout |
64
+ | `auth-session-store.md` | `AuthSessionStore`, memory adapter and production-store guidance |
65
+ | `auth-route-guards.md` | Auth, guest and role route guards |
66
+ | `api-reference.md` | Public Authentication Platform v2 exports |
67
+ | `platform-manifest.json` | Authentication v2 capability flags |
68
+ | `api-manifest.json` | `bcp/auth` guide ownership |
69
+ | `releases/0.2.5.md` | Authentication Platform v2 release notes |
57
70
 
58
- Primary command:
71
+ Primary public entrypoint:
59
72
 
60
- ```bash
61
- bcp config check
73
+ ```ts
74
+ import {
75
+ auth,
76
+ createAuth,
77
+ createMemoryAuthSessionStore,
78
+ login,
79
+ logout,
80
+ logoutAll,
81
+ requireAuth,
82
+ requireGuest,
83
+ requireRole,
84
+ } from "bcp/auth";
62
85
  ```
63
86
 
64
- JSON diagnostics:
87
+ ## Authentication security model
65
88
 
66
- ```bash
67
- bcp config check --json
89
+ Default mode:
90
+
91
+ ```text
92
+ signed HttpOnly JWT cookie
93
+
94
+ signature + expiry validation
95
+
96
+ authenticated session
68
97
  ```
69
98
 
99
+ Optional revocable mode:
100
+
101
+ ```text
102
+ signed HttpOnly JWT cookie
103
+ +
104
+ server-side sid store
105
+
106
+ revocable authenticated session
107
+ ```
108
+
109
+ The built-in memory store is intended for development/tests. Multi-process production systems should implement `AuthSessionStore` using shared durable storage.
110
+
70
111
  ## Update rule
71
112
 
72
113
  When framework behavior or public surface changes:
@@ -103,76 +144,24 @@ Important current routes:
103
144
 
104
145
  | Website route | Markdown source |
105
146
  | --- | --- |
106
- | `/docs/configuration` | `configuration.md` |
107
- | `/docs/environment-validation` | `environment-validation.md` |
108
- | `/docs/platform-contract` | `platform-contract.md` |
109
- | `/docs/documentation-platform` | `documentation-platform.md` |
110
- | `/docs/migration-0.2` | `migration-0.2.md` |
147
+ | `/docs/authentication` | `authentication.md` |
148
+ | `/docs/auth-session-store` | `auth-session-store.md` |
149
+ | `/docs/auth-route-guards` | `auth-route-guards.md` |
150
+ | `/docs/application-packaging` | `application-packaging.md` |
151
+ | `/docs/database` | `database.md` |
111
152
  | `/docs/api-reference` | `api-reference.md` |
112
- | `/releases/0.2.2` | `releases/0.2.2.md` |
153
+ | `/releases/0.2.5` | `releases/0.2.5.md` |
113
154
 
114
155
  Every route/source pair is validated by unit tests.
115
156
 
116
- ## Configuration source model
117
-
118
- Framework settings:
119
-
120
- ```text
121
- bcp.config.ts
122
- bcp.config.mts
123
- bcp.config.js
124
- bcp.config.mjs
125
- ```
126
-
127
- Application environment schema:
128
-
129
- ```text
130
- bcp.environment.ts
131
- bcp.environment.mts
132
- bcp.environment.js
133
- bcp.environment.mjs
134
- ```
135
-
136
- Only one file from each convention may exist at a time.
137
-
138
- The environment schema is optional. Existing applications without `bcp.environment.*` continue to use the previous environment-loading behavior.
139
-
140
- Configuration precedence remains:
141
-
142
- ```text
143
- CLI override
144
-
145
- BCP_* environment
146
-
147
- bcp.config.*
148
-
149
- framework defaults
150
- ```
151
-
152
- See [Environment Validation](environment-validation.md).
153
-
154
- ## Environment security boundary
155
-
156
- `BCP_PUBLIC_*` values may be embedded into browser bundles. They must never contain credentials/private secrets.
157
-
158
- A variable declared with:
159
-
160
- ```ts
161
- secret: true
162
- ```
163
-
164
- must not use the `BCP_PUBLIC_` prefix. The configuration validator treats that combination as an error.
165
-
166
- `secret: true` is validation/tooling metadata and does not encrypt a value.
167
-
168
157
  ## Platform manifest
169
158
 
170
- `docs/platform-manifest.json` describes the supported framework baseline, including:
159
+ `docs/platform-manifest.json` describes:
171
160
 
172
161
  ```text
173
162
  framework version/release state
174
163
  Node/React/runtime baseline
175
- production build target
164
+ production build/package target
176
165
  public package entrypoints
177
166
  CLI command families
178
167
  capability flags
@@ -180,14 +169,6 @@ previous-baseline compatibility intent
180
169
  documentation contract files
181
170
  ```
182
171
 
183
- `0.2.2` declares the additional capabilities:
184
-
185
- ```text
186
- typedEnvironmentSchema
187
- configurationDiagnostics
188
- configCheckCli
189
- ```
190
-
191
172
  The supported production target remains:
192
173
 
193
174
  ```text
@@ -196,7 +177,7 @@ standalone-node
196
177
 
197
178
  ## API manifest
198
179
 
199
- `docs/api-manifest.json` describes the public package entrypoints documentation tooling may present as supported API surfaces.
180
+ `docs/api-manifest.json` describes public package entrypoints documentation tooling may present as supported APIs.
200
181
 
201
182
  Current entrypoints:
202
183
 
@@ -214,13 +195,6 @@ bcp/server-only
214
195
  bcp/middleware
215
196
  ```
216
197
 
217
- `bcp/config` owns both:
218
-
219
- ```text
220
- /docs/configuration
221
- /docs/environment-validation
222
- ```
223
-
224
198
  The API-manifest entrypoint set must match the platform public-entrypoint set exactly.
225
199
 
226
200
  ## bcp-docs-web synchronization
@@ -241,14 +215,6 @@ load referenced Markdown
241
215
  synchronize CMS/search/navigation
242
216
  ```
243
217
 
244
- Examples from the docs-web project:
245
-
246
- ```powershell
247
- npm run docs:sync -- --dry-run
248
- npm run docs:sync -- --publish-new
249
- npm run docs:sync -- --ref=v0.2.1
250
- ```
251
-
252
218
  ## Source conventions
253
219
 
254
220
  - one H1 per Markdown page,
@@ -263,7 +229,7 @@ npm run docs:sync -- --ref=v0.2.1
263
229
 
264
230
  ## Release validation
265
231
 
266
- Before publishing `0.2.2`:
232
+ Before publishing `0.2.5`:
267
233
 
268
234
  ```bash
269
235
  npm run typecheck
@@ -274,16 +240,17 @@ npm run test:e2e
274
240
  npm run rc:check
275
241
  ```
276
242
 
277
- Configuration & Environment v2 validation covers:
278
-
279
- - typed environment rules/defaults,
280
- - project `bcp.environment.*` loading,
281
- - public/secret safety boundary,
282
- - production diagnostics,
283
- - `bcp config check` CLI parsing,
284
- - dev schema watching,
285
- - public `bcp/config` exports,
286
- - prepared npm package files,
243
+ Authentication Platform v2 validation covers:
244
+
245
+ - stateless JWT backward compatibility,
246
+ - session-store registration and lookup,
247
+ - session revocation,
248
+ - logout-all,
249
+ - idle timeout,
250
+ - rotation with old-session revocation,
251
+ - guest route guards,
252
+ - public `bcp/auth` exports,
253
+ - prepared npm package contents,
287
254
  - docs/platform/API version parity.
288
255
 
289
256
  The final release tag must point to the exact commit that passed the complete RC sequence.
@@ -304,19 +271,3 @@ release notes
304
271
  ```
305
272
 
306
273
  `bcp-docs-web` remains the presentation/search/navigation layer for this content.
307
-
308
- ## Next direction
309
-
310
- Planned next milestone:
311
-
312
- ```text
313
- 0.2.3 — Database Platform v2
314
- ```
315
-
316
- Focus:
317
-
318
- - database adapter contract,
319
- - PostgreSQL support,
320
- - SQLite support,
321
- - connection lifecycle improvements,
322
- - provider-consistent migration workflows.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
3
  "framework": "bcp",
4
- "version": "0.2.4",
4
+ "version": "0.2.5",
5
5
  "releaseState": "unreleased",
6
6
  "coverage": "public-entrypoints",
7
7
  "entrypoints": [
@@ -85,9 +85,10 @@
85
85
  "source": "packages/client/src/auth.ts",
86
86
  "environment": "server",
87
87
  "route": "/docs/api-reference#bcp-auth",
88
- "summary": "Authentication, login/logout/session rotation and route authorization guards.",
88
+ "summary": "Authentication Platform v2 with JWT cookies, optional revocable session stores, idle timeout, logout-all and auth/guest/role route guards.",
89
89
  "guides": [
90
90
  "/docs/authentication",
91
+ "/docs/auth-session-store",
91
92
  "/docs/auth-route-guards",
92
93
  "/docs/session-auth"
93
94
  ]
@@ -164,25 +164,45 @@ Related guides: [Database](database.md), [Database Migrations](database-migratio
164
164
 
165
165
  ## `bcp/auth`
166
166
 
167
- Authentication and authorization APIs.
167
+ Server-only Authentication Platform v2 APIs.
168
168
 
169
169
  ```ts
170
170
  import {
171
171
  auth,
172
172
  createAuth,
173
173
  createAuthGuard,
174
+ createGuestGuard,
175
+ createMemoryAuthSessionStore,
174
176
  createRoleGuard,
175
177
  getGuardAuth,
176
178
  getSession,
177
179
  login,
178
180
  logout,
181
+ logoutAll,
179
182
  requireAuth,
183
+ requireGuest,
180
184
  requireRole,
185
+ revokeSession,
186
+ revokeUserSessions,
181
187
  rotateSession,
188
+ type AuthApi,
189
+ type AuthLoginOptions,
190
+ type AuthOptions,
191
+ type AuthSession,
192
+ type AuthSessionStore,
193
+ type AuthSessionStoreRecord,
194
+ type AuthUser,
195
+ type MemoryAuthSessionStore,
182
196
  } from "bcp/auth";
183
197
  ```
184
198
 
185
- Related guides: [Authentication](authentication.md), [Auth Route Guards](auth-route-guards.md), [JWT Sessions](session-auth.md).
199
+ The default mode remains stateless signed JWT-cookie authentication.
200
+
201
+ Configure `AuthOptions.store` to enable server-side session revocation and `idleTimeout`. `createMemoryAuthSessionStore()` is provided for development/testing; production multi-instance applications should implement `AuthSessionStore` with shared durable storage.
202
+
203
+ `logoutAll()`, `revokeSession()`, and `revokeUserSessions()` require server-side session state. `requireGuest()` / `createGuestGuard()` support login/register routes that should redirect already-authenticated users.
204
+
205
+ Related guides: [Authentication](authentication.md), [Auth Session Stores](auth-session-store.md), [Auth Route Guards](auth-route-guards.md), [JWT Sessions](session-auth.md).
186
206
 
187
207
  ## `bcp/server`
188
208