@molecule/api-jwt 1.0.10 → 1.0.11
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 +16 -9
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/provider.d.ts +10 -8
- package/dist/provider.d.ts.map +1 -1
- package/dist/provider.js +10 -8
- package/dist/provider.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-11T21:01:02.381Z
|
|
7
7
|
-->
|
|
8
8
|
|
|
9
9
|
# @molecule/api-jwt
|
|
@@ -238,14 +238,16 @@ Signs a payload into a JWT string using the bonded provider. Uses the
|
|
|
238
238
|
configured algorithm, expiry, and private key as defaults.
|
|
239
239
|
|
|
240
240
|
This is the LOW-LEVEL signer: it signs whatever payload it is given, and a
|
|
241
|
-
token it mints is not by itself a session.
|
|
242
|
-
|
|
243
|
-
`
|
|
244
|
-
`
|
|
245
|
-
|
|
246
|
-
`
|
|
247
|
-
|
|
248
|
-
`
|
|
241
|
+
token it mints is not by itself a session. **To sign a user in from a route of
|
|
242
|
+
your own, do not call this: `@molecule/api-resource-user` exports
|
|
243
|
+
`createAccount({ username, email, password }, { req, res })` and
|
|
244
|
+
`signIn({ email, password }, { req, res })`, which resolve to
|
|
245
|
+
`{ ok: true, user, token }` — `token` is the session, signed by this provider —
|
|
246
|
+
and `issueSession(userId, { req, res })` for an account authenticated some other
|
|
247
|
+
way.** The app's global `verifyMiddleware` accepts a JWT only when its payload
|
|
248
|
+
also carries a `deviceId` naming an active row in `devices` (see the module
|
|
249
|
+
`@remarks`); those functions create that row, and a token signed here by hand
|
|
250
|
+
names none, so every route answers it 401.
|
|
249
251
|
|
|
250
252
|
**There is ONE JWT provider per app, and this signs with it.** The scaffold
|
|
251
253
|
bonds `@molecule/api-jwt-jsonwebtoken` once (the app's `api/src/bonds/`), keyed
|
|
@@ -404,6 +406,11 @@ anything security-relevant; `decode()` is only for reading a token you do NOT tr
|
|
|
404
406
|
and populates `res.locals.session`, so a handler calls `getUserId(res)` — do NOT call
|
|
405
407
|
`verify()`/`sign()` by hand for the session (see the `auth` skill). Use these directly
|
|
406
408
|
only for a CUSTOM token, e.g. a signed email/reset link.
|
|
409
|
+
- **Signing a user in from a route of your own? Call `signIn({ email, password }, { req, res })`
|
|
410
|
+
or `createAccount({ username, email, password }, { req, res })` from
|
|
411
|
+
`@molecule/api-resource-user`: each resolves to `{ ok: true, user, token }`, and `token` is
|
|
412
|
+
the session, signed by this package's provider. `issueSession(userId, { req, res })` does the
|
|
413
|
+
same for an account authenticated some other way. None of them needs `sign()`.**
|
|
407
414
|
- **{@link sign} is the low-level signer; a token it mints is NOT a session.**
|
|
408
415
|
`verifyMiddleware` (`@molecule/api-resource-user`) accepts a JWT only when its payload
|
|
409
416
|
also carries a `deviceId` naming an ACTIVE row in the app's `devices` table, so a
|
package/dist/index.d.ts
CHANGED
|
@@ -21,6 +21,11 @@
|
|
|
21
21
|
* and populates `res.locals.session`, so a handler calls `getUserId(res)` — do NOT call
|
|
22
22
|
* `verify()`/`sign()` by hand for the session (see the `auth` skill). Use these directly
|
|
23
23
|
* only for a CUSTOM token, e.g. a signed email/reset link.
|
|
24
|
+
* - **Signing a user in from a route of your own? Call `signIn({ email, password }, { req, res })`
|
|
25
|
+
* or `createAccount({ username, email, password }, { req, res })` from
|
|
26
|
+
* `@molecule/api-resource-user`: each resolves to `{ ok: true, user, token }`, and `token` is
|
|
27
|
+
* the session, signed by this package's provider. `issueSession(userId, { req, res })` does the
|
|
28
|
+
* same for an account authenticated some other way. None of them needs `sign()`.**
|
|
24
29
|
* - **{@link sign} is the low-level signer; a token it mints is NOT a session.**
|
|
25
30
|
* `verifyMiddleware` (`@molecule/api-resource-user`) accepts a JWT only when its payload
|
|
26
31
|
* also carries a `deviceId` naming an ACTIVE row in the app's `devices` table, so a
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6EG;AAEH,cAAc,oBAAoB,CAAA;AAClC,cAAc,WAAW,CAAA;AACzB,cAAc,eAAe,CAAA;AAC7B,cAAc,YAAY,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -21,6 +21,11 @@
|
|
|
21
21
|
* and populates `res.locals.session`, so a handler calls `getUserId(res)` — do NOT call
|
|
22
22
|
* `verify()`/`sign()` by hand for the session (see the `auth` skill). Use these directly
|
|
23
23
|
* only for a CUSTOM token, e.g. a signed email/reset link.
|
|
24
|
+
* - **Signing a user in from a route of your own? Call `signIn({ email, password }, { req, res })`
|
|
25
|
+
* or `createAccount({ username, email, password }, { req, res })` from
|
|
26
|
+
* `@molecule/api-resource-user`: each resolves to `{ ok: true, user, token }`, and `token` is
|
|
27
|
+
* the session, signed by this package's provider. `issueSession(userId, { req, res })` does the
|
|
28
|
+
* same for an account authenticated some other way. None of them needs `sign()`.**
|
|
24
29
|
* - **{@link sign} is the low-level signer; a token it mints is NOT a session.**
|
|
25
30
|
* `verifyMiddleware` (`@molecule/api-resource-user`) accepts a JWT only when its payload
|
|
26
31
|
* also carries a `deviceId` naming an ACTIVE row in the app's `devices` table, so a
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6EG;AAEH,cAAc,oBAAoB,CAAA;AAClC,cAAc,WAAW,CAAA;AACzB,cAAc,eAAe,CAAA;AAC7B,cAAc,YAAY,CAAA"}
|
package/dist/provider.d.ts
CHANGED
|
@@ -51,14 +51,16 @@ export declare const hasProvider: () => boolean;
|
|
|
51
51
|
* configured algorithm, expiry, and private key as defaults.
|
|
52
52
|
*
|
|
53
53
|
* This is the LOW-LEVEL signer: it signs whatever payload it is given, and a
|
|
54
|
-
* token it mints is not by itself a session.
|
|
55
|
-
*
|
|
56
|
-
* `
|
|
57
|
-
* `
|
|
58
|
-
*
|
|
59
|
-
* `
|
|
60
|
-
*
|
|
61
|
-
* `
|
|
54
|
+
* token it mints is not by itself a session. **To sign a user in from a route of
|
|
55
|
+
* your own, do not call this: `@molecule/api-resource-user` exports
|
|
56
|
+
* `createAccount({ username, email, password }, { req, res })` and
|
|
57
|
+
* `signIn({ email, password }, { req, res })`, which resolve to
|
|
58
|
+
* `{ ok: true, user, token }` — `token` is the session, signed by this provider —
|
|
59
|
+
* and `issueSession(userId, { req, res })` for an account authenticated some other
|
|
60
|
+
* way.** The app's global `verifyMiddleware` accepts a JWT only when its payload
|
|
61
|
+
* also carries a `deviceId` naming an active row in `devices` (see the module
|
|
62
|
+
* `@remarks`); those functions create that row, and a token signed here by hand
|
|
63
|
+
* names none, so every route answers it 401.
|
|
62
64
|
*
|
|
63
65
|
* **There is ONE JWT provider per app, and this signs with it.** The scaffold
|
|
64
66
|
* bonds `@molecule/api-jwt-jsonwebtoken` once (the app's `api/src/bonds/`), keyed
|
package/dist/provider.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,OAAO,KAAK,EACV,UAAU,EACV,YAAY,EACZ,gBAAgB,EAChB,UAAU,EACV,WAAW,EACX,cAAc,EACd,gBAAgB,EACjB,MAAM,YAAY,CAAA;AAkDnB;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,cAAwB,CAAA;AAElD;;;GAGG;AACH,eAAO,MAAM,gBAAgB,QAA2D,CAAA;AAExF;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,QAAkD,CAAA;AAE/E;;;;;GAKG;AACH,eAAO,MAAM,WAAW,GAAI,UAAU,WAAW,KAAG,IAEnD,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,WAAW,QAAO,WAE9B,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,WAAW,QAAO,OAE9B,CAAA;AAED
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,OAAO,KAAK,EACV,UAAU,EACV,YAAY,EACZ,gBAAgB,EAChB,UAAU,EACV,WAAW,EACX,cAAc,EACd,gBAAgB,EACjB,MAAM,YAAY,CAAA;AAkDnB;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,cAAwB,CAAA;AAElD;;;GAGG;AACH,eAAO,MAAM,gBAAgB,QAA2D,CAAA;AAExF;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,QAAkD,CAAA;AAE/E;;;;;GAKG;AACH,eAAO,MAAM,WAAW,GAAI,UAAU,WAAW,KAAG,IAEnD,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,WAAW,QAAO,WAE9B,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,WAAW,QAAO,OAE9B,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,eAAO,MAAM,IAAI,GACf,QAAQ,UAAU,EAClB,oCAAsE,cAAmB,EACzF,aAAY,MAAM,GAAG,MAAwB,KAC5C,MAAmF,CAAA;AAEtF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,MAAM,GACjB,OAAO,MAAM,EACb,0BAA2C,gBAAqB,EAChE,YAAW,MAAM,GAAG,MAAuB,KAC1C,MAAM,GAAG,UAA6E,CAAA;AAEzF;;;;;;;GAOG;AACH,eAAO,MAAM,MAAM,GAAI,OAAO,MAAM,EAAE,UAAU,gBAAgB,KAAG,MAAM,GAAG,UAAU,GAAG,IACnD,CAAA"}
|
package/dist/provider.js
CHANGED
|
@@ -100,14 +100,16 @@ export const hasProvider = () => {
|
|
|
100
100
|
* configured algorithm, expiry, and private key as defaults.
|
|
101
101
|
*
|
|
102
102
|
* This is the LOW-LEVEL signer: it signs whatever payload it is given, and a
|
|
103
|
-
* token it mints is not by itself a session.
|
|
104
|
-
*
|
|
105
|
-
* `
|
|
106
|
-
* `
|
|
107
|
-
*
|
|
108
|
-
* `
|
|
109
|
-
*
|
|
110
|
-
* `
|
|
103
|
+
* token it mints is not by itself a session. **To sign a user in from a route of
|
|
104
|
+
* your own, do not call this: `@molecule/api-resource-user` exports
|
|
105
|
+
* `createAccount({ username, email, password }, { req, res })` and
|
|
106
|
+
* `signIn({ email, password }, { req, res })`, which resolve to
|
|
107
|
+
* `{ ok: true, user, token }` — `token` is the session, signed by this provider —
|
|
108
|
+
* and `issueSession(userId, { req, res })` for an account authenticated some other
|
|
109
|
+
* way.** The app's global `verifyMiddleware` accepts a JWT only when its payload
|
|
110
|
+
* also carries a `deviceId` naming an active row in `devices` (see the module
|
|
111
|
+
* `@remarks`); those functions create that row, and a token signed here by hand
|
|
112
|
+
* names none, so every route answers it 401.
|
|
111
113
|
*
|
|
112
114
|
* **There is ONE JWT provider per app, and this signs with it.** The scaffold
|
|
113
115
|
* bonds `@molecule/api-jwt-jsonwebtoken` once (the app's `api/src/bonds/`), keyed
|
package/dist/provider.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAElG,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAW3D,MAAM,MAAM,GAAG,SAAS,EAAE,CAAA;AAE1B,MAAM,SAAS,GAAG,KAAK,CAAA;AACvB,UAAU,CAAC,SAAS,CAAC,CAAA;AAErB,8DAA8D;AAC9D,MAAM,oBAAoB,GAA4B;IACpD,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;CACR,CAAA;AAED;;;;;;;;;;;GAWG;AACH,MAAM,mBAAmB,GAAG,GAAiB,EAAE;IAC7C,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,aAAa,CAAA;IACrC,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,OAAO,OAAO,CAAA;IAChB,CAAC;IACD,IAAK,oBAA0C,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QAC9D,OAAO,GAAmB,CAAA;IAC5B,CAAC;IACD,MAAM,CAAC,IAAI,CACT,4BAA4B,GAAG,6CAA6C;QAC1E,4CAA4C,oBAAoB,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CACjF,CAAA;IACD,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA;AAED;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,mBAAmB,EAAE,CAAA;AAElD;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG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