Accounts 1.1.0: moving Events' users in, people.* requests, new recovery codes

POST /api/accounts/v1/requests (crosscode.identity-request/1): import.* keeps
each person's Events id as sub, password hash and authenticator secret
(sealed in transit), consent, notices and lockout; linked when the email
already has an account. people.* for product admins, limited to people the
product knows. New recovery codes after the first 2FA sign-in for people
moved in with 2FA. screen=signup. auth-client: request(), seal(), signUp.
8 new tests (47 in all).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-19 13:40:15 +02:00
co-authored by Claude Opus 5.5
parent 08fef930c1
commit 733992e917
19 changed files with 834 additions and 39 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@crosscode/accounts-frontend",
"version": "1.0.1",
"version": "1.1.0",
"private": true,
"description": "Cross Code Accounts: the church's sign-in pages, the account page and admin",
"scripts": {
@@ -17,11 +17,12 @@ export function Reset({ token }: { token: string | null }) {
<form onSubmit={async (e) => {
e.preventDefault();
setBusy(true);
const r = await call<{ uid: string | null }>("POST", "/password/reset", { token, password: new FormData(e.currentTarget).get("password") });
const r = await call<{ uid: string | null; returnUrl: string | null }>("POST", "/password/reset", { token, password: new FormData(e.currentTarget).get("password") });
setBusy(false);
if (!r.ok) return setError(r.error.message);
// Back to the sign-in it started from (and on to that site), or to the account page.
window.location.assign(r.data.uid ? `/signin?uid=${encodeURIComponent(r.data.uid)}` : selfSignIn("/account"));
// Back to the sign-in it started from (and on to that site), to the product that made the
// account (its sign-in brings them straight back here signed in), or to the account page.
window.location.assign(r.data.uid ? `/signin?uid=${encodeURIComponent(r.data.uid)}` : r.data.returnUrl ?? selfSignIn("/account"));
}}>
<Field label="New password" name="password" type="password" autoComplete="new-password" required minLength={8} autoFocus />
<Button type="submit" busy={busy} className="w-full">Save and sign in</Button>
@@ -13,6 +13,7 @@ type State = {
product: string;
signupEnabled: boolean;
loginHint?: string | null;
screen?: "signin" | "signup";
name?: string;
email?: string;
sentTo?: string;
@@ -35,16 +36,29 @@ export function SignIn({ uid }: { uid: string }) {
const [error, setError] = useState<ApiError | null>(null);
const [busy, setBusy] = useState(false);
const [mode, setMode] = useState<"signin" | "signup">("signin");
const [codes, setCodes] = useState<{ codes: string[]; next: string } | null>(null);
const [codes, setCodes] = useState<{ codes: string[]; next: State } | null>(null);
const [opened, setOpened] = useState(false);
const apply = (s: State) => {
// New recovery codes (2FA just set up, or moved in from Cross Events without them) are shown
// first, whatever comes next.
const go = (s: State) => {
if (s.stage === "done" && s.redirectTo) {
if (s.recoveryCodes?.length) setCodes({ codes: s.recoveryCodes, next: s.redirectTo });
else window.location.assign(s.redirectTo);
window.location.assign(s.redirectTo);
return;
}
setState(s);
};
const apply = (s: State) => {
if (!opened) {
setOpened(true);
if (s.screen === "signup" && s.signupEnabled) setMode("signup");
}
if (s.recoveryCodes?.length) {
setCodes({ codes: s.recoveryCodes, next: s });
return;
}
go(s);
};
useExternalEffect(() => {
let alive = true;
@@ -69,7 +83,7 @@ export function SignIn({ uid }: { uid: string }) {
const frame = (children: React.ReactNode) => <Shell branding={branding}><Card>{children}</Card></Shell>;
if (codes) {
return frame(<RecoveryCodes codes={codes.codes} onDone={() => window.location.assign(codes.next)} />);
return frame(<RecoveryCodes codes={codes.codes} onDone={() => { const next = codes.next; setCodes(null); go(next); }} />);
}
if (!state) {
return frame(error ? (