mirror of
https://github.com/bitbaum/botsmann.git
synced 2026-12-04 04:47:45 +01:00
* feat(auth): every way in on AccountKit's own screens
Botsmann signed people in against OrangeCat's GoTrue (auth.users). It now
runs on AccountKit (@bitbaum/accountkit 0.23) with AccountKit's own forms:
/auth/signin offers email and password, an emailed sign-in link, a
passkey, recovery through the mailed link and the second factor;
/auth/signup is sign-up; /account carries the account panel ("Sign-in and
security" in the account menu). "Continue with OrangeCat" and the shared
sign-in show when their clients are set, the link and recovery when mail
is. The GoTrue routes (/api/auth/signin, signup, forgot-password,
resend-verification, profile) and pages (callback, forgot-password,
reset-password, verify-email) and the cookie-session client are gone.
AccountKit's tables live in a host accounts database (drizzle/, loki
accounts-db.conf); the data stays in the botsmann supabase schema, which
every route already read with the service-role client. verifyUser now reads
AccountKit's session; /api/user/profile moves onto it too. New accounts get
uuid ids, and migration 013 drops the person columns' keys to auth.users,
which a new person's id is not in. Nothing is deleted. The profile editor
writes AccountKit's name and image.
Existing people keep their rows: scripts/db/accountkit-people.sql lists
everyone who owns rows with their OrangeCat actor id, and
scripts/db/accountkit-import.sql gives each an account under the same id,
linked to OrangeCat by that actor id, never by address (loki
accountkit-supabase.yml rehearses it rolled back, then imports).
Pages were served with public, max-age=3600 to every browser, account pages
included: after sign-out the browser showed its cached /account. /account
and /auth/* are now private, no-store. The account menu's trigger has a name.
tests/__tests__/accounts runs the ways in and the import on the committed
migration; browser-smoke.yml's account job rehearses the import and runs
the browser journey against the production build with AccountKit's real
mail caught by a sink.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmuJhiHPASaR5k8raL9
* fix(auth): send a signed-out visitor to sign in with the router
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmuJhiHPASaR5k8raL9
* ci(auth): the shared sign-in's button is matched by how it starts
AccountKit 0.24 names only the providers Morulia publishes, so the label
changes with Morulia.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmuJhiHPASaR5k8raL9
* ci(auth): expect the shared sign-in only once Morulia publishes a provider
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmuJhiHPASaR5k8raL9
* ci: run the checks on the journey change
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmuJhiHPASaR5k8raL9
---------
Co-authored-by: Claude <noreply@anthropic.com>
30 lines
1.3 KiB
JavaScript
30 lines
1.3 KiB
JavaScript
/* eslint-disable @typescript-eslint/no-require-imports -- a --require preload must be CommonJS */
|
|
/**
|
|
* CI only: account mail without a mail provider. Preloaded into `next start`
|
|
* (NODE_OPTIONS="--require ./scripts/ci/mail-sink.cjs") with MAIL_SINK set, it
|
|
* answers @bitbaum/mail-kit's one call, POST https://api.resend.com/emails, by
|
|
* appending the message as one JSON line to MAIL_SINK. Every other request goes
|
|
* out untouched. The browser journey reads the reset and sign-in links from
|
|
* that file, so AccountKit's real token, callback and reset run end to end.
|
|
* Never loaded outside CI: nothing in the app requires it.
|
|
*/
|
|
const fs = require('node:fs');
|
|
|
|
const SINK = process.env.MAIL_SINK;
|
|
if (SINK) {
|
|
const original = globalThis.fetch;
|
|
globalThis.fetch = async function sinkFetch(input, init) {
|
|
const url = typeof input === 'string' ? input : input instanceof URL ? input.href : input.url;
|
|
if (url === 'https://api.resend.com/emails') {
|
|
const body =
|
|
typeof init?.body === 'string' ? init.body : await new Request(input, init).text();
|
|
fs.appendFileSync(SINK, body.replace(/\n/g, ' ') + '\n');
|
|
return new Response(JSON.stringify({ id: `ci-${Date.now()}` }), {
|
|
status: 200,
|
|
headers: { 'content-type': 'application/json' },
|
|
});
|
|
}
|
|
return original(input, init);
|
|
};
|
|
}
|