@molecule/api-resource-user 1.4.12 → 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 +8 -1
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -0
- 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-10-
|
|
6
|
+
Generated: 2026-10-15T23:29:57.665Z
|
|
7
7
|
-->
|
|
8
8
|
|
|
9
9
|
# @molecule/api-resource-user
|
|
@@ -943,6 +943,13 @@ 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
|
+
|
|
946
953
|
**Revoking a session yourself:** the middleware caches "this device exists" for 10 s per
|
|
947
954
|
process, so a hand-written logout that deletes the `devices` row keeps authorizing that
|
|
948
955
|
token until the cache expires — a check right after logout still answers 200. Call
|
package/dist/index.d.ts
CHANGED
|
@@ -20,6 +20,13 @@
|
|
|
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
|
+
*
|
|
23
30
|
* **Revoking a session yourself:** the middleware caches "this device exists" for 10 s per
|
|
24
31
|
* process, so a hand-written logout that deletes the `devices` row keeps authorizing that
|
|
25
32
|
* token until the cache expires — a check right after logout still answers 200. Call
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,13 @@
|
|
|
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
|
+
*
|
|
23
30
|
* **Revoking a session yourself:** the middleware caches "this device exists" for 10 s per
|
|
24
31
|
* process, so a hand-written logout that deletes the `devices` row keeps authorizing that
|
|
25
32
|
* token until the cache expires — a check right after logout still answers 200. Call
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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"}
|