@cossackframework/cms 0.9.6 → 0.9.7
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/app/src/auth.ts
CHANGED
|
@@ -1149,17 +1149,19 @@ export async function apiTokenUser(token: string): Promise<{ user: PublicUser; s
|
|
|
1149
1149
|
* `MAIL_FROM` via the global helpers — no `Context` parameter needed. If the
|
|
1150
1150
|
* send_email binding is not configured, this is a graceful no-op.
|
|
1151
1151
|
*/
|
|
1152
|
-
export async function requestPasswordReset(email: string
|
|
1152
|
+
export async function requestPasswordReset(email: string): Promise<void> {
|
|
1153
1153
|
return accountByEmail(email, () => accounts(async () => {
|
|
1154
1154
|
// Beyond the limits per email and per address nothing is sent, and the answer is the same.
|
|
1155
1155
|
const key = await security.sha256Hex(email.trim().toLowerCase());
|
|
1156
1156
|
if (!(await security.attempt('reset', `e:${key}`, security.RESET_REQUESTS.perEmail, security.RESET_REQUESTS.windowMs))
|
|
1157
1157
|
|| !(await security.attempt('reset', `a:${clientAddress()}`, security.RESET_REQUESTS.perAddress, security.RESET_REQUESTS.windowMs))) return;
|
|
1158
|
+
// The link opens on the site's own address. A link built from the request's Host header
|
|
1159
|
+
// would send the token to whatever server the client named.
|
|
1160
|
+
const [mail, origin] = [mailer(), linkOrigin()];
|
|
1161
|
+
if (!mail || !origin) return; // no mail sender or no site address: nothing is sent
|
|
1158
1162
|
const token = await createPasswordResetToken(email);
|
|
1159
1163
|
if (!token) return; // silently no-op for unknown emails
|
|
1160
|
-
const
|
|
1161
|
-
if (!mail) return; // send_email not configured: graceful no-op
|
|
1162
|
-
const resetUrl = `${resetBaseUrl.replace(/\/$/, '')}/auth/reset-password?token=${token}`;
|
|
1164
|
+
const resetUrl = `${origin}/auth/reset-password?token=${token}`;
|
|
1163
1165
|
await mail.send({ kind: 'reset', to: email, subject: 'Reset your password',
|
|
1164
1166
|
text: `We received a request to reset your password. Choose a new one here; the link works for one hour:\n${resetUrl}\n\nIf you did not ask for it, ignore this email.` });
|
|
1165
1167
|
}), undefined);
|
|
@@ -1365,7 +1367,7 @@ export async function deleteOwnAccount(c: Context, userId: string, password: str
|
|
|
1365
1367
|
* Email a one-time sign-in link to an active account. Nothing says whether the email exists; a
|
|
1366
1368
|
* flood for one address or from one client stops after a few. Without a mail sender, nothing is sent.
|
|
1367
1369
|
*/
|
|
1368
|
-
export async function requestMagicLink(email: string
|
|
1370
|
+
export async function requestMagicLink(email: string): Promise<void> {
|
|
1369
1371
|
return accountByEmail(email, () => accounts(async () => {
|
|
1370
1372
|
const [mail, origin] = [mailer(), linkOrigin()];
|
|
1371
1373
|
if (!origin) return;
|
|
@@ -52,10 +52,8 @@ export default class ForgotPasswordPage extends Cossack {
|
|
|
52
52
|
const { email, turnstile } = await resetRequestInput.parse(submitted);
|
|
53
53
|
// Before anything else, so a failed check says nothing about the account.
|
|
54
54
|
if (!(await passesBotCheck(turnstile, 'reset'))) throw new ClientVisibleError(BOT_CHECK_FAILED);
|
|
55
|
-
// Build the reset base URL from the request origin.
|
|
56
|
-
const origin = new URL(this.c.req.url).origin;
|
|
57
55
|
try {
|
|
58
|
-
await requestPasswordReset(email
|
|
56
|
+
await requestPasswordReset(email);
|
|
59
57
|
} catch {
|
|
60
58
|
throw new ClientVisibleError('Could not send the reset link. Try again.');
|
|
61
59
|
}
|
|
@@ -127,7 +127,7 @@ export default class LoginPage extends Cossack {
|
|
|
127
127
|
async sendLink(email: string, turnstile = '') {
|
|
128
128
|
this.error = '';
|
|
129
129
|
if (!(await passesBotCheck(turnstile, 'login'))) { this.error = BOT_CHECK_FAILED; return; }
|
|
130
|
-
try { await requestMagicLink(String(email).trim().toLowerCase().slice(0, 254)
|
|
130
|
+
try { await requestMagicLink(String(email).trim().toLowerCase().slice(0, 254)); } catch { /* the page says the same either way */ }
|
|
131
131
|
this.linkSent = true;
|
|
132
132
|
}
|
|
133
133
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cossackframework/cms",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Cossack CMS: resources, schema planning, repositories, auth and stores on RomeDB",
|
|
6
6
|
"license": "MIT",
|
|
@@ -33,20 +33,20 @@
|
|
|
33
33
|
"markdown-it": "15.0.3",
|
|
34
34
|
"prosemirror-collab": "1.3.1",
|
|
35
35
|
"uqr": "0.1.3",
|
|
36
|
-
"@cossackframework/auth": "0.9.
|
|
37
|
-
"@cossackframework/
|
|
38
|
-
"@cossackframework/
|
|
39
|
-
"@cossackframework/
|
|
40
|
-
"@cossackframework/romedb": "0.9.
|
|
36
|
+
"@cossackframework/auth": "0.9.7",
|
|
37
|
+
"@cossackframework/renderer": "0.9.7",
|
|
38
|
+
"@cossackframework/core": "0.9.7",
|
|
39
|
+
"@cossackframework/database": "0.9.7",
|
|
40
|
+
"@cossackframework/romedb": "0.9.7"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"@aws-sdk/client-s3": "^3.1156.0",
|
|
44
44
|
"hono": "^4.13.18",
|
|
45
45
|
"sharp": "^0.35.5",
|
|
46
46
|
"vite": "*",
|
|
47
|
-
"@cossackframework/framework": "0.9.
|
|
48
|
-
"@cossackframework/
|
|
49
|
-
"@cossackframework/
|
|
47
|
+
"@cossackframework/framework": "0.9.7",
|
|
48
|
+
"@cossackframework/node-adapter": "0.9.7",
|
|
49
|
+
"@cossackframework/ui": "0.9.7"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@aws-sdk/client-s3": "^3.1156.0",
|
|
@@ -59,8 +59,8 @@
|
|
|
59
59
|
"simple-icons": "16.36.0",
|
|
60
60
|
"vite": "^8.1.6",
|
|
61
61
|
"vitest": "^4.1.12",
|
|
62
|
-
"@cossackframework/framework": "0.9.
|
|
63
|
-
"@cossackframework/node-adapter": "0.9.
|
|
62
|
+
"@cossackframework/framework": "0.9.7",
|
|
63
|
+
"@cossackframework/node-adapter": "0.9.7"
|
|
64
64
|
},
|
|
65
65
|
"exports": {
|
|
66
66
|
".": "./src/index.ts",
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** The version of this package. A test keeps it equal to `package.json`. */
|
|
2
|
-
export const CMS_VERSION = '0.9.
|
|
2
|
+
export const CMS_VERSION = '0.9.7';
|