@molecule/api-resource-user 1.8.3 → 1.8.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
@@ -3,7 +3,7 @@ AUTO-GENERATED — DO NOT EDIT THIS FILE.
3
3
  Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
4
4
  Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
5
5
  To change this document, edit the module-level JSDoc in src/index.ts.
6
- Generated: 2026-11-04T14:20:01.202Z
6
+ Generated: 2026-11-06T22:35:09.204Z
7
7
  -->
8
8
 
9
9
  # @molecule/api-resource-user
@@ -66,6 +66,16 @@ res.status(statusCode).send(body)
66
66
  Monkey-patching `res.json` to re-shape a handler's answer intercepts nothing the handler
67
67
  produces, so the request it was meant to answer is left unanswered and hangs.
68
68
 
69
+ **Adapt envelopes with `createRequestHandler(handler, options)` from
70
+ `@molecule/api-resource` 1.1 or newer.** Keep `handlers.create(resource)` and
71
+ `handlers.logIn(resource)` as the handler. `mapRequest: (req) =>
72
+ ({ body: req.body?.account })` unwraps this API's account envelope before the
73
+ existing validation runs. `mapResponse` can return `{ ...result, body }`
74
+ for a successful result; preserve errors, the 206 two-factor response and
75
+ session headers. Both mappings may be async. Read that package's adapter
76
+ example for the full wiring, including early validation responses. Keep
77
+ route rate limits and authorization around the configured wrapper.
78
+
69
79
  **Re-shaping a success answer (RealWorld's `{ user: { …, token } }`, say)? Read the token from
70
80
  `result.body.accessToken` — it is in the BODY.** The `Authorization` response header carries
71
81
  the same token prefixed with the mount's scheme (`Bearer <token>`), so it is not the raw value
@@ -1189,8 +1199,9 @@ interface VerifyMiddlewareOptions {
1189
1199
  shouldRefreshSession?: (session: Session, req: MoleculeRequest) => boolean | Promise<boolean>
1190
1200
  /**
1191
1201
  * Whether the `token` cookie is a session on this mount, in BOTH directions.
1192
- * Defaults to `true` (browser clients sign in once and every page request carries
1193
- * the cookie).
1202
+ * Defaults to `true` for Bearer (browser clients sign in once and every page request
1203
+ * carries the cookie), and `false` for a custom header scheme such as Token.
1204
+ * Pass `true` explicitly to combine a custom scheme with browser cookie sessions.
1194
1205
  *
1195
1206
  * Pass `false` for a token-only JSON API. Then the cookie is not a credential here:
1196
1207
  * the middleware does not resolve a session from it (and drops one an earlier, laxer
@@ -1219,8 +1230,9 @@ interface VerifyMiddlewareOptions {
1219
1230
 
1220
1231
  Middleware that verifies the JWT token from the `Authorization` header and sets `res.locals.session`.
1221
1232
  Accepts `Bearer` and `Token` (Django REST / RealWorld) plus the configured scheme, on EVERY
1222
- route the mount covers. Falls back to cookie-based session for browser clients unless
1223
- `allowCookieSession` is `false` — which also stops `set()` writing the session cookie for this
1233
+ route the mount covers. Bearer falls back to cookie-based sessions; custom schemes default
1234
+ to header-only sessions. `allowCookieSession` overrides this default in both directions,
1235
+ including whether `set()` writes the session cookie for this
1224
1236
  request. Records the scheme for `set()` and, when the token came from the header, records the
1225
1237
  raw token in `res.locals[AUTH_TOKEN_LOCALS_KEY]`. Auto-refreshes tokens older than `JWT_REFRESH_TIME`.
1226
1238
 
@@ -2573,7 +2585,11 @@ before calling a handler, or write the route yourself. A username keeps exactly
2573
2585
  sent (letters, digits, `.`, `-`, `_`); anything else is answered 400
2574
2586
  `user.error.usernameInvalid`, never rewritten.
2575
2587
 
2576
- **A token-only JSON API:** by default the `token` cookie that login sets IS a session,
2588
+ **A token-only JSON API:** the default Bearer scheme permits cookie sessions;
2589
+ configuring a custom scheme (`AUTH_SCHEME=Token` or `verifyMiddleware({ scheme: 'Token' })`)
2590
+ defaults to header-only authentication and does not write session cookies. Pass
2591
+ `allowCookieSession: true` explicitly to use cookies with a custom scheme.
2592
+ With cookie sessions enabled, the `token` cookie that login sets IS a session,
2577
2593
  and `authorization.set()` writes it on every sign-in — so a client that keeps a cookie
2578
2594
  jar (an HTTP test runner, `curl -b`) stays signed in on a request that sends no
2579
2595
  `Authorization` header, and gets 200 on the step the suite calls "no auth". Mount
@@ -2614,9 +2630,12 @@ token until the cache expires — a check right after logout still answers 200.
2614
2630
  `invalidateDeviceExistsCache(deviceId)` (or `invalidateAllDeviceExistsCache()`) after the
2615
2631
  delete; the built-in log-out route already does.
2616
2632
 
2617
- On the CLIENT, the bearer token is held IN MEMORY only — a `localStorage` copy is
2618
- XSS-exfiltratable and is forbidden. The session is restored after a reload via the
2619
- httpOnly cookie + `GET /users/me`; don't persist the token yourself.
2633
+ On the CLIENT, use the bonded `@molecule/app-auth` client as the session store.
2634
+ `AuthClientConfig.storage` selects persistence. A cookie API can use `storage:
2635
+ 'memory'` and restore through the httpOnly cookie + `GET /users/me`. A header-only
2636
+ API sets no session cookie; the browser client's default or an explicit
2637
+ `createBrowserStorageAdapter()` retains its token across reloads. Keep that
2638
+ choice in the shared auth configuration, rather than adding another token store.
2620
2639
 
2621
2640
  **Client-facing endpoints** (mounted under the app's `/api` prefix → `/api/users/...`).
2622
2641
  The auth CLIENT (`useAuth()` → `login` / `register` / `logout` / `refresh`) already wraps
@@ -2657,8 +2676,9 @@ by one. A box you can't check is an integration bug to fix — not a skip:
2657
2676
  in its payload; never mock the flow or modify production code to expose it.
2658
2677
  - [ ] Logging out and logging back in with the same credentials reaches the same
2659
2678
  account and its data.
2660
- - [ ] The session survives a full page reload (restored via the httpOnly cookie +
2661
- `GET /users/me` — never from a token persisted in localStorage).
2679
+ - [ ] The session survives a full page reload through the configured shared client:
2680
+ a cookie API restores via the httpOnly cookie + `GET /users/me`; a header-only
2681
+ API uses its configured storage adapter.
2662
2682
  - [ ] A wrong password shows a visible error and does NOT authenticate.
2663
2683
  - [ ] Authenticated-only screens are unreachable when logged out (redirect to
2664
2684
  login or an explicit denial — never a blank page).
@@ -231,8 +231,9 @@ export interface VerifyMiddlewareOptions {
231
231
  shouldRefreshSession?: (session: Session, req: MoleculeRequest) => boolean | Promise<boolean>;
232
232
  /**
233
233
  * Whether the `token` cookie is a session on this mount, in BOTH directions.
234
- * Defaults to `true` (browser clients sign in once and every page request carries
235
- * the cookie).
234
+ * Defaults to `true` for Bearer (browser clients sign in once and every page request
235
+ * carries the cookie), and `false` for a custom header scheme such as Token.
236
+ * Pass `true` explicitly to combine a custom scheme with browser cookie sessions.
236
237
  *
237
238
  * Pass `false` for a token-only JSON API. Then the cookie is not a credential here:
238
239
  * the middleware does not resolve a session from it (and drops one an earlier, laxer
@@ -258,8 +259,9 @@ export interface VerifyMiddlewareOptions {
258
259
  /**
259
260
  * Middleware that verifies the JWT token from the `Authorization` header and sets `res.locals.session`.
260
261
  * Accepts `Bearer` and `Token` (Django REST / RealWorld) plus the configured scheme, on EVERY
261
- * route the mount covers. Falls back to cookie-based session for browser clients unless
262
- * `allowCookieSession` is `false` — which also stops `set()` writing the session cookie for this
262
+ * route the mount covers. Bearer falls back to cookie-based sessions; custom schemes default
263
+ * to header-only sessions. `allowCookieSession` overrides this default in both directions,
264
+ * including whether `set()` writes the session cookie for this
263
265
  * request. Records the scheme for `set()` and, when the token came from the header, records the
264
266
  * raw token in `res.locals[AUTH_TOKEN_LOCALS_KEY]`. Auto-refreshes tokens older than `JWT_REFRESH_TIME`.
265
267
  * @param options - {@link VerifyMiddlewareOptions} controlling the auto-refresh, cookie policy and scheme.
@@ -1 +1 @@
1
- {"version":3,"file":"authorization.d.ts","sourceRoot":"","sources":["../src/authorization.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAO,cAAc,CAAA;AAMrB,OAAO,KAAK,EACV,eAAe,EACf,sBAAsB,EACtB,gBAAgB,EACjB,MAAM,wBAAwB,CAAA;AAE/B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAwB1C;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,iBAAiB,GAAI,MAAM,MAAM,KAAG,MACP,CAAA;AA4B1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,oBAAoB,QAAO;IACtC,MAAM,EAAE,OAAO,CAAA;IACf,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AG,QAAQ,CAAA;AAiBnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyDG;AACH,eAAO,MAAM,GAAG,GACd,MAAM,eAAe,EACrB,KAAK,gBAAgB,EACrB,SAAS,OAAO,KACf,MAAM,GAAG,IAuGX,CAAA;AAED,4CAA4C;AAC5C,MAAM,WAAW,uBAAuB;IACtC;;;;;;;;;;;;;OAaG;IACH,oBAAoB,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,eAAe,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;IAC7F;;;;;;;;;;;;OAYG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B;;;;;;;;;;OAUG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,gBAAgB,GAC1B,UAAU,uBAAuB,KAAG,sBA0HpC,CAAA"}
@@ -362,13 +362,14 @@ export const AUTH_SESSION_SOURCE_LOCALS_KEY = 'authSessionSource';
362
362
  *
363
363
  * {@link verifyMiddleware} records its `allowCookieSession` option in `res.locals`
364
364
  * ({@link ALLOW_COOKIE_SESSION_LOCALS_KEY}); an ABSENT record means the request never
365
- * passed a mount that declares a policy, so the historical default applies (cookies on)
366
- * and a direct `set()` caller outside the scaffold is unchanged.
365
+ * passed a mount that declares a policy. In that case the configured scheme applies:
366
+ * Bearer keeps browser sessions; a custom header scheme defaults to header-only auth.
367
367
  *
368
368
  * @param res - The response object.
369
369
  * @returns `true` when the session cookies may be written.
370
370
  */
371
- const maySetSessionCookie = (res) => res.locals?.[ALLOW_COOKIE_SESSION_LOCALS_KEY] !== false;
371
+ const maySetSessionCookie = (res) => res.locals?.[ALLOW_COOKIE_SESSION_LOCALS_KEY] ??
372
+ resolveAuthScheme(res).toLowerCase() === DEFAULT_AUTH_SCHEME.toLowerCase();
372
373
  /**
373
374
  * Set authorization headers and cookie for a session, and RETURN the signed token.
374
375
  *
@@ -520,8 +521,9 @@ export const set = (_req, res, session) => {
520
521
  /**
521
522
  * Middleware that verifies the JWT token from the `Authorization` header and sets `res.locals.session`.
522
523
  * Accepts `Bearer` and `Token` (Django REST / RealWorld) plus the configured scheme, on EVERY
523
- * route the mount covers. Falls back to cookie-based session for browser clients unless
524
- * `allowCookieSession` is `false` — which also stops `set()` writing the session cookie for this
524
+ * route the mount covers. Bearer falls back to cookie-based sessions; custom schemes default
525
+ * to header-only sessions. `allowCookieSession` overrides this default in both directions,
526
+ * including whether `set()` writes the session cookie for this
525
527
  * request. Records the scheme for `set()` and, when the token came from the header, records the
526
528
  * raw token in `res.locals[AUTH_TOKEN_LOCALS_KEY]`. Auto-refreshes tokens older than `JWT_REFRESH_TIME`.
527
529
  * @param options - {@link VerifyMiddlewareOptions} controlling the auto-refresh, cookie policy and scheme.
@@ -535,10 +537,10 @@ export const verifyMiddleware = (options) => async (req, res, next) => {
535
537
  // scheme) and a later, stricter mount reads it to know it may strip a session
536
538
  // an earlier one resolved out of the cookie. The sign-in request itself carries
537
539
  // no token, so the write cannot sit behind the token lookup below.
538
- const allowCookieSession = options?.allowCookieSession !== false;
539
- res.locals[ALLOW_COOKIE_SESSION_LOCALS_KEY] = allowCookieSession;
540
540
  const scheme = normalizeAuthScheme(options?.scheme ?? getConfiguredAuthScheme(), options?.scheme === undefined ? 'AUTH_SCHEME' : 'verifyMiddleware({ scheme })');
541
541
  res.locals[AUTH_SCHEME_LOCALS_KEY] = scheme;
542
+ const allowCookieSession = options?.allowCookieSession ?? scheme.toLowerCase() === DEFAULT_AUTH_SCHEME.toLowerCase();
543
+ res.locals[ALLOW_COOKIE_SESSION_LOCALS_KEY] = allowCookieSession;
542
544
  // Get token from Authorization header, falling back to the `token`
543
545
  // cookie that `set()` writes alongside the header. The JSDoc above
544
546
  // promises this fallback for browser clients; without it the cookie
@@ -1 +1 @@
1
- {"version":3,"file":"authorization.js","sourceRoot":"","sources":["../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AA;gBACxD,IAAI,OAAO,EAAE,GAAG,EAAE,CAAC;oBACjB,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,OAAO,CAAC,GAAG,GAAG,IAAI,CAAA;oBAChD,IACE,QAAQ,GAAG,iBAAiB,EAAE;wBAC9B,CAAC,MAAM,OAAO,EAAE,oBAAoB,EAAE,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,KAAK,KAAK,EAC/D,CAAC;wBACD,8CAA8C;wBAC9C,MAAM,GAAG,CACP,QAAQ,CACT,EAAE,cAAc,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAA;wBAEnC,uBAAuB;wBACvB,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,CAAA;oBACxB,CAAC;gBACH,CAAC;YACH,CAAC;YAAC,OAAO,MAAM,EAAE,CAAC;gBAChB,sEAAsE;gBACtE,wEAAwE;gBACxE,mDAAmD;YACrD,CAAC;QACH,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,KAAK,CAAC,6BAA6B,EAAE,KAAK,CAAC,CAAA;IACpD,CAAC;IAED,OAAO,IAAI,EAAE,CAAA;AACf,CAAC,CAAA"}
package/dist/index.d.ts CHANGED
@@ -56,6 +56,16 @@
56
56
  * Monkey-patching `res.json` to re-shape a handler's answer intercepts nothing the handler
57
57
  * produces, so the request it was meant to answer is left unanswered and hangs.
58
58
  *
59
+ * **Adapt envelopes with `createRequestHandler(handler, options)` from
60
+ * `@molecule/api-resource` 1.1 or newer.** Keep `handlers.create(resource)` and
61
+ * `handlers.logIn(resource)` as the handler. `mapRequest: (req) =>
62
+ * ({ body: req.body?.account })` unwraps this API's account envelope before the
63
+ * existing validation runs. `mapResponse` can return `{ ...result, body }`
64
+ * for a successful result; preserve errors, the 206 two-factor response and
65
+ * session headers. Both mappings may be async. Read that package's adapter
66
+ * example for the full wiring, including early validation responses. Keep
67
+ * route rate limits and authorization around the configured wrapper.
68
+ *
59
69
  * **Re-shaping a success answer (RealWorld's `{ user: { …, token } }`, say)? Read the token from
60
70
  * `result.body.accessToken` — it is in the BODY.** The `Authorization` response header carries
61
71
  * the same token prefixed with the mount's scheme (`Bearer <token>`), so it is not the raw value
@@ -189,7 +199,11 @@
189
199
  * sent (letters, digits, `.`, `-`, `_`); anything else is answered 400
190
200
  * `user.error.usernameInvalid`, never rewritten.
191
201
  *
192
- * **A token-only JSON API:** by default the `token` cookie that login sets IS a session,
202
+ * **A token-only JSON API:** the default Bearer scheme permits cookie sessions;
203
+ * configuring a custom scheme (`AUTH_SCHEME=Token` or `verifyMiddleware({ scheme: 'Token' })`)
204
+ * defaults to header-only authentication and does not write session cookies. Pass
205
+ * `allowCookieSession: true` explicitly to use cookies with a custom scheme.
206
+ * With cookie sessions enabled, the `token` cookie that login sets IS a session,
193
207
  * and `authorization.set()` writes it on every sign-in — so a client that keeps a cookie
194
208
  * jar (an HTTP test runner, `curl -b`) stays signed in on a request that sends no
195
209
  * `Authorization` header, and gets 200 on the step the suite calls "no auth". Mount
@@ -230,9 +244,12 @@
230
244
  * `invalidateDeviceExistsCache(deviceId)` (or `invalidateAllDeviceExistsCache()`) after the
231
245
  * delete; the built-in log-out route already does.
232
246
  *
233
- * On the CLIENT, the bearer token is held IN MEMORY only — a `localStorage` copy is
234
- * XSS-exfiltratable and is forbidden. The session is restored after a reload via the
235
- * httpOnly cookie + `GET /users/me`; don't persist the token yourself.
247
+ * On the CLIENT, use the bonded `@molecule/app-auth` client as the session store.
248
+ * `AuthClientConfig.storage` selects persistence. A cookie API can use `storage:
249
+ * 'memory'` and restore through the httpOnly cookie + `GET /users/me`. A header-only
250
+ * API sets no session cookie; the browser client's default or an explicit
251
+ * `createBrowserStorageAdapter()` retains its token across reloads. Keep that
252
+ * choice in the shared auth configuration, rather than adding another token store.
236
253
  *
237
254
  * **Client-facing endpoints** (mounted under the app's `/api` prefix → `/api/users/...`).
238
255
  * The auth CLIENT (`useAuth()` → `login` / `register` / `logout` / `refresh`) already wraps
@@ -285,8 +302,9 @@
285
302
  * in its payload; never mock the flow or modify production code to expose it.
286
303
  * - [ ] Logging out and logging back in with the same credentials reaches the same
287
304
  * account and its data.
288
- * - [ ] The session survives a full page reload (restored via the httpOnly cookie +
289
- * `GET /users/me` — never from a token persisted in localStorage).
305
+ * - [ ] The session survives a full page reload through the configured shared client:
306
+ * a cookie API restores via the httpOnly cookie + `GET /users/me`; a header-only
307
+ * API uses its configured storage adapter.
290
308
  * - [ ] A wrong password shows a visible error and does NOT authenticate.
291
309
  * - [ ] Authenticated-only screens are unreachable when logged out (redirect to
292
310
  * login or an explicit denial — never a blank page).
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuSG;AAEH,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAA;AACnD,OAAO,KAAK,WAAW,MAAM,wBAAwB,CAAA;AACrD,cAAc,oBAAoB,CAAA;AAClC,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAA;AAC/C,cAAc,WAAW,CAAA;AACzB,cAAc,mBAAmB,CAAA;AACjC,cAAc,wBAAwB,CAAA;AACtC,cAAc,eAAe,CAAA;AAC7B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyTG;AAEH,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAA;AACnD,OAAO,KAAK,WAAW,MAAM,wBAAwB,CAAA;AACrD,cAAc,oBAAoB,CAAA;AAClC,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAA;AAC/C,cAAc,WAAW,CAAA;AACzB,cAAc,mBAAmB,CAAA;AACjC,cAAc,wBAAwB,CAAA;AACtC,cAAc,eAAe,CAAA;AAC7B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAA"}
package/dist/index.js CHANGED
@@ -56,6 +56,16 @@
56
56
  * Monkey-patching `res.json` to re-shape a handler's answer intercepts nothing the handler
57
57
  * produces, so the request it was meant to answer is left unanswered and hangs.
58
58
  *
59
+ * **Adapt envelopes with `createRequestHandler(handler, options)` from
60
+ * `@molecule/api-resource` 1.1 or newer.** Keep `handlers.create(resource)` and
61
+ * `handlers.logIn(resource)` as the handler. `mapRequest: (req) =>
62
+ * ({ body: req.body?.account })` unwraps this API's account envelope before the
63
+ * existing validation runs. `mapResponse` can return `{ ...result, body }`
64
+ * for a successful result; preserve errors, the 206 two-factor response and
65
+ * session headers. Both mappings may be async. Read that package's adapter
66
+ * example for the full wiring, including early validation responses. Keep
67
+ * route rate limits and authorization around the configured wrapper.
68
+ *
59
69
  * **Re-shaping a success answer (RealWorld's `{ user: { …, token } }`, say)? Read the token from
60
70
  * `result.body.accessToken` — it is in the BODY.** The `Authorization` response header carries
61
71
  * the same token prefixed with the mount's scheme (`Bearer <token>`), so it is not the raw value
@@ -189,7 +199,11 @@
189
199
  * sent (letters, digits, `.`, `-`, `_`); anything else is answered 400
190
200
  * `user.error.usernameInvalid`, never rewritten.
191
201
  *
192
- * **A token-only JSON API:** by default the `token` cookie that login sets IS a session,
202
+ * **A token-only JSON API:** the default Bearer scheme permits cookie sessions;
203
+ * configuring a custom scheme (`AUTH_SCHEME=Token` or `verifyMiddleware({ scheme: 'Token' })`)
204
+ * defaults to header-only authentication and does not write session cookies. Pass
205
+ * `allowCookieSession: true` explicitly to use cookies with a custom scheme.
206
+ * With cookie sessions enabled, the `token` cookie that login sets IS a session,
193
207
  * and `authorization.set()` writes it on every sign-in — so a client that keeps a cookie
194
208
  * jar (an HTTP test runner, `curl -b`) stays signed in on a request that sends no
195
209
  * `Authorization` header, and gets 200 on the step the suite calls "no auth". Mount
@@ -230,9 +244,12 @@
230
244
  * `invalidateDeviceExistsCache(deviceId)` (or `invalidateAllDeviceExistsCache()`) after the
231
245
  * delete; the built-in log-out route already does.
232
246
  *
233
- * On the CLIENT, the bearer token is held IN MEMORY only — a `localStorage` copy is
234
- * XSS-exfiltratable and is forbidden. The session is restored after a reload via the
235
- * httpOnly cookie + `GET /users/me`; don't persist the token yourself.
247
+ * On the CLIENT, use the bonded `@molecule/app-auth` client as the session store.
248
+ * `AuthClientConfig.storage` selects persistence. A cookie API can use `storage:
249
+ * 'memory'` and restore through the httpOnly cookie + `GET /users/me`. A header-only
250
+ * API sets no session cookie; the browser client's default or an explicit
251
+ * `createBrowserStorageAdapter()` retains its token across reloads. Keep that
252
+ * choice in the shared auth configuration, rather than adding another token store.
236
253
  *
237
254
  * **Client-facing endpoints** (mounted under the app's `/api` prefix → `/api/users/...`).
238
255
  * The auth CLIENT (`useAuth()` → `login` / `register` / `logout` / `refresh`) already wraps
@@ -285,8 +302,9 @@
285
302
  * in its payload; never mock the flow or modify production code to expose it.
286
303
  * - [ ] Logging out and logging back in with the same credentials reaches the same
287
304
  * account and its data.
288
- * - [ ] The session survives a full page reload (restored via the httpOnly cookie +
289
- * `GET /users/me` — never from a token persisted in localStorage).
305
+ * - [ ] The session survives a full page reload through the configured shared client:
306
+ * a cookie API restores via the httpOnly cookie + `GET /users/me`; a header-only
307
+ * API uses its configured storage adapter.
290
308
  * - [ ] A wrong password shows a visible error and does NOT authenticate.
291
309
  * - [ ] Authenticated-only screens are unreachable when logged out (redirect to
292
310
  * login or an explicit denial — never a blank page).
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuSG;AAEH,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAA;AACnD,OAAO,KAAK,WAAW,MAAM,wBAAwB,CAAA;AACrD,cAAc,oBAAoB,CAAA;AAClC,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAA;AAC/C,cAAc,WAAW,CAAA;AACzB,cAAc,mBAAmB,CAAA;AACjC,cAAc,wBAAwB,CAAA;AACtC,cAAc,eAAe,CAAA;AAC7B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyTG;AAEH,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAA;AACnD,OAAO,KAAK,WAAW,MAAM,wBAAwB,CAAA;AACrD,cAAc,oBAAoB,CAAA;AAClC,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAA;AAC/C,cAAc,WAAW,CAAA;AACzB,cAAc,mBAAmB,CAAA;AACjC,cAAc,wBAAwB,CAAA;AACtC,cAAc,eAAe,CAAA;AAC7B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@molecule/api-resource-user",
3
- "version": "1.8.3",
3
+ "version": "1.8.5",
4
4
  "description": "User resource types and schema for molecule.dev.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",