@molecule/api-resource-user 1.4.11 → 1.4.13

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-09T13:50:49.876Z
6
+ Generated: 2026-10-15T23:29:57.665Z
7
7
  -->
8
8
 
9
9
  # @molecule/api-resource-user
@@ -943,6 +943,19 @@ Auth is ALREADY wired globally (the router's `verifyMiddleware` → `res.locals.
943
943
  so a handler reads the current user with `getUserId(res)` and does NOT add per-route auth
944
944
  middleware (see the `auth` skill). Scope every custom user query by the authenticated id.
945
945
 
946
+ **Issuing a session yourself:** the middleware accepts both `Authorization: Bearer <jwt>`
947
+ and `Authorization: Token <jwt>` (RealWorld's scheme), but only for a token whose
948
+ `deviceId` names an ACTIVE row in `devices`. A JWT you `sign()` with an invented `deviceId`
949
+ is answered 401 on every route. Mint sessions the way the built-in login does — create the
950
+ device with `get('device').createOrUpdate(userId, deviceName)` (it returns the device id; or call
951
+ `authorization.set(…)`) and sign that id — instead of inventing one.
952
+
953
+ **Revoking a session yourself:** the middleware caches "this device exists" for 10 s per
954
+ process, so a hand-written logout that deletes the `devices` row keeps authorizing that
955
+ token until the cache expires — a check right after logout still answers 200. Call
956
+ `invalidateDeviceExistsCache(deviceId)` (or `invalidateAllDeviceExistsCache()`) after the
957
+ delete; the built-in log-out route already does.
958
+
946
959
  On the CLIENT, the bearer token is held IN MEMORY only — a `localStorage` copy is
947
960
  XSS-exfiltratable and is forbidden. The session is restored after a reload via the
948
961
  httpOnly cookie + `GET /users/me`; don't persist the token yourself.
package/dist/index.d.ts CHANGED
@@ -20,6 +20,19 @@
20
20
  * so a handler reads the current user with `getUserId(res)` and does NOT add per-route auth
21
21
  * middleware (see the `auth` skill). Scope every custom user query by the authenticated id.
22
22
  *
23
+ * **Issuing a session yourself:** the middleware accepts both `Authorization: Bearer <jwt>`
24
+ * and `Authorization: Token <jwt>` (RealWorld's scheme), but only for a token whose
25
+ * `deviceId` names an ACTIVE row in `devices`. A JWT you `sign()` with an invented `deviceId`
26
+ * is answered 401 on every route. Mint sessions the way the built-in login does — create the
27
+ * device with `get('device').createOrUpdate(userId, deviceName)` (it returns the device id; or call
28
+ * `authorization.set(…)`) and sign that id — instead of inventing one.
29
+ *
30
+ * **Revoking a session yourself:** the middleware caches "this device exists" for 10 s per
31
+ * process, so a hand-written logout that deletes the `devices` row keeps authorizing that
32
+ * token until the cache expires — a check right after logout still answers 200. Call
33
+ * `invalidateDeviceExistsCache(deviceId)` (or `invalidateAllDeviceExistsCache()`) after the
34
+ * delete; the built-in log-out route already does.
35
+ *
23
36
  * On the CLIENT, the bearer token is held IN MEMORY only — a `localStorage` copy is
24
37
  * XSS-exfiltratable and is forbidden. The session is restored after a reload via the
25
38
  * httpOnly cookie + `GET /users/me`; don't persist the token yourself.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqFG;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,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkGG;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,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
@@ -20,6 +20,19 @@
20
20
  * so a handler reads the current user with `getUserId(res)` and does NOT add per-route auth
21
21
  * middleware (see the `auth` skill). Scope every custom user query by the authenticated id.
22
22
  *
23
+ * **Issuing a session yourself:** the middleware accepts both `Authorization: Bearer <jwt>`
24
+ * and `Authorization: Token <jwt>` (RealWorld's scheme), but only for a token whose
25
+ * `deviceId` names an ACTIVE row in `devices`. A JWT you `sign()` with an invented `deviceId`
26
+ * is answered 401 on every route. Mint sessions the way the built-in login does — create the
27
+ * device with `get('device').createOrUpdate(userId, deviceName)` (it returns the device id; or call
28
+ * `authorization.set(…)`) and sign that id — instead of inventing one.
29
+ *
30
+ * **Revoking a session yourself:** the middleware caches "this device exists" for 10 s per
31
+ * process, so a hand-written logout that deletes the `devices` row keeps authorizing that
32
+ * token until the cache expires — a check right after logout still answers 200. Call
33
+ * `invalidateDeviceExistsCache(deviceId)` (or `invalidateAllDeviceExistsCache()`) after the
34
+ * delete; the built-in log-out route already does.
35
+ *
23
36
  * On the CLIENT, the bearer token is held IN MEMORY only — a `localStorage` copy is
24
37
  * XSS-exfiltratable and is forbidden. The session is restored after a reload via the
25
38
  * httpOnly cookie + `GET /users/me`; don't persist the token yourself.
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqFG;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,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkGG;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,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.4.11",
3
+ "version": "1.4.13",
4
4
  "description": "User resource types and schema for molecule.dev.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",