@fonderie/auth 7.1.0 → 7.1.1
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/dist/index.cjs +18 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +5 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1156,6 +1156,8 @@ function normalizeEmailSafe(email2) {
|
|
|
1156
1156
|
}
|
|
1157
1157
|
|
|
1158
1158
|
// src/models/password-reset.model.ts
|
|
1159
|
+
import { createHash } from "crypto";
|
|
1160
|
+
var hashSecret = (value) => createHash("sha256").update(value).digest("hex");
|
|
1159
1161
|
var PasswordResetModel = class {
|
|
1160
1162
|
constructor(store) {
|
|
1161
1163
|
this.store = store;
|
|
@@ -1167,7 +1169,7 @@ var PasswordResetModel = class {
|
|
|
1167
1169
|
VALUES ($1, $2, $3, $4, now())
|
|
1168
1170
|
ON CONFLICT (user_id) DO UPDATE
|
|
1169
1171
|
SET pin = $2, token = $3, expires_at = $4, created_at = now()`,
|
|
1170
|
-
[userId, pin, token, expiresAt]
|
|
1172
|
+
[userId, hashSecret(pin), hashSecret(token), expiresAt]
|
|
1171
1173
|
);
|
|
1172
1174
|
}
|
|
1173
1175
|
async findLastSentAt(userId) {
|
|
@@ -1181,7 +1183,7 @@ var PasswordResetModel = class {
|
|
|
1181
1183
|
async findByPin(pin) {
|
|
1182
1184
|
const [row] = await this.store.query(
|
|
1183
1185
|
`SELECT user_id, expires_at FROM fonderie_password_resets WHERE pin = $1`,
|
|
1184
|
-
[pin]
|
|
1186
|
+
[hashSecret(pin)]
|
|
1185
1187
|
);
|
|
1186
1188
|
if (!row) return null;
|
|
1187
1189
|
return { userId: row.user_id, expiresAt: new Date(row.expires_at) };
|
|
@@ -1194,7 +1196,7 @@ var PasswordResetModel = class {
|
|
|
1194
1196
|
if (typeof token !== "string" || token.length < 32) return null;
|
|
1195
1197
|
const [row] = await this.store.query(
|
|
1196
1198
|
`SELECT user_id, expires_at FROM fonderie_password_resets WHERE token = $1`,
|
|
1197
|
-
[token]
|
|
1199
|
+
[hashSecret(token)]
|
|
1198
1200
|
);
|
|
1199
1201
|
if (!row) return null;
|
|
1200
1202
|
return { userId: row.user_id, expiresAt: new Date(row.expires_at) };
|