@molecule/api-resource-user 1.4.7 → 1.4.8
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 +2 -1
- package/dist/handlers/logIn.d.ts.map +1 -1
- package/dist/handlers/logIn.js +54 -15
- package/dist/handlers/logIn.js.map +1 -1
- package/dist/handlers/resetPassword.d.ts +14 -0
- package/dist/handlers/resetPassword.d.ts.map +1 -1
- package/dist/handlers/resetPassword.js +36 -3
- package/dist/handlers/resetPassword.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-09T13:50:49.876Z
|
|
7
7
|
-->
|
|
8
8
|
|
|
9
9
|
# @molecule/api-resource-user
|
|
@@ -548,6 +548,7 @@ Members:
|
|
|
548
548
|
- `handlers.oauthAuthorize` — function: OAuth initiation — `GET /users/oauth/:provider`.
|
|
549
549
|
- `handlers.read` — function: Reads a user by ID from the database. Attaches plan info (with expiration/renewal status) via the
|
|
550
550
|
- `handlers.readSelf` — function: Reads the AUTHENTICATED user from the session — no `:id` param. Backs
|
|
551
|
+
- `handlers.RESET_TOKEN_TTL_MS` — const: How long a password-reset token stays valid, in milliseconds. Shared with
|
|
551
552
|
- `handlers.ResetPasswordRequest` — interface: Request body for confirming a password reset using a token.
|
|
552
553
|
- `handlers.resetPassword` — function: Confirms a password reset by validating the one-time token previously generated by
|
|
553
554
|
- `handlers.update` — function: Updates a user's profile fields (username, name, email). Validates username format
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logIn.d.ts","sourceRoot":"","sources":["../../src/handlers/logIn.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAG/E,OAAO,KAAK,KAAK,KAAK,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"logIn.d.ts","sourceRoot":"","sources":["../../src/handlers/logIn.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAG/E,OAAO,KAAK,KAAK,KAAK,MAAM,aAAa,CAAA;AAwBzC,oFAAoF;AACpF,MAAM,WAAW,YAAa,SAAQ,eAAe;IACnD,IAAI,EAAE;QACJ,QAAQ,CAAC,EAAE,MAAM,CAAA;QACjB,KAAK,CAAC,EAAE,MAAM,CAAA;QACd,QAAQ,CAAC,EAAE,MAAM,CAAA;QACjB,kBAAkB,CAAC,EAAE,MAAM,CAAA;QAC3B,cAAc,CAAC,EAAE,MAAM,CAAA;QACvB,UAAU,CAAC,EAAE,MAAM,CAAA;KACpB,CAAA;CACF;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,KAAK,GAAI,6CAA6C,KAAK,CAAC,QAAQ,MACjE,KAAK,YAAY,EAAE,KAAK,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8RvD,CAAA"}
|
package/dist/handlers/logIn.js
CHANGED
|
@@ -8,6 +8,7 @@ import { hashResetToken } from '../utilities/hashResetToken.js';
|
|
|
8
8
|
import { normalizeEmail } from '../utilities/normalizeEmail.js';
|
|
9
9
|
import { notify } from '../utilities/notify.js';
|
|
10
10
|
import { stripSensitiveUserColumns } from '../utilities/stripSensitiveUserColumns.js';
|
|
11
|
+
import { RESET_TOKEN_TTL_MS } from './resetPassword.js';
|
|
11
12
|
const analytics = getAnalytics();
|
|
12
13
|
const logger = getLogger();
|
|
13
14
|
/**
|
|
@@ -99,32 +100,38 @@ export const logIn = ({ name: _name, tableName, schema: _schema }) => {
|
|
|
99
100
|
};
|
|
100
101
|
}
|
|
101
102
|
let authenticated = false;
|
|
103
|
+
// Whether authentication came from the one-time reset token (as opposed
|
|
104
|
+
// to a reusable password): its consumption is DEFERRED until every
|
|
105
|
+
// challenge that can still bounce the request (the 2FA challenge below)
|
|
106
|
+
// has passed, and then happens atomically before any session is minted.
|
|
107
|
+
// Consuming it up front burned the link on the 206 two-factor challenge,
|
|
108
|
+
// so the documented retry (same body plus `twoFactorToken`) always found
|
|
109
|
+
// a NULL token and could never complete the login — every attempt spent
|
|
110
|
+
// a fresh reset link for nothing.
|
|
111
|
+
let authenticatedByResetToken = false;
|
|
102
112
|
// Try password authentication.
|
|
103
113
|
if (body.password && secrets.passwordHash) {
|
|
104
114
|
authenticated = await compare(body.password, secrets.passwordHash);
|
|
105
115
|
}
|
|
106
116
|
// Try password reset token (constant-time comparison to prevent timing
|
|
107
117
|
// attacks). The stored value is sha256(token) — hash the incoming one.
|
|
118
|
+
// Read-only here: the TTL is checked, but the token is NOT consumed yet.
|
|
108
119
|
if (!authenticated && body.passwordResetToken && secrets.passwordResetToken) {
|
|
109
120
|
const a = Buffer.from(hashResetToken(body.passwordResetToken), 'utf-8');
|
|
110
121
|
const b = Buffer.from(secrets.passwordResetToken, 'utf-8');
|
|
111
122
|
if (a.length === b.length && crypto.timingSafeEqual(a, b)) {
|
|
112
|
-
// Check if the token is still valid (within 1 hour).
|
|
123
|
+
// Check if the token is still valid (within 1 hour). The SAME gate
|
|
124
|
+
// as resetPassword — the same constant and the same boundary
|
|
125
|
+
// (`tokenAge` equal to the TTL is still valid, exactly as the reset
|
|
126
|
+
// confirmation treats it): an unparseable or future-dated timestamp
|
|
127
|
+
// is refused here too — this path mints an authenticated session,
|
|
128
|
+
// so it must not be looser than the reset path for the same
|
|
129
|
+
// one-hour credential.
|
|
113
130
|
if (secrets.passwordResetTokenAt) {
|
|
114
131
|
const tokenAge = Date.now() - new Date(secrets.passwordResetTokenAt).getTime();
|
|
115
|
-
if (tokenAge
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
// requests holding the same token only the one that flips it to
|
|
119
|
-
// NULL matches a row — the other sees affected 0 and is refused.
|
|
120
|
-
// (A plain updateById cleared "whatever is there", so both
|
|
121
|
-
// requests passed and both minted sessions.)
|
|
122
|
-
const consumed = await updateMany(`${tableName}Secrets`, [
|
|
123
|
-
{ field: 'id', operator: '=', value: user.id },
|
|
124
|
-
{ field: 'passwordResetToken', operator: '=', value: secrets.passwordResetToken },
|
|
125
|
-
], { passwordResetToken: null, passwordResetTokenAt: null });
|
|
126
|
-
if (consumed.affected === 1)
|
|
127
|
-
authenticated = true;
|
|
132
|
+
if (Number.isFinite(tokenAge) && tokenAge >= 0 && tokenAge <= RESET_TOKEN_TTL_MS) {
|
|
133
|
+
authenticated = true;
|
|
134
|
+
authenticatedByResetToken = true;
|
|
128
135
|
}
|
|
129
136
|
}
|
|
130
137
|
}
|
|
@@ -215,6 +222,34 @@ export const logIn = ({ name: _name, tableName, schema: _schema }) => {
|
|
|
215
222
|
};
|
|
216
223
|
}
|
|
217
224
|
}
|
|
225
|
+
// Consume the one-time reset token ATOMICALLY, now that every challenge
|
|
226
|
+
// that can still refuse the request has passed: the clear is
|
|
227
|
+
// WHERE-guarded on the very token value that was verified above, so of
|
|
228
|
+
// two concurrent requests holding the same token only the one that
|
|
229
|
+
// flips it to NULL matches a row — the other sees affected 0 and is
|
|
230
|
+
// refused instead of minting a session. (A plain updateById cleared
|
|
231
|
+
// "whatever is there", so both requests passed and both minted
|
|
232
|
+
// sessions.) This must stay AFTER the 2FA gate — a 206 challenge must
|
|
233
|
+
// not burn the link, the retry needs it — and BEFORE any session is
|
|
234
|
+
// minted below.
|
|
235
|
+
if (authenticatedByResetToken) {
|
|
236
|
+
const consumed = await updateMany(`${tableName}Secrets`, [
|
|
237
|
+
{ field: 'id', operator: '=', value: user.id },
|
|
238
|
+
{ field: 'passwordResetToken', operator: '=', value: secrets.passwordResetToken },
|
|
239
|
+
], { passwordResetToken: null, passwordResetTokenAt: null });
|
|
240
|
+
if (consumed.affected !== 1) {
|
|
241
|
+
analytics
|
|
242
|
+
.track({ name: 'user.login_failed', properties: { reason: 'invalid_credentials' } })
|
|
243
|
+
.catch(() => { });
|
|
244
|
+
return {
|
|
245
|
+
statusCode: 403,
|
|
246
|
+
body: {
|
|
247
|
+
error: t('user.error.invalidCredentials'),
|
|
248
|
+
errorKey: 'user.error.invalidCredentials',
|
|
249
|
+
},
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
}
|
|
218
253
|
// Create or update device.
|
|
219
254
|
const deviceId = await get('device')?.createOrUpdate(user.id, body.deviceName || 'Unknown');
|
|
220
255
|
if (!deviceId) {
|
|
@@ -243,7 +278,11 @@ export const logIn = ({ name: _name, tableName, schema: _schema }) => {
|
|
|
243
278
|
.track({
|
|
244
279
|
name: 'user.login',
|
|
245
280
|
userId: user.id,
|
|
246
|
-
|
|
281
|
+
// What ACTUALLY authenticated the request: a body carrying both a
|
|
282
|
+
// valid password and a reset token authenticated by the password and
|
|
283
|
+
// did NOT spend the link — calling that a reset_token login makes
|
|
284
|
+
// the event lie about which credential is still live.
|
|
285
|
+
properties: { method: authenticatedByResetToken ? 'reset_token' : 'password' },
|
|
247
286
|
})
|
|
248
287
|
.catch(() => { });
|
|
249
288
|
// `user` is a `SELECT *` row — strip secret columns (email-confirmation /
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logIn.js","sourceRoot":"","sources":["../../src/handlers/logIn.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAA;AAEhC,OAAO,EAAE,GAAG,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AACjE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAuB,MAAM,wBAAwB,CAAA;AAC3F,OAAO,EAAE,CAAC,EAAE,MAAM,oBAAoB,CAAA;AACtC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAA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AE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,CAAA;QACpF,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;YACnB,OAAO;gBACL,UAAU,EAAE,GAAG;gBACf,IAAI,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,wBAAwB,CAAC,EAAE,QAAQ,EAAE,wBAAwB,EAAE;aACjF,CAAA;QACH,CAAC;IACH,CAAC,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import type { MoleculeRequest } from '@molecule/api-resource';
|
|
2
2
|
import type * as types from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* How long a password-reset token stays valid, in milliseconds. Shared with
|
|
5
|
+
* `logIn`, which accepts the same token as a login credential and must apply
|
|
6
|
+
* the SAME gate — the same constant AND the same boundary (`tokenAge` equal to
|
|
7
|
+
* the TTL is still valid in both), or one path becomes the looser way in for
|
|
8
|
+
* the other's one-hour credential.
|
|
9
|
+
*/
|
|
10
|
+
export declare const RESET_TOKEN_TTL_MS: number;
|
|
3
11
|
/** Request body for confirming a password reset using a token. */
|
|
4
12
|
export interface ResetPasswordRequest extends MoleculeRequest {
|
|
5
13
|
body: {
|
|
@@ -18,6 +26,12 @@ export interface ResetPasswordRequest extends MoleculeRequest {
|
|
|
18
26
|
* On success, all existing device sessions are invalidated to force a fresh login,
|
|
19
27
|
* mirroring the behavior of `updatePassword`.
|
|
20
28
|
*
|
|
29
|
+
* The new password and the token clear are written as ONE WHERE-guarded update
|
|
30
|
+
* matching the verified token hash, so the link is consumed atomically: of two
|
|
31
|
+
* concurrent requests holding the same link, only the one that flips the token
|
|
32
|
+
* to NULL matches a row — the other is refused with 401 and cannot overwrite
|
|
33
|
+
* the winner's password.
|
|
34
|
+
*
|
|
21
35
|
* @param resource - The user resource configuration (name, tableName, schema).
|
|
22
36
|
* @param resource.tableName - The database table name for users.
|
|
23
37
|
* @returns A request handler that responds with `{ statusCode: 200, body: { success: true } }` on success.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resetPassword.d.ts","sourceRoot":"","sources":["../../src/handlers/resetPassword.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAG7D,OAAO,KAAK,KAAK,KAAK,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"resetPassword.d.ts","sourceRoot":"","sources":["../../src/handlers/resetPassword.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAG7D,OAAO,KAAK,KAAK,KAAK,MAAM,aAAa,CAAA;AAMzC;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,QAAiB,CAAA;AAEhD,kEAAkE;AAClE,MAAM,WAAW,oBAAqB,SAAQ,eAAe;IAC3D,IAAI,EAAE;QACJ,KAAK,CAAC,EAAE,MAAM,CAAA;QACd,QAAQ,CAAC,EAAE,MAAM,CAAA;KAClB,CAAA;CACF;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,aAAa,GAAI,6CAA6C,KAAK,CAAC,QAAQ,MACzE,KAAK,oBAAoB;;;;;;;;;;;;;;EA6JxC,CAAA"}
|
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
import crypto from 'node:crypto';
|
|
2
2
|
import { get, getAnalytics, getLogger } from '@molecule/api-bond';
|
|
3
|
-
import { findOne,
|
|
3
|
+
import { findOne, updateMany } from '@molecule/api-database';
|
|
4
4
|
import { t } from '@molecule/api-i18n';
|
|
5
5
|
import { hash } from '@molecule/api-password';
|
|
6
6
|
import { invalidateAllDeviceExistsCache } from '../authorization.js';
|
|
7
7
|
import { hashResetToken } from '../utilities/hashResetToken.js';
|
|
8
8
|
const analytics = getAnalytics();
|
|
9
9
|
const logger = getLogger();
|
|
10
|
-
|
|
10
|
+
/**
|
|
11
|
+
* How long a password-reset token stays valid, in milliseconds. Shared with
|
|
12
|
+
* `logIn`, which accepts the same token as a login credential and must apply
|
|
13
|
+
* the SAME gate — the same constant AND the same boundary (`tokenAge` equal to
|
|
14
|
+
* the TTL is still valid in both), or one path becomes the looser way in for
|
|
15
|
+
* the other's one-hour credential.
|
|
16
|
+
*/
|
|
17
|
+
export const RESET_TOKEN_TTL_MS = 1000 * 60 * 60;
|
|
11
18
|
/**
|
|
12
19
|
* Confirms a password reset by validating the one-time token previously generated by
|
|
13
20
|
* `forgotPassword`, then hashing and storing the new password and clearing the token.
|
|
@@ -19,6 +26,12 @@ const RESET_TOKEN_TTL_MS = 1000 * 60 * 60;
|
|
|
19
26
|
* On success, all existing device sessions are invalidated to force a fresh login,
|
|
20
27
|
* mirroring the behavior of `updatePassword`.
|
|
21
28
|
*
|
|
29
|
+
* The new password and the token clear are written as ONE WHERE-guarded update
|
|
30
|
+
* matching the verified token hash, so the link is consumed atomically: of two
|
|
31
|
+
* concurrent requests holding the same link, only the one that flips the token
|
|
32
|
+
* to NULL matches a row — the other is refused with 401 and cannot overwrite
|
|
33
|
+
* the winner's password.
|
|
34
|
+
*
|
|
22
35
|
* @param resource - The user resource configuration (name, tableName, schema).
|
|
23
36
|
* @param resource.tableName - The database table name for users.
|
|
24
37
|
* @returns A request handler that responds with `{ statusCode: 200, body: { success: true } }` on success.
|
|
@@ -115,11 +128,31 @@ export const resetPassword = ({ name: _name, tableName, schema: _schema }) => {
|
|
|
115
128
|
};
|
|
116
129
|
}
|
|
117
130
|
const passwordHash = await hash(password);
|
|
118
|
-
|
|
131
|
+
// Consume the link ATOMICALLY: the password write and the token clear
|
|
132
|
+
// are one WHERE-guarded update matching the very token hash that was
|
|
133
|
+
// just verified, so of two concurrent requests holding the same link
|
|
134
|
+
// only the one that flips the token to NULL matches a row — the loser's
|
|
135
|
+
// write hits nothing and is refused below, instead of silently
|
|
136
|
+
// overwriting the winner's password with its own (a plain updateById
|
|
137
|
+
// let both requests "succeed": last write won and both got a 200).
|
|
138
|
+
const consumed = await updateMany(`${tableName}Secrets`, [
|
|
139
|
+
{ field: 'id', operator: '=', value: userId },
|
|
140
|
+
{ field: 'passwordResetToken', operator: '=', value: tokenHash },
|
|
141
|
+
], {
|
|
119
142
|
passwordHash,
|
|
120
143
|
passwordResetToken: null,
|
|
121
144
|
passwordResetTokenAt: null,
|
|
122
145
|
});
|
|
146
|
+
if (consumed.affected !== 1) {
|
|
147
|
+
// Another request spent this link between our read and this write.
|
|
148
|
+
return {
|
|
149
|
+
statusCode: 401,
|
|
150
|
+
body: {
|
|
151
|
+
error: t('user.error.invalidToken'),
|
|
152
|
+
errorKey: 'user.error.invalidToken',
|
|
153
|
+
},
|
|
154
|
+
};
|
|
155
|
+
}
|
|
123
156
|
try {
|
|
124
157
|
await get('device')?.deleteByUserId(userId);
|
|
125
158
|
// Evict this process's positive device-exists cache so no just-deleted
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resetPassword.js","sourceRoot":"","sources":["../../src/handlers/resetPassword.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAA;AAEhC,OAAO,EAAE,GAAG,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AACjE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAC5D,OAAO,EAAE,CAAC,EAAE,MAAM,oBAAoB,CAAA;AACtC,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAA;AAG7C,OAAO,EAAE,8BAA8B,EAAE,MAAM,qBAAqB,CAAA;AAEpE,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AAE/D,MAAM,SAAS,GAAG,YAAY,EAAE,CAAA;AAChC,MAAM,MAAM,GAAG,SAAS,EAAE,CAAA;AAE1B,MAAM,kBAAkB,GAAG,IAAI,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