feat(web): sign in by emailed code on the account page
Adds the email form (address, code, resend timer, aria-live status) shown only when /v1/info reports email_auth enabled, RU/EN strings, privacy policy update, API helpers, tests and browser QA with a mocked Hub.
This commit is contained in:
parent
309b77e63c
commit
a4cae66336
9 changed files with 528 additions and 28 deletions
|
|
@ -15,6 +15,7 @@ The optional browser script requires the loopback preview from `bun run dev` or
|
|||
- Keyboard-operated illustration tabs and theme selection.
|
||||
- Runtime RU/EN changes and layouts at 320, 390, 768 and 1440 pixels, including account views.
|
||||
- Enabled, disabled and unavailable GitHub sign-in; retry after session failure.
|
||||
- Email sign-in form (shown only when `/v1/info` reports `email_auth: enabled`): address validation, rate-limit and outage messages, code step with focus and `aria-invalid`, resend timer, language switch keeping state, wrong and right code. Hub is mocked; no mail is sent.
|
||||
- Profile values rendered as text, rejected unsafe avatar URLs and no script execution from hostile profile fixtures.
|
||||
- CSRF-header/Origin/POST sign-out and expired-session handling.
|
||||
- Browser storage contains only the UI language; no account tokens are persisted.
|
||||
|
|
|
|||
50
src/api.ts
50
src/api.ts
|
|
@ -8,12 +8,14 @@ export type Session =
|
|||
| { authenticated: false }
|
||||
| { authenticated: true; user: User; csrf_token: string };
|
||||
export interface HubInfo {
|
||||
capabilities: { github_auth: string };
|
||||
capabilities: { github_auth: string; email_auth?: string };
|
||||
}
|
||||
export interface RequestOptions {
|
||||
signal?: AbortSignal;
|
||||
method?: "GET" | "POST";
|
||||
csrf?: string;
|
||||
/** JSON request body; only sent when given. */
|
||||
body?: unknown;
|
||||
fetcher?: (input: string, options: RequestInit) => Promise<Response>;
|
||||
}
|
||||
export class ApiError extends Error {
|
||||
|
|
@ -26,7 +28,7 @@ export class ApiError extends Error {
|
|||
}
|
||||
export async function request(
|
||||
path: string,
|
||||
{ signal, method = "GET", csrf, fetcher = fetch }: RequestOptions = {},
|
||||
{ signal, method = "GET", csrf, body, fetcher = fetch }: RequestOptions = {},
|
||||
): Promise<unknown> {
|
||||
if (!path.startsWith("/v1/"))
|
||||
throw new TypeError("Only same-origin VNOX API paths are allowed");
|
||||
|
|
@ -38,7 +40,9 @@ export async function request(
|
|||
headers: {
|
||||
Accept: "application/json",
|
||||
...(csrf ? { "X-CSRF-Token": csrf } : {}),
|
||||
...(body === undefined ? {} : { "Content-Type": "application/json" }),
|
||||
},
|
||||
...(body === undefined ? {} : { body: JSON.stringify(body) }),
|
||||
});
|
||||
if (!response.ok) throw new ApiError(response.status, "request_failed");
|
||||
if (response.status === 204) return null;
|
||||
|
|
@ -70,9 +74,49 @@ export function isInfo(value: unknown): value is HubInfo {
|
|||
return (
|
||||
record(value) &&
|
||||
record(value.capabilities) &&
|
||||
typeof value.capabilities.github_auth === "string"
|
||||
typeof value.capabilities.github_auth === "string" &&
|
||||
(value.capabilities.email_auth === undefined ||
|
||||
typeof value.capabilities.email_auth === "string")
|
||||
);
|
||||
}
|
||||
/** Result of asking Hub to mail a sign-in code. */
|
||||
export interface CodeRequest {
|
||||
resendAfter: number;
|
||||
}
|
||||
/** Asks Hub to email a one-time code. Resolves with a bounded resend delay in seconds. */
|
||||
export async function requestEmailCode(
|
||||
email: string,
|
||||
lang: "ru" | "en",
|
||||
options: Pick<RequestOptions, "signal" | "fetcher"> = {},
|
||||
): Promise<CodeRequest> {
|
||||
const value = await request("/v1/auth/email/start", {
|
||||
...options,
|
||||
method: "POST",
|
||||
body: { email, lang },
|
||||
});
|
||||
const delay = record(value) ? value.resend_after : undefined;
|
||||
return {
|
||||
resendAfter:
|
||||
typeof delay === "number" && delay >= 1 && delay <= 3600
|
||||
? Math.ceil(delay)
|
||||
: 60,
|
||||
};
|
||||
}
|
||||
/** Redeems the code. Resolves only with an authenticated session. */
|
||||
export async function verifyEmailCode(
|
||||
email: string,
|
||||
code: string,
|
||||
options: Pick<RequestOptions, "signal" | "fetcher"> = {},
|
||||
): Promise<Session> {
|
||||
const value = await request("/v1/auth/email/verify", {
|
||||
...options,
|
||||
method: "POST",
|
||||
body: { email, code },
|
||||
});
|
||||
if (!isSession(value) || !value.authenticated)
|
||||
throw new Error("invalid_session");
|
||||
return value;
|
||||
}
|
||||
export function safeAvatar(value: unknown): string | null {
|
||||
if (typeof value !== "string") return null;
|
||||
try {
|
||||
|
|
|
|||
183
src/app.ts
183
src/app.ts
|
|
@ -1,7 +1,15 @@
|
|||
import type { Language, MessageKey } from "./i18n";
|
||||
import type { Session } from "./api";
|
||||
import { detectLanguage, translate } from "./i18n";
|
||||
import { request, isSession, isInfo, safeAvatar, ApiError } from "./api";
|
||||
import {
|
||||
request,
|
||||
isSession,
|
||||
isInfo,
|
||||
safeAvatar,
|
||||
ApiError,
|
||||
requestEmailCode,
|
||||
verifyEmailCode,
|
||||
} from "./api";
|
||||
|
||||
let savedLanguage: string | null | undefined;
|
||||
try {
|
||||
|
|
@ -31,6 +39,17 @@ let activeTheme: Theme = "dark";
|
|||
let controller: AbortController | undefined;
|
||||
let currentSession: Session | null = null;
|
||||
let githubEnabled = false;
|
||||
let emailEnabled = false;
|
||||
// Email sign-in form state. Kept outside the DOM so a language switch or a
|
||||
// re-render does not lose what was typed.
|
||||
let emailStep: "address" | "code" = "address";
|
||||
let emailAddress = "";
|
||||
let emailCode = "";
|
||||
let emailBusy: "idle" | "sending" | "verifying" = "idle";
|
||||
let emailMessage: MessageKey | null = null;
|
||||
let emailField: "address" | "code" | null = null;
|
||||
let resendUntil = 0;
|
||||
let resendTimer: ReturnType<typeof setInterval> | undefined;
|
||||
let sessionState: "loading" | "ready" | "error" = "loading";
|
||||
let infoState: "loading" | "ready" | "error" = "loading";
|
||||
let logoutState: "idle" | "pending" | "error" = "idle";
|
||||
|
|
@ -195,7 +214,7 @@ function renderAccount() {
|
|||
return;
|
||||
}
|
||||
if (currentSession?.authenticated) {
|
||||
panel.innerHTML = `<div class="profile-heading"><div class="profile-avatar" id="profile-avatar" aria-hidden="true">V</div><div>${tr("profileTitle", "h2")}<p id="profile-name"></p></div></div>${tr("profileIntro", "p")}<dl class="profile-fields"><div><dt>${tr("handle")}</dt><dd id="profile-handle"></dd></div><div><dt>${tr("userId")}</dt><dd id="profile-id"></dd></div><div><dt>${tr("provider")}</dt><dd>GitHub</dd></div></dl><div class="profile-actions"><button class="button secondary" id="copy-id">${icon("copy", 17)}${tr("copy")}</button><button class="button quiet" id="logout" ${logoutState === "pending" ? "disabled" : ""}>${tr(logoutState === "pending" ? "loggingOut" : "logout")}</button></div><p class="form-message" id="profile-message" role="status"></p>`;
|
||||
panel.innerHTML = `<div class="profile-heading"><div class="profile-avatar" id="profile-avatar" aria-hidden="true">V</div><div>${tr("profileTitle", "h2")}<p id="profile-name"></p></div></div>${tr("profileIntro", "p")}<dl class="profile-fields"><div><dt>${tr("handle")}</dt><dd id="profile-handle"></dd></div><div><dt>${tr("userId")}</dt><dd id="profile-id"></dd></div></dl><div class="profile-actions"><button class="button secondary" id="copy-id">${icon("copy", 17)}${tr("copy")}</button><button class="button quiet" id="logout" ${logoutState === "pending" ? "disabled" : ""}>${tr(logoutState === "pending" ? "loggingOut" : "logout")}</button></div><p class="form-message" id="profile-message" role="status"></p>`;
|
||||
const user = currentSession.user;
|
||||
find("#profile-name", panel).textContent =
|
||||
user.display_name || t("profileFallback");
|
||||
|
|
@ -223,7 +242,7 @@ function renderAccount() {
|
|||
find("#profile-message", panel).textContent = t("logoutError");
|
||||
return;
|
||||
}
|
||||
panel.innerHTML = `<div class="login-provider">${icon("github", 33)}</div>${tr("loginTitle", "h2")}${tr("loginText", "p")}<a class="button primary github-login ${githubEnabled ? "" : "unavailable"}" ${githubEnabled ? 'href="/v1/auth/github/start"' : 'aria-disabled="true" tabindex="-1"'}>${icon("github", 21)}${tr("loginButton")}</a><p id="login-availability" class="form-message" role="status"></p><button class="text-button" id="retry-info" ${infoState === "error" ? "" : "hidden"}>${tr("retry")}</button><div class="privacy-note">${icon("check", 16)}${tr("privacy", "p")}</div>`;
|
||||
panel.innerHTML = `<div class="login-provider">${icon("github", 33)}</div>${tr("loginTitle", "h2")}${tr("loginText", "p")}<a class="button primary github-login ${githubEnabled ? "" : "unavailable"}" ${githubEnabled ? 'href="/v1/auth/github/start"' : 'aria-disabled="true" tabindex="-1"'}>${icon("github", 21)}${tr("loginButton")}</a><p id="login-availability" class="form-message" role="status"></p><button class="text-button" id="retry-info" ${infoState === "error" ? "" : "hidden"}>${tr("retry")}</button><div id="email-area"></div><div class="privacy-note">${icon("check", 16)}${tr("privacy", "p")}</div>`;
|
||||
find("#login-availability", panel).textContent =
|
||||
infoState === "loading"
|
||||
? t("loginLoading")
|
||||
|
|
@ -233,6 +252,162 @@ function renderAccount() {
|
|||
? ""
|
||||
: t("loginDisabled");
|
||||
find("#retry-info", panel).addEventListener("click", refresh);
|
||||
renderEmail();
|
||||
}
|
||||
function stopResendTimer() {
|
||||
clearInterval(resendTimer);
|
||||
resendTimer = undefined;
|
||||
}
|
||||
function tickResend() {
|
||||
const button = document.querySelector<HTMLButtonElement>("#resend");
|
||||
if (!button) return stopResendTimer();
|
||||
const left = Math.max(0, Math.ceil((resendUntil - Date.now()) / 1000));
|
||||
button.disabled = left > 0 || emailBusy !== "idle";
|
||||
button.textContent =
|
||||
left > 0
|
||||
? t("emailResendIn").replace("{seconds}", String(left))
|
||||
: t("emailResend");
|
||||
if (left === 0) stopResendTimer();
|
||||
}
|
||||
const looksLikeEmail = (value: string) =>
|
||||
value.length <= 254 && /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value);
|
||||
function emailFailure(error: unknown, rejected: MessageKey): MessageKey {
|
||||
if (error instanceof ApiError) {
|
||||
if (error.status === 400) return rejected;
|
||||
if (error.status === 429) return "emailTooMany";
|
||||
}
|
||||
return "emailFailed";
|
||||
}
|
||||
/** Draws the email form into #email-area. Hidden unless Hub reports email_auth: enabled. */
|
||||
function renderEmail() {
|
||||
const area = document.querySelector("#email-area");
|
||||
if (!area) return;
|
||||
stopResendTimer();
|
||||
area.replaceChildren();
|
||||
if (!emailEnabled) return;
|
||||
const busy = emailBusy !== "idle";
|
||||
const invalid = emailMessage !== null && emailField !== null;
|
||||
const describedBy = 'aria-describedby="email-message"';
|
||||
const aria = (field: "address" | "code") =>
|
||||
invalid && emailField === field ? 'aria-invalid="true"' : "";
|
||||
const stepHtml =
|
||||
emailStep === "address"
|
||||
? `<label for="email-input">${tr("emailLabel")}</label><input id="email-input" class="field" type="email" name="email" autocomplete="email" inputmode="email" autocapitalize="none" spellcheck="false" maxlength="254" required ${describedBy} ${aria("address")}><button class="button secondary" type="submit" id="email-submit" ${busy ? "disabled" : ""}>${t(emailBusy === "sending" ? "emailSending" : "emailSend")}</button>`
|
||||
: `<p id="email-sent"></p><label for="code-input">${tr("codeLabel")}</label><input id="code-input" class="field code-field" type="text" name="code" inputmode="numeric" pattern="[0-9]*" autocomplete="one-time-code" autocapitalize="none" spellcheck="false" maxlength="8" required ${describedBy} ${aria("code")}><button class="button secondary" type="submit" id="email-submit" ${busy ? "disabled" : ""}>${t(emailBusy === "verifying" ? "codeVerifying" : "codeVerify")}</button><div class="email-actions"><button class="text-button" type="button" id="resend"></button><button class="text-button" type="button" id="change-email" ${busy ? "disabled" : ""}>${tr("emailChange")}</button></div>`;
|
||||
area.innerHTML = `<div class="login-divider" role="separator"><span>${tr("emailOr")}</span></div><form class="email-form" id="email-form" novalidate aria-busy="${busy}">${tr("emailTitle", "h3")}${emailStep === "address" ? tr("emailText", "p", 'class="email-text"') : ""}${stepHtml}<p class="form-message" id="email-message" role="status" aria-live="polite"></p></form>`;
|
||||
const form = find<HTMLFormElement>("#email-form", area);
|
||||
find("#email-message", area).textContent = emailMessage
|
||||
? t(emailMessage)
|
||||
: "";
|
||||
if (emailStep === "address") {
|
||||
const input = find<HTMLInputElement>("#email-input", area);
|
||||
input.value = emailAddress;
|
||||
input.addEventListener("input", () => (emailAddress = input.value));
|
||||
} else {
|
||||
find("#email-sent", area).textContent = t("emailCodeSent").replace(
|
||||
"{address}",
|
||||
emailAddress.trim().toLowerCase(),
|
||||
);
|
||||
const input = find<HTMLInputElement>("#code-input", area);
|
||||
input.value = emailCode;
|
||||
input.addEventListener("input", () => {
|
||||
input.value = input.value.replace(/\D/g, "").slice(0, 8);
|
||||
emailCode = input.value;
|
||||
});
|
||||
find("#resend", area).addEventListener("click", () => submitEmail(true));
|
||||
find("#change-email", area).addEventListener("click", () => {
|
||||
emailStep = "address";
|
||||
emailCode = "";
|
||||
emailMessage = null;
|
||||
emailField = null;
|
||||
resendUntil = 0;
|
||||
renderEmail();
|
||||
find<HTMLInputElement>("#email-input").focus();
|
||||
});
|
||||
tickResend();
|
||||
if (resendUntil > Date.now()) resendTimer = setInterval(tickResend, 1000);
|
||||
}
|
||||
form.addEventListener("submit", (event) => {
|
||||
event.preventDefault();
|
||||
if (emailBusy === "idle")
|
||||
void (emailStep === "address" ? submitEmail(false) : submitCode());
|
||||
});
|
||||
}
|
||||
function focusEmailField() {
|
||||
document
|
||||
.querySelector<HTMLInputElement>(
|
||||
emailStep === "address" ? "#email-input" : "#code-input",
|
||||
)
|
||||
?.focus();
|
||||
}
|
||||
async function submitEmail(resend: boolean) {
|
||||
if (emailBusy !== "idle") return;
|
||||
const address = emailAddress.trim();
|
||||
if (!looksLikeEmail(address)) {
|
||||
emailMessage = "emailInvalid";
|
||||
emailField = "address";
|
||||
renderEmail();
|
||||
focusEmailField();
|
||||
return;
|
||||
}
|
||||
emailAddress = address;
|
||||
emailBusy = "sending";
|
||||
emailMessage = null;
|
||||
emailField = null;
|
||||
renderEmail();
|
||||
try {
|
||||
const result = await requestEmailCode(address, language, {
|
||||
signal: AbortSignal.timeout(30000),
|
||||
});
|
||||
emailStep = "code";
|
||||
emailCode = "";
|
||||
resendUntil = Date.now() + result.resendAfter * 1000;
|
||||
emailMessage = resend ? "emailResent" : null;
|
||||
emailField = null;
|
||||
emailBusy = "idle";
|
||||
renderEmail();
|
||||
focusEmailField();
|
||||
} catch (error) {
|
||||
emailBusy = "idle";
|
||||
emailMessage = emailFailure(error, "emailInvalid");
|
||||
emailField = emailMessage === "emailInvalid" ? "address" : null;
|
||||
// A failed resend keeps the code step; the old code stays usable until it expires.
|
||||
renderEmail();
|
||||
if (emailStep === "address") focusEmailField();
|
||||
}
|
||||
}
|
||||
async function submitCode() {
|
||||
if (emailBusy !== "idle") return;
|
||||
if (!/^[0-9]{8}$/.test(emailCode)) {
|
||||
emailMessage = "emailCodeShape";
|
||||
emailField = "code";
|
||||
renderEmail();
|
||||
focusEmailField();
|
||||
return;
|
||||
}
|
||||
emailBusy = "verifying";
|
||||
emailMessage = null;
|
||||
emailField = null;
|
||||
renderEmail();
|
||||
try {
|
||||
currentSession = await verifyEmailCode(emailAddress, emailCode, {
|
||||
signal: AbortSignal.timeout(30000),
|
||||
});
|
||||
emailStep = "address";
|
||||
emailAddress = "";
|
||||
emailCode = "";
|
||||
emailBusy = "idle";
|
||||
emailMessage = null;
|
||||
logoutState = "idle";
|
||||
renderAccount();
|
||||
} catch (error) {
|
||||
emailBusy = "idle";
|
||||
emailCode = "";
|
||||
emailMessage = emailFailure(error, "emailInvalidCode");
|
||||
emailField = emailMessage === "emailInvalidCode" ? "code" : null;
|
||||
renderEmail();
|
||||
focusEmailField();
|
||||
}
|
||||
}
|
||||
async function logout() {
|
||||
if (!currentSession?.authenticated || logoutState === "pending") return;
|
||||
|
|
@ -290,11 +465,13 @@ async function refresh() {
|
|||
if (controller !== currentController) return;
|
||||
if (!isInfo(value)) throw new Error("invalid_info");
|
||||
githubEnabled = value.capabilities.github_auth === "enabled";
|
||||
emailEnabled = value.capabilities.email_auth === "enabled";
|
||||
infoState = "ready";
|
||||
})
|
||||
.catch(() => {
|
||||
if (!currentController.signal.aborted) {
|
||||
githubEnabled = false;
|
||||
emailEnabled = false;
|
||||
infoState = "error";
|
||||
}
|
||||
})
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ export const en = {
|
|||
"The gateway (TCP) handles chat, guilds and roles, and the voice node (UDP) relays audio. There is also a combined daemon that runs both.",
|
||||
projectCentral: "Vnox Central",
|
||||
projectCentralText:
|
||||
"A web account with GitHub sign-in. It is not linked to the desktop client key yet.",
|
||||
"A web account with GitHub or email sign-in. It is not linked to the desktop client key yet.",
|
||||
privacyLink: "Privacy",
|
||||
privacyTitle: "Privacy policy",
|
||||
privacyUpdated: "Updated 24 October 2026",
|
||||
|
|
@ -61,13 +61,13 @@ export const en = {
|
|||
"This policy covers the website and Vnox Central. Chats on community servers and the desktop client are not part of it, see below.",
|
||||
privacyCollectTitle: "What we receive",
|
||||
privacyCollectText:
|
||||
"When you sign in with GitHub we store the numeric ID, username, display name and avatar link from your public profile. We do not ask for repository access or your private email. The GitHub token is used once to read the profile and is discarded right away.",
|
||||
"When you sign in with GitHub we store the numeric ID, username, display name and avatar link from your public profile. We do not ask for repository access or your private email. The GitHub token is used once to read the profile and is discarded right away. When you sign in by email we store your address, converted to lowercase, as the sign-in identifier and use it only to send the code. The code itself is not stored as plain text but as an HMAC with a server secret, is valid for 10 minutes and is deleted once used. To fight abuse we keep, for about an hour, only HMAC fingerprints of the address and of the network the request came from, not the values themselves.",
|
||||
privacyCookiesTitle: "Cookies",
|
||||
privacyCookiesText:
|
||||
"Only the necessary ones: a short sign-in cookie (10 minutes) and a session cookie (7 days). Both are Secure and HttpOnly, and the database stores only a hash of the session. Signing out ends the session.",
|
||||
"Only the necessary ones: a short sign-in cookie for GitHub or email sign-in (10 minutes) and a session cookie (7 days). Both are Secure and HttpOnly, and the database stores only a hash of the session. Signing out ends the session.",
|
||||
privacyTrackTitle: "Tracking and third parties",
|
||||
privacyTrackText:
|
||||
"The website has no analytics, ads or third-party scripts. Your language choice is kept in your browser. The avatar loads from avatars.githubusercontent.com, so GitHub sees your IP address. Sign-in requests are not written to the web server logs.",
|
||||
"The website has no analytics, ads or third-party scripts. Your language choice is kept in your browser. The avatar loads from avatars.githubusercontent.com, so GitHub sees your IP address. Sign-in requests are not written to the web server logs. The code email goes out through an SMTP mail service, so that service sees your address and the text of the message.",
|
||||
privacyOtherTitle: "Community servers and the client",
|
||||
privacyOtherText:
|
||||
"VNOX servers are run by their owners. Messages and files on a server are held by its owner, who sets the retention rules. The desktop client keeps your key and settings on your device.",
|
||||
|
|
@ -108,7 +108,8 @@ export const en = {
|
|||
availableOne: "Client, text channels and voice",
|
||||
availableTwo: "Direct messages, friends, guilds and roles",
|
||||
availableThree: "Voice encryption (ChaCha20-Poly1305) and key-based sign-in",
|
||||
availableFour: "Web account through GitHub, site in Russian and English",
|
||||
availableFour:
|
||||
"Web account (GitHub or an emailed code), site in Russian and English",
|
||||
availableFive: "Incoming and signed outgoing webhooks on the server",
|
||||
nextOne: "Webhook management in the client",
|
||||
nextTwo: "Screen sharing with separate audio",
|
||||
|
|
@ -121,7 +122,7 @@ export const en = {
|
|||
"No. The gateway and the voice node can run as one daemon (serverd).",
|
||||
faqCentral: "What is Vnox Central for?",
|
||||
faqCentralAnswer:
|
||||
"It is a web account with GitHub sign-in. A community server runs on its own and does not depend on Central.",
|
||||
"It is a web account with GitHub or email sign-in. A community server runs on its own and does not depend on Central.",
|
||||
faqRelease: "Where can I download the client?",
|
||||
faqReleaseAnswer:
|
||||
"Nowhere yet. The client and server sources are open, and build instructions are in their repositories.",
|
||||
|
|
@ -133,7 +134,7 @@ export const en = {
|
|||
back: "Back to home",
|
||||
accountHeading: "Your Vnox Central account",
|
||||
accountIntro:
|
||||
"For now you can sign in with GitHub. There is nothing else to do with the account yet.",
|
||||
"You can sign in with GitHub or with a code sent by email. There is nothing else to do with the account yet.",
|
||||
loginTitle: "Continue with GitHub",
|
||||
loginText:
|
||||
"VNOX gets your public GitHub profile. It does not ask for access to your repositories.",
|
||||
|
|
@ -141,15 +142,15 @@ export const en = {
|
|||
loginLoading: "Checking sign-in availability…",
|
||||
loginDisabled: "GitHub sign-in is turned off on the server.",
|
||||
loginUnavailable: "Could not check sign-in availability. Try again.",
|
||||
privacy: "You sign in on github.com. Your GitHub password stays with GitHub.",
|
||||
privacy:
|
||||
"GitHub sign-in happens on github.com. Your GitHub password stays with GitHub.",
|
||||
accountStage:
|
||||
"The account is not linked to the desktop client keys yet. Friends, servers and messages will be added later.",
|
||||
sessionLoading: "Loading your account…",
|
||||
profileTitle: "You are signed in",
|
||||
profileIntro: "Signed in with GitHub. This is your VNOX Central account.",
|
||||
profileIntro: "You are signed in. This is your VNOX Central account.",
|
||||
handle: "Account handle",
|
||||
userId: "Account ID",
|
||||
provider: "Signed in with",
|
||||
logout: "Sign out",
|
||||
loggingOut: "Signing out…",
|
||||
logoutError: "Could not sign out. Try again.",
|
||||
|
|
@ -160,5 +161,27 @@ export const en = {
|
|||
copy: "Copy account ID",
|
||||
copied: "Account ID copied",
|
||||
copyError: "Could not copy the ID. Select it manually.",
|
||||
emailOr: "or",
|
||||
emailTitle: "Sign in with email",
|
||||
emailText:
|
||||
"We send an 8-digit code to your address. No password needed. If there is no account yet, it is created once you enter the code.",
|
||||
emailLabel: "Email address",
|
||||
emailSend: "Send code",
|
||||
emailSending: "Sending…",
|
||||
emailCodeSent:
|
||||
"We sent a code to {address}. It is valid for 10 minutes. If the message is missing, check your spam folder.",
|
||||
codeLabel: "Code from the email",
|
||||
codeVerify: "Sign in",
|
||||
codeVerifying: "Checking…",
|
||||
emailResend: "Send the code again",
|
||||
emailResendIn: "Send again in {seconds} s",
|
||||
emailResent: "A new code is on its way. The old one no longer works.",
|
||||
emailChange: "Use another address",
|
||||
emailInvalid: "Check the address. It should look like name@example.com.",
|
||||
emailCodeShape: "Enter the 8 digits from the email.",
|
||||
emailInvalidCode:
|
||||
"The code is wrong or expired. Check the digits or ask for a new one.",
|
||||
emailTooMany: "Too many requests. Wait a little and try again.",
|
||||
emailFailed: "That did not work. Try again in a moment.",
|
||||
} as const;
|
||||
export type Catalog = Record<keyof typeof en, string>;
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ export const ru: Catalog = {
|
|||
"Шлюз (TCP) отвечает за чат, гильдии и роли, голосовой узел (UDP) пересылает звук. Есть и общий демон для обоих.",
|
||||
projectCentral: "Vnox Central",
|
||||
projectCentralText:
|
||||
"Веб-аккаунт с входом через GitHub. С ключом настольного клиента он пока не связан.",
|
||||
"Веб-аккаунт с входом через GitHub или по почте. С ключом настольного клиента он пока не связан.",
|
||||
privacyLink: "Конфиденциальность",
|
||||
privacyTitle: "Политика конфиденциальности",
|
||||
privacyUpdated: "Обновлено 24 октября 2026",
|
||||
|
|
@ -63,13 +63,13 @@ export const ru: Catalog = {
|
|||
"Это политика сайта и Vnox Central. Чаты на серверах сообществ и настольный клиент сюда не входят, о них ниже.",
|
||||
privacyCollectTitle: "Что мы получаем",
|
||||
privacyCollectText:
|
||||
"При входе через GitHub мы сохраняем числовой ID, имя пользователя, отображаемое имя и ссылку на аватар из вашего публичного профиля. Доступ к репозиториям и приватной почте не запрашивается. Токен GitHub используется один раз, чтобы прочитать профиль, и сразу удаляется.",
|
||||
"При входе через GitHub мы сохраняем числовой ID, имя пользователя, отображаемое имя и ссылку на аватар из вашего публичного профиля. Доступ к репозиториям и приватной почте не запрашивается. Токен GitHub используется один раз, чтобы прочитать профиль, и сразу удаляется. При входе по почте мы сохраняем ваш адрес, приведённый к строчным буквам, как идентификатор входа и используем его только для отправки кода. Сам код хранится не открытым текстом, а в виде HMAC с секретом сервера, действует 10 минут и после использования удаляется. Для защиты от злоупотреблений около часа хранятся только HMAC-отпечатки адреса и сети, из которой пришёл запрос, без самих значений.",
|
||||
privacyCookiesTitle: "Cookie",
|
||||
privacyCookiesText:
|
||||
"Только необходимые: короткий cookie на время входа (10 минут) и cookie сессии (7 дней). Они защищены флагами Secure и HttpOnly, а в базе хранится только хеш сессии. Выход из аккаунта завершает сессию.",
|
||||
"Только необходимые: короткий cookie на время входа через GitHub или по почте (10 минут) и cookie сессии (7 дней). Они защищены флагами Secure и HttpOnly, а в базе хранится только хеш сессии. Выход из аккаунта завершает сессию.",
|
||||
privacyTrackTitle: "Слежка и сторонние сервисы",
|
||||
privacyTrackText:
|
||||
"На сайте нет аналитики, рекламы и сторонних скриптов. Выбранный язык хранится в вашем браузере. Аватар загружается с avatars.githubusercontent.com, поэтому GitHub видит ваш IP-адрес. Запросы входа не попадают в журналы веб-сервера.",
|
||||
"На сайте нет аналитики, рекламы и сторонних скриптов. Выбранный язык хранится в вашем браузере. Аватар загружается с avatars.githubusercontent.com, поэтому GitHub видит ваш IP-адрес. Запросы входа не попадают в журналы веб-сервера. Письмо с кодом уходит через почтовый SMTP-сервис, поэтому он видит ваш адрес и текст письма.",
|
||||
privacyOtherTitle: "Серверы сообществ и клиент",
|
||||
privacyOtherText:
|
||||
"Серверы VNOX ведут сами владельцы. Сообщения и файлы на сервере находятся у его владельца, и правила хранения задаёт он. Настольный клиент хранит ваш ключ и настройки на вашем устройстве.",
|
||||
|
|
@ -109,7 +109,8 @@ export const ru: Catalog = {
|
|||
availableOne: "Клиент, текстовые каналы и голос",
|
||||
availableTwo: "Личные сообщения, друзья, гильдии и роли",
|
||||
availableThree: "Шифрование голоса (ChaCha20-Poly1305) и вход по ключу",
|
||||
availableFour: "Веб-аккаунт через GitHub, сайт на русском и английском",
|
||||
availableFour:
|
||||
"Веб-аккаунт (GitHub или код на почту), сайт на русском и английском",
|
||||
availableFive: "Входящие и подписанные исходящие вебхуки на сервере",
|
||||
nextOne: "Управление вебхуками в клиенте",
|
||||
nextTwo: "Трансляция экрана с отдельным звуком",
|
||||
|
|
@ -122,7 +123,7 @@ export const ru: Catalog = {
|
|||
"Нет. Шлюз и голосовой узел можно запустить одним демоном (serverd).",
|
||||
faqCentral: "Зачем нужен Vnox Central?",
|
||||
faqCentralAnswer:
|
||||
"Это веб-аккаунт с входом через GitHub. Сервер сообщества работает отдельно и от Central не зависит.",
|
||||
"Это веб-аккаунт с входом через GitHub или по почте. Сервер сообщества работает отдельно и от Central не зависит.",
|
||||
faqRelease: "Где скачать клиент?",
|
||||
faqReleaseAnswer:
|
||||
"Пока нигде. Исходники клиента и сервера открыты, инструкции по сборке лежат в их репозиториях.",
|
||||
|
|
@ -134,7 +135,7 @@ export const ru: Catalog = {
|
|||
back: "На главную",
|
||||
accountHeading: "Аккаунт Vnox Central",
|
||||
accountIntro:
|
||||
"Пока можно войти через GitHub. Больше с аккаунтом ничего не сделать.",
|
||||
"Войти можно через GitHub или по коду из письма. Больше с аккаунтом пока ничего не сделать.",
|
||||
loginTitle: "Продолжить с GitHub",
|
||||
loginText:
|
||||
"VNOX получает ваш публичный профиль GitHub. Доступ к репозиториям не запрашивается.",
|
||||
|
|
@ -143,15 +144,15 @@ export const ru: Catalog = {
|
|||
loginDisabled: "Вход через GitHub на сервере пока выключен.",
|
||||
loginUnavailable:
|
||||
"Не удалось проверить доступность входа. Повторите попытку.",
|
||||
privacy: "Вход проходит на github.com. Пароль от GitHub остаётся у GitHub.",
|
||||
privacy:
|
||||
"Вход через GitHub проходит на github.com. Пароль от GitHub остаётся у GitHub.",
|
||||
accountStage:
|
||||
"Аккаунт пока не связан с ключами настольного клиента. Друзья, серверы и сообщения в нём появятся позже.",
|
||||
sessionLoading: "Загружаем аккаунт…",
|
||||
profileTitle: "Вы вошли",
|
||||
profileIntro: "Вход через GitHub выполнен. Это ваш аккаунт VNOX Central.",
|
||||
profileIntro: "Вход выполнен. Это ваш аккаунт VNOX Central.",
|
||||
handle: "Имя аккаунта",
|
||||
userId: "ID аккаунта",
|
||||
provider: "Способ входа",
|
||||
logout: "Выйти из аккаунта",
|
||||
loggingOut: "Выходим…",
|
||||
logoutError: "Не удалось выйти. Повторите попытку.",
|
||||
|
|
@ -162,4 +163,26 @@ export const ru: Catalog = {
|
|||
copy: "Скопировать ID",
|
||||
copied: "ID скопирован",
|
||||
copyError: "Не удалось скопировать ID. Выделите его вручную.",
|
||||
emailOr: "или",
|
||||
emailTitle: "Войти по почте",
|
||||
emailText:
|
||||
"Пришлём на адрес код из 8 цифр. Пароль не нужен. Если аккаунта нет, он создастся после ввода кода.",
|
||||
emailLabel: "Электронная почта",
|
||||
emailSend: "Получить код",
|
||||
emailSending: "Отправляем…",
|
||||
emailCodeSent:
|
||||
"Мы отправили код на адрес {address}. Он действует 10 минут. Если письма нет, загляните в папку «Спам».",
|
||||
codeLabel: "Код из письма",
|
||||
codeVerify: "Войти",
|
||||
codeVerifying: "Проверяем…",
|
||||
emailResend: "Отправить код ещё раз",
|
||||
emailResendIn: "Отправить ещё раз через {seconds} с",
|
||||
emailResent: "Новый код отправлен. Старый больше не подойдёт.",
|
||||
emailChange: "Другой адрес",
|
||||
emailInvalid: "Проверьте адрес. Он должен быть вида name@example.com.",
|
||||
emailCodeShape: "Введите 8 цифр из письма.",
|
||||
emailInvalidCode:
|
||||
"Код не подошёл или устарел. Проверьте цифры или запросите новый.",
|
||||
emailTooMany: "Слишком много запросов. Подождите немного и повторите.",
|
||||
emailFailed: "Не получилось. Повторите попытку чуть позже.",
|
||||
};
|
||||
|
|
|
|||
|
|
@ -970,6 +970,70 @@ p {
|
|||
margin-top: 14px !important;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
.login-divider {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 14px;
|
||||
margin: 28px 0 22px;
|
||||
color: var(--muted);
|
||||
font-size: 0.78rem;
|
||||
}
|
||||
.login-divider::before,
|
||||
.login-divider::after {
|
||||
content: "";
|
||||
flex: 1;
|
||||
border-top: 1px solid #ffffff12;
|
||||
}
|
||||
.email-form h3 {
|
||||
font-size: 1.15rem;
|
||||
letter-spacing: -0.02em;
|
||||
}
|
||||
.email-form p {
|
||||
font-size: 0.85rem;
|
||||
margin-top: 10px;
|
||||
}
|
||||
.email-form label {
|
||||
display: block;
|
||||
margin: 18px 0 8px;
|
||||
font-size: 0.78rem;
|
||||
color: #c5c0b8;
|
||||
}
|
||||
.field {
|
||||
width: 100%;
|
||||
min-height: 48px;
|
||||
padding: 11px 14px;
|
||||
background: #1b1b1d;
|
||||
color: var(--ink);
|
||||
border: 1px solid #4d4b47;
|
||||
border-radius: 7px;
|
||||
font-size: 1rem;
|
||||
font-family: inherit;
|
||||
}
|
||||
.field:focus-visible {
|
||||
outline: 2px solid var(--sand);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
.field[aria-invalid="true"] {
|
||||
border-color: #d2b7a5;
|
||||
}
|
||||
.code-field {
|
||||
font-variant-numeric: tabular-nums;
|
||||
letter-spacing: 0.2em;
|
||||
}
|
||||
.email-form .button {
|
||||
width: 100%;
|
||||
margin-top: 14px;
|
||||
}
|
||||
.email-actions {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px 22px;
|
||||
margin-top: 14px;
|
||||
}
|
||||
.email-actions .text-button:disabled {
|
||||
cursor: default;
|
||||
text-decoration: none;
|
||||
}
|
||||
.privacy-note {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,14 @@
|
|||
import { test } from "bun:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { request, isSession, isInfo, safeAvatar, ApiError } from "../src/api";
|
||||
import {
|
||||
request,
|
||||
isSession,
|
||||
isInfo,
|
||||
safeAvatar,
|
||||
ApiError,
|
||||
requestEmailCode,
|
||||
verifyEmailCode,
|
||||
} from "../src/api";
|
||||
import { messages, detectLanguage } from "../src/i18n";
|
||||
|
||||
test("catalogs match and never silently fall back to a missing translation", () => {
|
||||
|
|
@ -105,3 +113,63 @@ test("Hub capabilities reject malformed JSON before enabling sign-in", () => {
|
|||
assert.equal(isInfo(value), false);
|
||||
}
|
||||
});
|
||||
|
||||
test("email_auth capability must be a string when present", () => {
|
||||
assert.ok(
|
||||
isInfo({ capabilities: { github_auth: "enabled", email_auth: "enabled" } }),
|
||||
);
|
||||
assert.ok(isInfo({ capabilities: { github_auth: "enabled" } }));
|
||||
assert.equal(
|
||||
isInfo({ capabilities: { github_auth: "enabled", email_auth: true } }),
|
||||
false,
|
||||
);
|
||||
});
|
||||
test("email code requests send JSON same-origin and bound the resend delay", async () => {
|
||||
let seen: { path: string; init: RequestInit } | undefined;
|
||||
const result = await requestEmailCode("a@example.com", "en", {
|
||||
fetcher: async (path, init) => {
|
||||
seen = { path, init };
|
||||
return Response.json({ resend_after: 999999 }, { status: 202 });
|
||||
},
|
||||
});
|
||||
assert.equal(result.resendAfter, 60);
|
||||
assert.ok(seen);
|
||||
assert.equal(seen.path, "/v1/auth/email/start");
|
||||
assert.equal(seen.init.method, "POST");
|
||||
assert.equal(seen.init.credentials, "same-origin");
|
||||
assert.equal(
|
||||
new Headers(seen.init.headers).get("Content-Type"),
|
||||
"application/json",
|
||||
);
|
||||
assert.deepEqual(JSON.parse(String(seen.init.body)), {
|
||||
email: "a@example.com",
|
||||
lang: "en",
|
||||
});
|
||||
const short = await requestEmailCode("a@example.com", "ru", {
|
||||
fetcher: async () => Response.json({ resend_after: 30 }, { status: 202 }),
|
||||
});
|
||||
assert.equal(short.resendAfter, 30);
|
||||
});
|
||||
test("email verification accepts only an authenticated session and keeps the status", async () => {
|
||||
const session = {
|
||||
authenticated: true,
|
||||
csrf_token: "fixture",
|
||||
user: { user_id: "u", handle: "h", display_name: "n" },
|
||||
};
|
||||
const ok = await verifyEmailCode("a@example.com", "12345678", {
|
||||
fetcher: async () => Response.json(session),
|
||||
});
|
||||
assert.equal(ok.authenticated, true);
|
||||
await assert.rejects(
|
||||
verifyEmailCode("a@example.com", "12345678", {
|
||||
fetcher: async () => Response.json({ authenticated: false }),
|
||||
}),
|
||||
);
|
||||
await assert.rejects(
|
||||
verifyEmailCode("a@example.com", "12345678", {
|
||||
fetcher: async () =>
|
||||
Response.json({ error: "invalid_code" }, { status: 400 }),
|
||||
}),
|
||||
(error: unknown) => error instanceof ApiError && error.status === 400,
|
||||
);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -19,12 +19,24 @@ artifacts.mkdir(parents=True, exist_ok=True)
|
|||
with sync_playwright() as p:
|
||||
browser = p.chromium.launch(executable_path='/usr/bin/chromium', headless=True, args=['--no-sandbox'])
|
||||
context = browser.new_context(viewport={'width': 1440, 'height': 1000}, locale='ru-RU')
|
||||
mail = {'starts': [], 'verifies': [], 'start_status': 202, 'verify_status': 400, 'good_code': '12345678'}
|
||||
state = {'info': {'capabilities': {'github_auth': 'enabled'}}, 'session': {'authenticated': False}, 'info_status': 200, 'session_status': 200, 'logout_status': 204}
|
||||
logouts = []
|
||||
def api(route):
|
||||
path = urlparse(route.request.url).path
|
||||
if path == '/v1/info': route.fulfill(status=state['info_status'], json=state['info'])
|
||||
elif path == '/v1/auth/session': route.fulfill(status=state['session_status'], json=state['session'])
|
||||
elif path == '/v1/auth/email/start':
|
||||
body = json.loads(route.request.post_data or '{}')
|
||||
mail['starts'].append({'body': body, 'headers': route.request.all_headers()})
|
||||
route.fulfill(status=mail['start_status'], json={'status': 'code_requested', 'expires_in': 600, 'resend_after': 3} if mail['start_status'] == 202 else {'error': 'try_later'})
|
||||
elif path == '/v1/auth/email/verify':
|
||||
body = json.loads(route.request.post_data or '{}')
|
||||
mail['verifies'].append(body)
|
||||
if body.get('code') == mail['good_code']:
|
||||
state['session'] = {'authenticated': True, 'csrf_token': 'email-csrf', 'user': {'user_id': 'email-id', 'handle': 'u_emailfixture', 'display_name': 'Vnox user', 'avatar_url': None}}
|
||||
route.fulfill(status=200, json=state['session'])
|
||||
else: route.fulfill(status=mail['verify_status'], json={'error': 'invalid_code'})
|
||||
elif path == '/v1/auth/logout':
|
||||
logouts.append({'method': route.request.method, 'headers': route.request.all_headers()})
|
||||
route.fulfill(status=state['logout_status'], body='' if state['logout_status'] == 204 else '{}')
|
||||
|
|
@ -77,6 +89,81 @@ with sync_playwright() as p:
|
|||
page.reload()
|
||||
page.locator('#login-availability').filter(has_text='выключен').wait_for()
|
||||
assert page.locator('.github-login').get_attribute('href') is None
|
||||
# Email sign-in: hidden unless Hub reports email_auth enabled.
|
||||
assert page.locator('#email-form').count() == 0
|
||||
state['info'] = {'capabilities': {'github_auth': 'enabled', 'email_auth': 'not_enabled'}}
|
||||
page.reload()
|
||||
page.locator('.github-login').wait_for()
|
||||
page.wait_for_timeout(300)
|
||||
assert page.locator('#email-form').count() == 0
|
||||
state['info'] = {'capabilities': {'github_auth': 'enabled', 'email_auth': 'enabled'}}
|
||||
page.reload()
|
||||
page.locator('#email-input').wait_for()
|
||||
page.screenshot(path=str(artifacts / 'account-email-address.png'), full_page=True)
|
||||
# Invalid address is caught in the browser, with focus and aria state.
|
||||
page.locator('#email-input').fill('not-an-address')
|
||||
page.locator('#email-input').press('Enter')
|
||||
page.locator('#email-message').filter(has_text='Проверьте адрес').wait_for()
|
||||
assert page.locator('#email-input').get_attribute('aria-invalid') == 'true'
|
||||
assert page.evaluate("document.activeElement.id") == 'email-input'
|
||||
assert page.locator('#email-message').get_attribute('role') == 'status'
|
||||
assert not mail['starts']
|
||||
# Server-side rate limit and outage are reported without leaving the step.
|
||||
mail['start_status'] = 429
|
||||
page.locator('#email-input').fill(' Person@Example.com ')
|
||||
page.locator('#email-submit').click()
|
||||
page.locator('#email-message').filter(has_text='Слишком много').wait_for()
|
||||
mail['start_status'] = 503
|
||||
page.locator('#email-submit').click()
|
||||
page.locator('#email-message').filter(has_text='Не получилось').wait_for()
|
||||
mail['start_status'] = 202
|
||||
page.locator('#email-input').press('Enter')
|
||||
page.locator('#code-input').wait_for()
|
||||
assert page.evaluate("document.activeElement.id") == 'code-input'
|
||||
sent = mail['starts'][-1]
|
||||
assert sent['body'] == {'email': 'Person@Example.com', 'lang': 'ru'}, sent['body']
|
||||
assert sent['headers']['origin'] == args.url
|
||||
assert sent['headers']['content-type'] == 'application/json'
|
||||
assert page.locator('#email-sent').inner_text().count('person@example.com') == 1
|
||||
page.screenshot(path=str(artifacts / 'account-email-code.png'), full_page=True)
|
||||
# Resend is locked by the timer (3 s fixture), then works.
|
||||
assert page.locator('#resend').is_disabled()
|
||||
assert 'через' in page.locator('#resend').inner_text()
|
||||
page.locator('#resend:not([disabled])').wait_for(timeout=6000)
|
||||
page.locator('#resend').click()
|
||||
page.locator('#email-message').filter(has_text='Новый код отправлен').wait_for()
|
||||
assert len(mail['starts']) == 4
|
||||
# Language switch keeps the step and the typed address, and relabels the form.
|
||||
page.locator('#code-input').fill('12ab34')
|
||||
assert page.locator('#code-input').input_value() == '1234'
|
||||
page.locator('[data-language="en"]').click()
|
||||
assert page.locator('label[for="code-input"]').inner_text() == 'Code from the email'
|
||||
assert page.locator('#code-input').input_value() == '1234'
|
||||
page.locator('[data-language="ru"]').click()
|
||||
# Short code, wrong code, then the right one.
|
||||
page.locator('#email-submit').click()
|
||||
page.locator('#email-message').filter(has_text='8 цифр').wait_for()
|
||||
page.locator('#code-input').fill('00000000')
|
||||
page.locator('#email-submit').click()
|
||||
page.locator('#email-message').filter(has_text='не подошёл').wait_for()
|
||||
assert page.locator('#code-input').get_attribute('aria-invalid') == 'true'
|
||||
assert page.locator('#code-input').input_value() == ''
|
||||
page.locator('#change-email').click()
|
||||
assert page.locator('#email-input').input_value() == 'Person@Example.com'
|
||||
page.locator('#email-submit').click()
|
||||
page.locator('#code-input').wait_for()
|
||||
for width in [320, 390, 768, 1440]:
|
||||
page.set_viewport_size({'width': width, 'height': 844})
|
||||
assert not page.evaluate('document.documentElement.scrollWidth > innerWidth'), ('email', width)
|
||||
page.set_viewport_size({'width': 1440, 'height': 1000})
|
||||
page.locator('#code-input').fill('12345678')
|
||||
page.locator('#code-input').press('Enter')
|
||||
page.locator('#profile-id').wait_for()
|
||||
assert mail['verifies'][-1] == {'email': 'Person@Example.com', 'code': '12345678'}
|
||||
assert page.locator('#email-form').count() == 0
|
||||
assert page.evaluate('Object.keys(localStorage)') == ['vnox-web-language']
|
||||
state['session'] = {'authenticated': False}
|
||||
state['info'] = {'capabilities': {'github_auth': 'enabled'}}
|
||||
state['info_status'] = 503
|
||||
page.reload()
|
||||
page.locator('#retry-info:not([hidden])').wait_for()
|
||||
|
|
@ -116,4 +203,4 @@ with sync_playwright() as p:
|
|||
page.locator('.github-login').wait_for()
|
||||
assert not errors, errors
|
||||
browser.close()
|
||||
print(json.dumps({'result':'passed','assertions':'tabs, theme, RU/EN, 320/390/768/1440 layout, login enabled/disabled/errors, session/profile XSS safety, CSRF logout/expired session, no persisted secrets','artifacts':str(artifacts)}))
|
||||
print(json.dumps({'result':'passed','assertions':'tabs, theme, RU/EN, 320/390/768/1440 layout, login enabled/disabled/errors, email code flow with fixtures, session/profile XSS safety, CSRF logout/expired session, no persisted secrets','artifacts':str(artifacts)}))
|
||||
|
|
|
|||
|
|
@ -108,3 +108,16 @@ test("app templates avoid inline style attributes blocked by the site CSP", asyn
|
|||
const source = await Bun.file("src/app.ts").text();
|
||||
assert.doesNotMatch(source, /style="/);
|
||||
});
|
||||
|
||||
test("privacy text describes email sign-in in both languages", () => {
|
||||
for (const [name, catalog] of Object.entries(messages)) {
|
||||
const text = [
|
||||
catalog.privacyCollectText,
|
||||
catalog.privacyTrackText,
|
||||
catalog.privacyCookiesText,
|
||||
].join(" ");
|
||||
assert.match(text, /HMAC/, name);
|
||||
assert.match(text, /10/, name);
|
||||
assert.match(text, /SMTP/, name);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue