@molecule/api-resource-user 1.8.4 → 1.8.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 +23 -9
- package/dist/index.d.ts +19 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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-
|
|
6
|
+
Generated: 2026-11-08T06:24:34.867Z
|
|
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
|
|
@@ -770,8 +780,8 @@ Schema for creating a user via password.
|
|
|
770
780
|
```typescript
|
|
771
781
|
const createPropsSchema: z.ZodObject<
|
|
772
782
|
{
|
|
773
|
-
username: z.ZodOptional<z.ZodString>
|
|
774
783
|
name: z.ZodOptional<z.ZodString>
|
|
784
|
+
username: z.ZodOptional<z.ZodString>
|
|
775
785
|
email: z.ZodOptional<z.ZodNullable<z.ZodString>>
|
|
776
786
|
},
|
|
777
787
|
z.core.$strip
|
|
@@ -796,8 +806,8 @@ Schema for creating a user via OAuth.
|
|
|
796
806
|
```typescript
|
|
797
807
|
const createOAuthPropsSchema: z.ZodObject<
|
|
798
808
|
{
|
|
799
|
-
username: z.ZodOptional<z.ZodString>
|
|
800
809
|
name: z.ZodOptional<z.ZodString>
|
|
810
|
+
username: z.ZodOptional<z.ZodString>
|
|
801
811
|
email: z.ZodOptional<z.ZodNullable<z.ZodString>>
|
|
802
812
|
emailVerified: z.ZodOptional<z.ZodBoolean>
|
|
803
813
|
avatar: z.ZodOptional<z.ZodNullable<z.ZodString>>
|
|
@@ -817,8 +827,8 @@ Schema for updating a user (partial username, name, email, avatar, bio).
|
|
|
817
827
|
```typescript
|
|
818
828
|
const updatePropsSchema: z.ZodObject<
|
|
819
829
|
{
|
|
820
|
-
username: z.ZodOptional<z.ZodOptional<z.ZodString>>
|
|
821
830
|
name: z.ZodOptional<z.ZodOptional<z.ZodString>>
|
|
831
|
+
username: z.ZodOptional<z.ZodOptional<z.ZodString>>
|
|
822
832
|
email: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodString>>>
|
|
823
833
|
avatar: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodString>>>
|
|
824
834
|
bio: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodString>>>
|
|
@@ -2620,9 +2630,12 @@ token until the cache expires — a check right after logout still answers 200.
|
|
|
2620
2630
|
`invalidateDeviceExistsCache(deviceId)` (or `invalidateAllDeviceExistsCache()`) after the
|
|
2621
2631
|
delete; the built-in log-out route already does.
|
|
2622
2632
|
|
|
2623
|
-
On the CLIENT, the
|
|
2624
|
-
|
|
2625
|
-
httpOnly cookie + `GET /users/me
|
|
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.
|
|
2626
2639
|
|
|
2627
2640
|
**Client-facing endpoints** (mounted under the app's `/api` prefix → `/api/users/...`).
|
|
2628
2641
|
The auth CLIENT (`useAuth()` → `login` / `register` / `logout` / `refresh`) already wraps
|
|
@@ -2663,8 +2676,9 @@ by one. A box you can't check is an integration bug to fix — not a skip:
|
|
|
2663
2676
|
in its payload; never mock the flow or modify production code to expose it.
|
|
2664
2677
|
- [ ] Logging out and logging back in with the same credentials reaches the same
|
|
2665
2678
|
account and its data.
|
|
2666
|
-
- [ ] The session survives a full page reload
|
|
2667
|
-
`GET /users/me
|
|
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.
|
|
2668
2682
|
- [ ] A wrong password shows a visible error and does NOT authenticate.
|
|
2669
2683
|
- [ ] Authenticated-only screens are unreachable when logged out (redirect to
|
|
2670
2684
|
login or an explicit denial — never a blank page).
|
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
|
|
@@ -234,9 +244,12 @@
|
|
|
234
244
|
* `invalidateDeviceExistsCache(deviceId)` (or `invalidateAllDeviceExistsCache()`) after the
|
|
235
245
|
* delete; the built-in log-out route already does.
|
|
236
246
|
*
|
|
237
|
-
* On the CLIENT, the
|
|
238
|
-
*
|
|
239
|
-
* httpOnly cookie + `GET /users/me
|
|
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.
|
|
240
253
|
*
|
|
241
254
|
* **Client-facing endpoints** (mounted under the app's `/api` prefix → `/api/users/...`).
|
|
242
255
|
* The auth CLIENT (`useAuth()` → `login` / `register` / `logout` / `refresh`) already wraps
|
|
@@ -289,8 +302,9 @@
|
|
|
289
302
|
* in its payload; never mock the flow or modify production code to expose it.
|
|
290
303
|
* - [ ] Logging out and logging back in with the same credentials reaches the same
|
|
291
304
|
* account and its data.
|
|
292
|
-
* - [ ] The session survives a full page reload
|
|
293
|
-
* `GET /users/me
|
|
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.
|
|
294
308
|
* - [ ] A wrong password shows a visible error and does NOT authenticate.
|
|
295
309
|
* - [ ] Authenticated-only screens are unreachable when logged out (redirect to
|
|
296
310
|
* login or an explicit denial — never a blank page).
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
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
|
|
@@ -234,9 +244,12 @@
|
|
|
234
244
|
* `invalidateDeviceExistsCache(deviceId)` (or `invalidateAllDeviceExistsCache()`) after the
|
|
235
245
|
* delete; the built-in log-out route already does.
|
|
236
246
|
*
|
|
237
|
-
* On the CLIENT, the
|
|
238
|
-
*
|
|
239
|
-
* httpOnly cookie + `GET /users/me
|
|
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.
|
|
240
253
|
*
|
|
241
254
|
* **Client-facing endpoints** (mounted under the app's `/api` prefix → `/api/users/...`).
|
|
242
255
|
* The auth CLIENT (`useAuth()` → `login` / `register` / `logout` / `refresh`) already wraps
|
|
@@ -289,8 +302,9 @@
|
|
|
289
302
|
* in its payload; never mock the flow or modify production code to expose it.
|
|
290
303
|
* - [ ] Logging out and logging back in with the same credentials reaches the same
|
|
291
304
|
* account and its data.
|
|
292
|
-
* - [ ] The session survives a full page reload
|
|
293
|
-
* `GET /users/me
|
|
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.
|
|
294
308
|
* - [ ] A wrong password shows a visible error and does NOT authenticate.
|
|
295
309
|
* - [ ] Authenticated-only screens are unreachable when logged out (redirect to
|
|
296
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
|
|
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"}
|