@molecule/api-resource-user 1.8.1 → 1.8.3

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-10-26T04:23:58.846Z
6
+ Generated: 2026-11-04T14:20:01.202Z
7
7
  -->
8
8
 
9
9
  # @molecule/api-resource-user
@@ -50,6 +50,8 @@ store). Set `AUTH_SCHEME=Token` (or `verifyMiddleware({ scheme: 'Token' })`): ev
50
50
  accepts it, `logIn`/`create` return `accessToken`, `GET /users/me` echoes it, and a password
51
51
  change revokes every OTHER device but keeps the caller's own session.
52
52
 
53
+ **Generated full-stack apps:** mlcl derives the app-auth composition root from this API contract; keep that bond and use its shared HTTP client.
54
+
53
55
  **`handlers.*` return `{ statusCode, headers?, body }` and never write to `res`** — not through
54
56
  `res.json`, not through `res.send`, not through `res.end`. The mounted routes apply that object
55
57
  for you (`createRequestHandler` does `res.set(headers)`, `res.status(statusCode)`,
@@ -959,8 +961,13 @@ sameSite: 'none', partitioned: true, path: '/' }`. The molecule.dev live
959
961
  {@link getAuthCookieName}). NEVER weaken it.
960
962
  - **Development, top-level** → `{ secure: false, sameSite: 'lax', path: '/' }`.
961
963
  The original dev posture (plain http, not `Secure`) — used by the molecule.dev
964
+ IDE and by a developer running their generated app locally. Both are top-level
965
+ documents, so `Lax` is correct and `Secure`/`None`/`Partitioned` would be both
966
+ unnecessary and (as above) actively harmful.
962
967
 
963
- _(description truncated — read the full text in `node_modules/@molecule/api-resource-user/dist/authorization.d.ts`.)_
968
+ `httpOnly` and `maxAge` are intentionally omitted: the SET call adds those per
969
+ cookie, and the CLEAR call spreads these attributes verbatim so the deletion
970
+ targets the exact same (possibly Partitioned) cookie jar.
964
971
 
965
972
  ```typescript
966
973
  function getAuthCookieOptions(): {
@@ -1124,8 +1131,30 @@ to mint a token without one: it throws when `session.userId` or `session.deviceI
1124
1131
  is not a non-empty string, naming the field and the call that supplies it, instead of letting the
1125
1132
  client discover it as a 401 on every later request. Do the device step on every path that signs a
1126
1133
  user in (register, login, OAuth, password reset), as `handlers/logIn.ts` does: a placeholder
1127
-
1128
- _(description truncated — read the full text in `node_modules/@molecule/api-resource-user/dist/authorization.d.ts`.)_
1134
+ (`'unknown'`, `''`, the user's id) yields a token that every later request answers 401.
1135
+
1136
+ To put a session token in a JSON response BODY — an API whose clients send
1137
+ `Authorization: Token <jwt>` — call this and use its return value; the shipped `logIn` and
1138
+ `create` handlers already return it as `accessToken`. Do NOT sign a
1139
+ second token with another key or algorithm: `verifyMiddleware` verifies with the app's
1140
+ bonded `@molecule/api-jwt` provider, so a self-signed one answers 401 on the very next
1141
+ request. Mount `verifyMiddleware({ allowCookieSession: false, scheme: 'Token' })` in front
1142
+ of the routes that sign users in and the client gets the token in that scheme with no
1143
+ session cookie. (`AUTH_SCHEME=Token` in the app's environment does the same for every
1144
+ mount — the scheme is configuration, not a second auth path.)
1145
+
1146
+ Always sets the `Authorization` response header — labelled with the request mount's scheme
1147
+ (`Bearer` by default, `Token` for a RealWorld-style API; see {@link AUTH_SCHEME_LOCALS_KEY}
1148
+ and `AUTH_SCHEME`). Writes the session cookies (the httpOnly
1149
+ `token` and `sessionId`, plus the readable `mol_auth` presence hint) UNLESS the request's
1150
+ cookie-session policy is off — see {@link ALLOW_COOKIE_SESSION_LOCALS_KEY}, written by
1151
+ {@link verifyMiddleware}. A token-only API (`allowCookieSession: false`) gets the header
1152
+ and no cookies, so its clients cannot drift into a cookie session.
1153
+
1154
+ The policy is the MOUNT's, and the mount records it on every request it passes — including
1155
+ the sign-in request itself, which carries no token and therefore resolves no session. So a
1156
+ token-only API writes no cookie from the very first response: mount
1157
+ `verifyMiddleware({ allowCookieSession: false })` in front of the routes that sign users in.
1129
1158
 
1130
1159
  ```typescript
1131
1160
  function set(_req: MoleculeRequest, res: MoleculeResponse, session: Session): string | null
@@ -2008,8 +2037,8 @@ arrived on stays, and the token that made the request (the `Authorization` heade
2008
2037
  is holding) keeps working. A RealWorld-style suite changes the password and then keeps using
2009
2038
  the same token for the next request; revoking the caller too is what answered its second
2010
2039
  `PUT /user` with 401. Do not fold a per-user secret into the
2011
-
2012
- _(description truncated — read the full text in `node_modules/@molecule/api-resource-user/dist/handlers/updatePassword.d.ts`.)_
2040
+ JWT: the device row is the revocation lever. A caller with no session (a handler invoked
2041
+ outside a request) falls back to revoking every device.
2013
2042
 
2014
2043
  ```typescript
2015
2044
  function updatePassword({
package/dist/index.d.ts CHANGED
@@ -40,6 +40,8 @@
40
40
  * accepts it, `logIn`/`create` return `accessToken`, `GET /users/me` echoes it, and a password
41
41
  * change revokes every OTHER device but keeps the caller's own session.
42
42
  *
43
+ * **Generated full-stack apps:** mlcl derives the app-auth composition root from this API contract; keep that bond and use its shared HTTP client.
44
+ *
43
45
  * **`handlers.*` return `{ statusCode, headers?, body }` and never write to `res`** — not through
44
46
  * `res.json`, not through `res.send`, not through `res.end`. The mounted routes apply that object
45
47
  * for you (`createRequestHandler` does `res.set(headers)`, `res.status(statusCode)`,
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;AAC5B,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAA"}
package/dist/index.js CHANGED
@@ -40,6 +40,8 @@
40
40
  * accepts it, `logIn`/`create` return `accessToken`, `GET /users/me` echoes it, and a password
41
41
  * change revokes every OTHER device but keeps the caller's own session.
42
42
  *
43
+ * **Generated full-stack apps:** mlcl derives the app-auth composition root from this API contract; keep that bond and use its shared HTTP client.
44
+ *
43
45
  * **`handlers.*` return `{ statusCode, headers?, body }` and never write to `res`** — not through
44
46
  * `res.json`, not through `res.send`, not through `res.end`. The mounted routes apply that object
45
47
  * for you (`createRequestHandler` does `res.set(headers)`, `res.status(statusCode)`,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqSG;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@molecule/api-resource-user",
3
- "version": "1.8.1",
3
+ "version": "1.8.3",
4
4
  "description": "User resource types and schema for molecule.dev.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",