Setup step 3 asks where you live and shows that country's bank feed (#6)

Saved as BROKE_COUNTRY. US and Canada get Plaid, NZ Akahu, UK and Europe
Enable Banking, Australia Basiq, Brazil Belvo. Countries with no feed are
told to import a statement after sign-in. Onboarding uses the saved
country instead of asking again.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
minimus7andClaude Opus 5.5 authored and GitHub committed 2026-11-16 11:15:28 -06:00
1 parent 1e246336a2
commit b532bb8dd8
8 files changed
+136 -60

No files matched your search

+1 -1
View File
@@ -78,7 +78,7 @@ export function Settings({ signedIn, local, folder, repo, update, email, profile
}, [group, local, load]); }, [group, local, load]);
const nav = local ? NAV : NAV.filter((n) => !SERVER.includes(n.id) || n.id === "banks" || n.id === "database"); const nav = local ? NAV : NAV.filter((n) => !SERVER.includes(n.id) || n.id === "banks" || n.id === "database");
const sections = (data?.sections ?? []).filter((s) => groupOf(s) === group); const sections = (data?.sections ?? []).filter((s) => s.id !== "country" && groupOf(s) === group); // "country": setup's step 3 with no feed; the country itself is under Profile
const flagged = (g: Group) => (data?.sections ?? []).some((s) => groupOf(s) === g && attention(s)); const flagged = (g: Group) => (data?.sections ?? []).some((s) => groupOf(s) === g && attention(s));
const here = NAV.find((n) => n.id === group)!; const here = NAV.find((n) => n.id === group)!;
const pick = (g: Group) => { const pick = (g: Group) => {
+5 -3
View File
@@ -1,6 +1,6 @@
import { NextResponse } from "next/server"; import { NextResponse } from "next/server";
import { countryOf, wantsAkahu } from "@/lib/countries"; import { countryOf, wantsAkahu } from "@/lib/countries";
import { fromLocalhost, setupAccess, setupStatus } from "@/lib/setup"; import { currentEnv, fromLocalhost, setupAccess, setupStatus } from "@/lib/setup";
import { createClient } from "@/utils/supabase/server"; import { createClient } from "@/utils/supabase/server";
// Server setup details are for the owner on this machine only: setup writes already need localhost (writeGate). // Server setup details are for the owner on this machine only: setup writes already need localhost (writeGate).
@@ -12,12 +12,14 @@ export async function GET() {
// The NZ bank keys only matter to someone with NZ banks. Keys already saved stay visible, so they can be changed or removed. // The NZ bank keys only matter to someone with NZ banks. Keys already saved stay visible, so they can be changed or removed.
// Before Supabase is set up there's nobody signed in, and no client to ask. // Before Supabase is set up there's nobody signed in, and no client to ask.
const user = access.signedIn ? (await (await createClient()).auth.getUser()).data.user : null; const user = access.signedIn ? (await (await createClient()).auth.getUser()).data.user : null;
const profile = user?.user_metadata?.profile; // Before anyone signs in, where they live is what setup step 3 asked (BROKE_COUNTRY).
const profile = user?.user_metadata?.profile ?? { country: currentEnv().BROKE_COUNTRY };
const here = countryOf(profile?.country).providers as string[]; const here = countryOf(profile?.country).providers as string[];
const nz = wantsAkahu(profile); const nz = wantsAkahu(profile);
// Bank connections for other countries stay out of the way, unless keys are already saved. // Bank connections for other countries stay out of the way, unless keys are already saved.
return NextResponse.json({ ...status, sections: status.sections.filter((s) => { return NextResponse.json({ ...status, sections: status.sections.filter((s) => {
if (s.kind === "required") return true;
if (s.id === "akahu") return nz || s.status === "done"; if (s.id === "akahu") return nz || s.status === "done";
return !["enablebanking", "basiq", "belvo"].includes(s.id) || here.includes(s.id) || s.status === "done"; return !["plaid", "enablebanking", "basiq", "belvo"].includes(s.id) || here.includes(s.id) || s.status === "done";
}) }); }) });
} }
+49
View File
@@ -2,6 +2,8 @@
import { Check, Copy, Eye, EyeOff } from "lucide-react"; import { Check, Copy, Eye, EyeOff } from "lucide-react";
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
import { Dropdown } from "@/components/Dropdown";
import { COUNTRIES, countryOf, guessCountry, OTHER } from "@/lib/countries";
import type { Field } from "@/lib/setup"; import type { Field } from "@/lib/setup";
export function CopyCommand({ command }: { command: string }) { export function CopyCommand({ command }: { command: string }) {
@@ -208,3 +210,50 @@ export function ConnectSupabaseButton({ onDone, onFail }: { onDone: () => void;
); );
} }
const COUNTRY_OPTIONS = [...COUNTRIES, OTHER].map((c) => ({ value: c.code, label: c.name }));
// Step 3 asks where they live first, so it can show that country's bank feed. Saved as BROKE_COUNTRY; onboarding uses it
// instead of asking again. Nothing saved yet: the guess from this computer, with a Continue button.
export function CountryPick({ saved, canWrite, writeNote, onSaved }: { saved: string; canWrite: boolean; writeNote?: string; onSaved: () => void }) {
const [guess, setGuess] = useState("");
const [value, setValue] = useState(saved);
const [busy, setBusy] = useState(false);
const [err, setErr] = useState("");
useEffect(() => {
if (saved) return; // the checklist remounts this (key) when the saved country changes
const g = guessCountry(navigator.languages ?? [navigator.language], Intl.DateTimeFormat().resolvedOptions().timeZone);
setGuess(g);
setValue((v) => v || g);
}, [saved]);
async function save(code: string) {
setBusy(true);
setErr("");
try {
const res = await fetch("/api/setup/env", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ values: { BROKE_COUNTRY: code } }) });
const body = (await res.json().catch(() => ({}))) as { error?: string; errors?: Record<string, string> };
if (res.ok) onSaved();
else setErr(body.errors?.BROKE_COUNTRY ?? body.error ?? "Couldn't save.");
} catch {
setErr("Couldn't reach broke. Is it still running?");
}
setBusy(false);
}
if (!canWrite) return <p className="text-sm text-muted">Where you live: {saved ? countryOf(saved).name : "not set"}. {writeNote} Set BROKE_COUNTRY there.</p>;
return (
<div className="space-y-2">
<span className="block text-sm font-medium">Where do you live?</span>
<div className="flex flex-wrap items-center gap-3">
<div className="w-64 max-w-full">
<Dropdown label="Country" value={value} options={COUNTRY_OPTIONS} onChange={(c) => { setValue(c); if (saved) save(c); }} placeholder="Choose a country" searchable />
</div>
{!saved && <button className="btn-primary" disabled={busy || !value} onClick={() => save(value)}>{busy ? "Saving..." : "Continue"}</button>}
{saved && busy && <span className="text-sm text-muted">Saving...</span>}
</div>
{!saved && value && value === guess && <p className="text-xs text-muted">Guessed from this computer&apos;s time zone and language. Change it if that&apos;s wrong.</p>}
{err && <p className="text-sm text-bad">{err}</p>}
</div>
);
}
+4 -4
View File
@@ -5,7 +5,7 @@ import Link from "next/link";
import { useCallback, useEffect, useState } from "react"; import { useCallback, useEffect, useState } from "react";
import { Logo } from "@/components/Logo"; import { Logo } from "@/components/Logo";
import type { AiRow, Part, Section, SetupStatus } from "@/lib/setup"; import type { AiRow, Part, Section, SetupStatus } from "@/lib/setup";
import { CopyCommand, KeyForm, ConnectSupabaseButton, MigrateButton } from "./SetupActions"; import { CopyCommand, CountryPick, KeyForm, ConnectSupabaseButton, MigrateButton } from "./SetupActions";
export function ExtLink({ href, children }: { href: string; children: React.ReactNode }) { export function ExtLink({ href, children }: { href: string; children: React.ReactNode }) {
return ( return (
@@ -83,9 +83,8 @@ export function SetupChecklist({ signedIn }: { signedIn: boolean }) {
const main = sections.filter((s) => s.kind !== "more"); const main = sections.filter((s) => s.kind !== "more");
const more = sections.filter((s) => s.kind === "more"); const more = sections.filter((s) => s.kind === "more");
const required = main.filter((s) => s.kind === "required"); const required = main.filter((s) => s.kind === "required");
const done = required.filter((s) => s.status === "done").length;
const next = required.find((s) => s.status !== "done"); const next = required.find((s) => s.status !== "done");
const canSkipBank = next?.id === "plaid"; // the database works, so broke can open: statements can be imported without a bank feed const canSkipBank = next?.country !== undefined; // the database works, so broke can open: statements can be imported without a bank feed
return ( return (
<main className="min-h-screen bg-canvas px-4 py-8 md:py-12"> <main className="min-h-screen bg-canvas px-4 py-8 md:py-12">
@@ -97,7 +96,7 @@ export function SetupChecklist({ signedIn }: { signedIn: boolean }) {
<section className="card p-7 space-y-5"> <section className="card p-7 space-y-5">
<div className="space-y-1"> <div className="space-y-1">
<h1 className="text-2xl font-semibold">{!data ? "Set up broke" : !next ? "You're all set" : `Step ${done + 1} of ${required.length}: ${next.title}`}</h1> <h1 className="text-2xl font-semibold">{!data ? "Set up broke" : !next ? "You're all set" : `Step ${required.indexOf(next) + 1} of ${required.length}: ${next.title}`}</h1>
<p className="text-sm text-muted"> <p className="text-sm text-muted">
{!data ? "Checking what's connected… " : !next ? "Open broke and sign in with your email. " : "It's free. Follow the steps below and paste each key in. "} {!data ? "Checking what's connected… " : !next ? "Open broke and sign in with your email. " : "It's free. Follow the steps below and paste each key in. "}
Your keys stay on this computer. Your keys stay on this computer.
@@ -186,6 +185,7 @@ function SectionCard({ s, n, open, onToggle, data, signedIn, reload }: { s: Sect
</button> </button>
<Collapse open={open}> <Collapse open={open}>
<div className="px-6 pb-6 pt-1 @md:pl-[4.25rem] space-y-4"> <div className="px-6 pb-6 pt-1 @md:pl-[4.25rem] space-y-4">
{s.country !== undefined && <CountryPick key={s.country} saved={s.country} canWrite={data.canWrite} writeNote={data.writeNote} onSaved={reload} />}
<Body s={s} data={data} signedIn={signedIn} reload={reload} /> <Body s={s} data={data} signedIn={signedIn} reload={reload} />
</div> </div>
</Collapse> </Collapse>
+5 -2
View File
@@ -1,10 +1,11 @@
import { redirect } from "next/navigation"; import { redirect } from "next/navigation";
import { MoneyProvider } from "@/components/Money"; import { MoneyProvider } from "@/components/Money";
import { Onboarding, type Step } from "@/components/Onboarding"; import { Onboarding, type Step } from "@/components/Onboarding";
import { countryOf } from "@/lib/countries"; import { COUNTRIES, countryOf } from "@/lib/countries";
import { getUser, userTz } from "@/lib/data"; import { getUser, userTz } from "@/lib/data";
import { fmtFor } from "@/lib/format"; import { fmtFor } from "@/lib/format";
import { addChoices } from "@/lib/providers"; import { addChoices } from "@/lib/providers";
import { currentEnv } from "@/lib/setup";
// First run: the app layout sends new users here until onboarding is done (profile.onboarding, Onboarding.tsx). // First run: the app layout sends new users here until onboarding is done (profile.onboarding, Onboarding.tsx).
// No country yet starts at the country picker; otherwise it resumes at the saved step. // No country yet starts at the country picker; otherwise it resumes at the saved step.
@@ -14,10 +15,12 @@ export default async function WelcomePage() {
const profile = user.user_metadata?.profile ?? {}; const profile = user.user_metadata?.profile ?? {};
if (profile.country && (!profile.onboarding || profile.onboarding === "done")) redirect("/"); if (profile.country && (!profile.onboarding || profile.onboarding === "done")) redirect("/");
const step = (profile.country ? profile.onboarding : "country") as Step; const step = (profile.country ? profile.onboarding : "country") as Step;
// Setup step 3 already asked where they live. Onboarding uses that instead of asking again. "Somewhere else" still asks, for the currency.
const setupCountry = COUNTRIES.some((c) => c.code === currentEnv().BROKE_COUNTRY) ? currentEnv().BROKE_COUNTRY : undefined;
return ( return (
<MoneyProvider fmt={{ ...fmtFor(profile), tz }}> <MoneyProvider fmt={{ ...fmtFor(profile), tz }}>
<main className="min-h-screen bg-canvas px-4 py-10 md:py-16 flex justify-center"> <main className="min-h-screen bg-canvas px-4 py-10 md:py-16 flex justify-center">
<Onboarding profile={profile} start={step} choices={addChoices(countryOf(profile.country).code)} /> <Onboarding profile={profile} start={step} setupCountry={setupCountry} choices={addChoices(countryOf(profile.country ?? setupCountry).code)} />
</main> </main>
</MoneyProvider> </MoneyProvider>
); );
+8 -3
View File
@@ -177,15 +177,20 @@ function ResultStep({ finish, back }: { finish: (href: string) => void; back: ()
); );
} }
export function Onboarding({ profile: initial, start, choices }: { profile: Profile; start: Step; choices: AddChoices }) { export function Onboarding({ profile: initial, start, setupCountry, choices }: { profile: Profile; start: Step; setupCountry?: string; choices: AddChoices }) {
const router = useRouter(); const router = useRouter();
const [profile, setProfile] = useState<Profile>(initial); // Setup step 3 already asked where they live: save that and start at the bank step.
const [step, setStep] = useState<Step>(STEPS.includes(start) ? start : "result"); const preset = start === "country" && setupCountry ? { ...initial, country: setupCountry, currency: countryOf(setupCountry).currency, onboarding: "bank" } : null;
const [profile, setProfile] = useState<Profile>(preset ?? initial);
const [step, setStep] = useState<Step>(preset ? "bank" : STEPS.includes(start) ? start : "result");
const [info, setInfo] = useState<Info | null>(null); const [info, setInfo] = useState<Info | null>(null);
// Writes run one after another so a later step never lands before an earlier one. // Writes run one after another so a later step never lands before an earlier one.
const queue = useRef<Promise<unknown>>(Promise.resolve()); const queue = useRef<Promise<unknown>>(Promise.resolve());
const write = (p: Profile) => (queue.current = queue.current.then(() => updateMeta(createClient(), { data: { profile: p } }))); const write = (p: Profile) => (queue.current = queue.current.then(() => updateMeta(createClient(), { data: { profile: p } })));
useEffect(() => {
if (preset) write(preset).then(() => router.refresh());
}, []); // eslint-disable-line react-hooks/exhaustive-deps
useEffect(() => { useEffect(() => {
if (step !== "country" && step !== "result") load().then(setInfo); if (step !== "country" && step !== "result") load().then(setInfo);
}, [step === "country"]); // eslint-disable-line react-hooks/exhaustive-deps }, [step === "country"]); // eslint-disable-line react-hooks/exhaustive-deps
+1
View File
@@ -33,6 +33,7 @@ export const ENV_KEYS: Record<string, Spec> = {
}, },
// Never saved: validate() puts it into SUPABASE_DB_URL's [YOUR-PASSWORD], so nobody edits the string by hand. // Never saved: validate() puts it into SUPABASE_DB_URL's [YOUR-PASSWORD], so nobody edits the string by hand.
SUPABASE_DB_PASSWORD: { label: "Database password", secret: true, check: () => null }, SUPABASE_DB_PASSWORD: { label: "Database password", secret: true, check: () => null },
BROKE_COUNTRY: { label: "Country", secret: false, check: (v) => (/^[A-Z]{2}$/.test(v) ? null : "A two-letter country code") },
PLAID_CLIENT_ID: { label: "Client ID", secret: false, check: (v) => (/^[a-f0-9]{24}$/.test(v) ? null : "24 letters and numbers, from Plaid → Developers → Keys") }, PLAID_CLIENT_ID: { label: "Client ID", secret: false, check: (v) => (/^[a-f0-9]{24}$/.test(v) ? null : "24 letters and numbers, from Plaid → Developers → Keys") },
PLAID_SECRET: { label: "Secret", secret: true, check: (v) => (/^[a-f0-9]{30}$/.test(v) ? null : "30 letters and numbers, from Plaid → Developers → Keys") }, PLAID_SECRET: { label: "Secret", secret: true, check: (v) => (/^[a-f0-9]{30}$/.test(v) ? null : "30 letters and numbers, from Plaid → Developers → Keys") },
PLAID_ENV: { label: "Mode", secret: false, check: (v) => (/^(sandbox|production)$/.test(v) ? null : "sandbox or production") }, PLAID_ENV: { label: "Mode", secret: false, check: (v) => (/^(sandbox|production)$/.test(v) ? null : "sandbox or production") },
+63 -47
View File
@@ -9,6 +9,7 @@ import { mcpConnected } from "@/lib/supabase-mcp";
import { cardReferralSection } from "@/lib/cards-data"; import { cardReferralSection } from "@/lib/cards-data";
import { akahuTokens } from "@/lib/providers"; import { akahuTokens } from "@/lib/providers";
import { akahuGet } from "@/lib/providers/akahu"; import { akahuGet } from "@/lib/providers/akahu";
import { countryOf } from "@/lib/countries";
export type StepStatus = "done" | "todo" | "error" | "optional"; export type StepStatus = "done" | "todo" | "error" | "optional";
export type Part = string | { href: string; label: string }; export type Part = string | { href: string; label: string };
@@ -27,6 +28,7 @@ export type Section = {
command?: string; command?: string;
action?: "migrate" | "connect"; action?: "migrate" | "connect";
providers?: AiRow[]; providers?: AiRow[];
country?: string; // step 3 only: the saved BROKE_COUNTRY, "" when not picked yet
}; };
export type SetupStatus = { sections: Section[]; ready: boolean; canWrite: boolean; writeNote?: string }; export type SetupStatus = { sections: Section[]; ready: boolean; canWrite: boolean; writeNote?: string };
@@ -142,10 +144,10 @@ export async function setupStatus(signedIn: boolean): Promise<SetupStatus> {
} }
const plaidSection: Section = { const plaidSection: Section = {
id: "plaid", kind: "required", id: "plaid", kind: "more",
title: "Connect banks", title: "US and Canadian banks (Plaid)",
what: "Start with Plaid's test banks: free, with made-up money. Switch to your real banks whenever you like.", what: "Start with Plaid's test banks: free, with made-up money. Switch to your real banks whenever you like.",
status: bank?.ok ? "done" : bank ? "error" : "todo", status: bank?.ok ? "done" : bank ? "error" : "optional",
note: bank?.message, note: bank?.message,
steps: [ steps: [
["Make a free account at ", { href: "https://dashboard.plaid.com/signup", label: "plaid.com" }, ", then open ", { href: "https://dashboard.plaid.com/developers/keys", label: "Developers → Keys" }, "."], ["Make a free account at ", { href: "https://dashboard.plaid.com/signup", label: "plaid.com" }, ", then open ", { href: "https://dashboard.plaid.com/developers/keys", label: "Developers → Keys" }, "."],
@@ -154,6 +156,62 @@ export async function setupStatus(signedIn: boolean): Promise<SetupStatus> {
fields: fields(env, ["PLAID_CLIENT_ID", "PLAID_SECRET", "PLAID_ENV"], { PLAID_ENV: { options: ["sandbox", "production"] } }), fields: fields(env, ["PLAID_CLIENT_ID", "PLAID_SECRET", "PLAID_ENV"], { PLAID_ENV: { options: ["sandbox", "production"] } }),
}; };
const akahuSection: Section = {
id: "akahu", kind: "more",
title: "New Zealand banks (Akahu)",
what: "Akahu reads NZ bank accounts. A free personal app covers the banks on your own Akahu login.",
status: akahu?.ok ? "done" : akahu ? "error" : "optional",
note: akahu?.message,
steps: [
["Sign up at ", { href: "https://my.akahu.nz", label: "my.akahu.nz" }, " and connect your banks."],
["Open Developers there, create a personal app and copy both tokens."],
],
fields: fields(env, ["AKAHU_APP_TOKEN", "AKAHU_USER_TOKEN"], { AKAHU_APP_TOKEN: { placeholder: "app_token_…" }, AKAHU_USER_TOKEN: { placeholder: "user_token_…" } }),
};
const enableSection: Section = {
id: "enablebanking", kind: "more",
title: "UK and European banks (Enable Banking)",
what: "People pick their bank and approve on the bank's own page. Restricted mode covers accounts you link yourself. Other people's accounts need a contract with Enable Banking.",
status: isSet(env.ENABLE_BANKING_APP_ID) && isSet(env.ENABLE_BANKING_PRIVATE_KEY) ? "done" : "optional",
steps: [
["Sign up at ", { href: "https://enablebanking.com/sign-in/", label: "enablebanking.com" }, " and register an application."],
[`Add this as the application's redirect URL: http://localhost:3000/api/bank/connect/enablebanking/callback`],
["Copy the application ID and paste its private key below."],
],
fields: fields(env, ["ENABLE_BANKING_APP_ID", "ENABLE_BANKING_PRIVATE_KEY"]),
};
const basiqSection: Section = {
id: "basiq", kind: "more",
title: "Australian banks (Basiq)",
what: "People approve on Basiq's own page. The sandbox is free with test banks. Real banks may need accreditation or a partner under Australia's Consumer Data Right, so ask Basiq.",
status: isSet(env.BASIQ_API_KEY) ? "done" : "optional",
steps: [
["Create an API key at ", { href: "https://dashboard.basiq.io", label: "dashboard.basiq.io" }, "."],
[`In Basiq's dashboard, set the return address to http://localhost:3000/api/bank/connect/basiq/callback`],
],
fields: fields(env, ["BASIQ_API_KEY"]),
};
const belvoSection: Section = {
id: "belvo", kind: "more",
title: "Brazilian banks (Belvo)",
what: "Open Finance consent on Belvo's page. People enter their CPF and name first, as Brazil requires. Belvo requires a link to your terms. Production keys come from Belvo support.",
status: isSet(env.BELVO_SECRET_ID) && isSet(env.BELVO_SECRET_PASSWORD) && isSet(env.BELVO_TERMS_URL) ? "done" : "optional",
steps: [["Sign up at ", { href: "https://developers.belvo.com", label: "belvo.com" }, " and create sandbox keys under Developer Tools, API Keys."]],
fields: fields(env, ["BELVO_SECRET_ID", "BELVO_SECRET_PASSWORD", "BELVO_TERMS_URL", "BELVO_ENV"]),
};
// Step 3 is the bank feed for where they live (BROKE_COUNTRY, asked on this step). No feed there: import a statement.
// Installs from before the country question keep a working feed as step 3.
const saved = isSet(env.BROKE_COUNTRY) ? env.BROKE_COUNTRY! : "";
const home = saved ? countryOf(saved) : bank?.ok ? countryOf("US") : akahu?.ok ? countryOf("NZ") : null;
const feeds = [plaidSection, akahuSection, enableSection, basiqSection, belvoSection];
const homeFeed = feeds.find((f) => f.id === home?.providers[0]);
const bankStep: Section = !home
? { id: "country", kind: "required", title: "Connect banks", what: "Pick where you live. broke shows the banks you can link there.", status: "todo", country: "" }
: homeFeed
? { ...homeFeed, kind: "required", title: "Connect banks", what: homeFeed === plaidSection ? homeFeed.what : `${homeFeed.title}. ${homeFeed.what}`, status: homeFeed.status === "optional" ? "todo" : homeFeed.status, country: saved }
: { id: "country", kind: "required", title: "Connect banks", what: `No bank feed for ${home.name} yet. After you sign in, import a statement from your bank.`, status: "done", country: saved };
const aiSection: Section = { const aiSection: Section = {
id: "ai", kind: "ai", id: "ai", kind: "ai",
title: "Connect your AI (optional)", title: "Connect your AI (optional)",
@@ -205,49 +263,7 @@ export async function setupStatus(signedIn: boolean): Promise<SetupStatus> {
command: `claude mcp add --transport http supabase-broke "https://mcp.supabase.com/mcp?project_ref=${ref}"`, command: `claude mcp add --transport http supabase-broke "https://mcp.supabase.com/mcp?project_ref=${ref}"`,
}] }]
: []), : []),
{ ...feeds.filter((f) => f !== homeFeed),
id: "akahu", kind: "more",
title: "New Zealand banks (Akahu)",
what: "Akahu reads NZ bank accounts. A free personal app covers the banks on your own Akahu login.",
status: akahu?.ok ? "done" : akahu ? "error" : "optional",
note: akahu?.message,
steps: [
["Sign up at ", { href: "https://my.akahu.nz", label: "my.akahu.nz" }, " and connect your banks."],
["Open Developers there, create a personal app and copy both tokens."],
],
fields: fields(env, ["AKAHU_APP_TOKEN", "AKAHU_USER_TOKEN"], { AKAHU_APP_TOKEN: { placeholder: "app_token_…" }, AKAHU_USER_TOKEN: { placeholder: "user_token_…" } }),
},
{
id: "enablebanking", kind: "more",
title: "UK and European banks (Enable Banking)",
what: "People pick their bank and approve on the bank's own page. Restricted mode covers accounts you link yourself. Other people's accounts need a contract with Enable Banking.",
status: isSet(env.ENABLE_BANKING_APP_ID) && isSet(env.ENABLE_BANKING_PRIVATE_KEY) ? "done" : "optional",
steps: [
["Sign up at ", { href: "https://enablebanking.com/sign-in/", label: "enablebanking.com" }, " and register an application."],
[`Add this as the application's redirect URL: http://localhost:3000/api/bank/connect/enablebanking/callback`],
["Copy the application ID and paste its private key below."],
],
fields: fields(env, ["ENABLE_BANKING_APP_ID", "ENABLE_BANKING_PRIVATE_KEY"]),
},
{
id: "basiq", kind: "more",
title: "Australian banks (Basiq)",
what: "People approve on Basiq's own page. The sandbox is free with test banks. Real banks may need accreditation or a partner under Australia's Consumer Data Right, so ask Basiq.",
status: isSet(env.BASIQ_API_KEY) ? "done" : "optional",
steps: [
["Create an API key at ", { href: "https://dashboard.basiq.io", label: "dashboard.basiq.io" }, "."],
[`In Basiq's dashboard, set the return address to http://localhost:3000/api/bank/connect/basiq/callback`],
],
fields: fields(env, ["BASIQ_API_KEY"]),
},
{
id: "belvo", kind: "more",
title: "Brazilian banks (Belvo)",
what: "Open Finance consent on Belvo's page. People enter their CPF and name first, as Brazil requires. Belvo requires a link to your terms. Production keys come from Belvo support.",
status: isSet(env.BELVO_SECRET_ID) && isSet(env.BELVO_SECRET_PASSWORD) && isSet(env.BELVO_TERMS_URL) ? "done" : "optional",
steps: [["Sign up at ", { href: "https://developers.belvo.com", label: "belvo.com" }, " and create sandbox keys under Developer Tools, API Keys."]],
fields: fields(env, ["BELVO_SECRET_ID", "BELVO_SECRET_PASSWORD", "BELVO_TERMS_URL", "BELVO_ENV"]),
},
{ {
id: "devlogin", kind: "more", id: "devlogin", kind: "more",
title: "Skip sign-in while testing", title: "Skip sign-in while testing",
@@ -258,7 +274,7 @@ export async function setupStatus(signedIn: boolean): Promise<SetupStatus> {
cardReferralSection(), cardReferralSection(),
]; ];
const required = [supabase, database, plaidSection]; const required = [supabase, database, bankStep];
const gate = writeAllowedBasics(); const gate = writeAllowedBasics();
return { sections: [...required, aiSection, ...more], ready: required.every((s) => s.status === "done"), canWrite: gate.ok, writeNote: gate.reason }; return { sections: [...required, aiSection, ...more], ready: required.every((s) => s.status === "done"), canWrite: gate.ok, writeNote: gate.reason };
} }