Release v2.20.1: migrate authentication to Better Auth

This commit is contained in:
lzstealth committed 2026-10-25 18:19:55 +00:00
1 parent e9a53f577c
commit fba4f99ff7
92 files changed
+5085 -1943

No files matched your search

+15 -7
View File
@@ -1,7 +1,7 @@
const test = require('node:test');
const assert = require('node:assert/strict');
const { DEFAULT_ACCOUNT_EMAIL_TEMPLATES, formatAccountEmailExpiry, renderAccountEmailTemplate } = require('../src/data/account-email-templates');
const { DEFAULT_ACCOUNT_EMAIL_TEMPLATES, formatAccountEmailExpiry, normalizeOtpEmailBody, renderAccountEmailTemplate } = require('../src/data/account-email-templates');
test('account email expiry values render with singular and plural units', () => {
assert.equal(formatAccountEmailExpiry(1, 'minutes'), '1 minute');
@@ -10,16 +10,24 @@ test('account email expiry values render with singular and plural units', () =>
assert.equal(renderAccountEmailTemplate('Subject [[expiry_time]]', 'Expires in [[expiry_time]].', { expiry_time: '45 minutes' }).text, 'Expires in 45 minutes.');
});
test('default account email templates render both the action button and inline link', () => {
test('default account email templates render one-time verification codes', () => {
const rendered = renderAccountEmailTemplate('Subject', DEFAULT_ACCOUNT_EMAIL_TEMPLATES.verificationBody, {
url: 'https://example.test/verify',
display_name: 'Alex',
otp: '123456',
expiry_time: '30 minutes',
action_label: 'Verify email address'
});
assert.match(rendered.html, /<strong>Alex<\/strong>/);
assert.match(rendered.html, /This <u>link<\/u> expires in <em>30 minutes<\/em>\./);
assert.match(rendered.html, /Confirm this email address: <a href="https:\/\/example\.test\/verify">https:\/\/example\.test\/verify<\/a>/);
assert.doesNotMatch(rendered.html, /\[\[(?:action_button|url)\]\]/);
assert.match(rendered.html, /verification code[\s\S]*<strong>123456<\/strong>/);
assert.match(rendered.html, /This code expires in <em>30 minutes<\/em>\./);
assert.doesNotMatch(rendered.html, /\[\[(?:action_button|url|otp)\]\]/);
});
test('legacy link email templates normalize to OTP wording and placeholders', () => {
const normalized = normalizeOtpEmailBody('Click [[action_button]]. This link expires in [[expiry_time]]. Verify: [[url]]');
const rendered = renderAccountEmailTemplate('Subject', normalized, { otp: '321654', expiry_time: '5 minutes' });
assert.match(rendered.text, /verification code/);
assert.match(rendered.text, /321654/);
assert.doesNotMatch(rendered.text, /\[\[(?:action_button|url|otp)\]\]/);
});