Files
loki/scripts/test/deploy-expected-providers.ts
CatoandClaude Opus 5.5 62d54e0ecc fix(auth): Loki's sign-in in AccountKit's order and words (#1567)
* fix(auth): Loki's sign-in in AccountKit's order and words

Every other app on AccountKit's screens draws OrangeCat, the passkey, the
password, the sign-in link and then recovery, and links between the pages
with "Create an account" / "Sign in". Loki put "Forgot password?" under the
password field and said "Welcome back", "Create one free →" and "Already
have an account? Sign in →".

The sign-in and sign-up cards now take those words from AccountKit's labels,
and recovery is a full-width row after the sign-in link. Loki still draws
these forms itself; moving them onto SignInForm/SignUpForm/AccountPanel is
the next step.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmuJhiHPASaR5k8raL9

* test(auth): the shared sign-in's words come from AccountKit, not a copy

The expectation named Apple and X, which AccountKit's published label no longer
does, so the test failed on main.

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>
2026-11-02 22:26:48 +01:00

98 lines
3.1 KiB
TypeScript

// The deploy's provider check (scripts/expected-auth-providers.ts) expects what
// the runtime actually mounts, and the sign-in pages show the shared sign-in
// exactly when AccountKit mounts it.
// Run: npx tsx scripts/test/deploy-expected-providers.ts
import { expectedAuthProviders } from "../expected-auth-providers";
import { getEnabledAuthProviders, PAUSED_PROVIDERS, sharedSigninLabel } from "@/lib/auth-providers";
import { DEFAULT_AUTH_LABELS } from "@bitbaum/accountkit/auth/react";
let pass = 0,
fail = 0;
function ok(name: string, cond: boolean) {
if (cond) {
pass++;
console.log(` ✓ ${name}`);
} else {
fail++;
console.log(` ✗ ${name}`);
}
}
const ORANGECAT = {
ORANGECAT_OAUTH_ISSUER: "https://orangecat.ch",
ORANGECAT_OAUTH_CLIENT_ID: "loki",
ORANGECAT_OAUTH_CLIENT_SECRET: "set",
};
const SIGNIN = {
SIGNIN_ISSUER: "https://signin.example.test",
SIGNIN_CLIENT_ID: "loki",
SIGNIN_CLIENT_SECRET: "set",
};
const same = (a: string[], b: string[]) => a.join(" ") === b.join(" ");
ok(
"Auth.js: the unpaused social providers and the password form",
same(expectedAuthProviders({}), [
...(["github", "google", "x"] as const)
.filter((p) => !PAUSED_PROVIDERS[p])
.map((p) => (p === "x" ? "x-1a" : p)),
"email-password",
]),
);
ok(
"AccountKit, no OIDC env: the password form only",
same(expectedAuthProviders({ AUTH_RUNTIME: "accountkit" }), ["email-password"]),
);
ok(
"AccountKit with OrangeCat: OrangeCat is expected",
same(expectedAuthProviders({ AUTH_RUNTIME: "accountkit", ...ORANGECAT }), [
"email-password",
"orangecat",
]),
);
ok(
"AccountKit with both: the shared sign-in is expected too",
same(expectedAuthProviders({ AUTH_RUNTIME: "accountkit", ...ORANGECAT, ...SIGNIN }), [
"email-password",
"bitbaum-signin",
"orangecat",
]),
);
ok(
"AccountKit with Loki's own GitHub app: GitHub is expected",
same(
expectedAuthProviders({
AUTH_RUNTIME: "accountkit",
...ORANGECAT,
GITHUB_CLIENT_ID: "loki",
GITHUB_CLIENT_SECRET: "set",
}),
["github", "email-password", "orangecat"],
),
);
ok(
"AccountKit, shared sign-in without its secret: not expected",
same(expectedAuthProviders({ AUTH_RUNTIME: "accountkit", ...SIGNIN, SIGNIN_CLIENT_SECRET: "" }), [
"email-password",
]),
);
const saved = { ...process.env };
Object.assign(process.env, SIGNIN);
delete process.env.AUTH_RUNTIME;
ok("Auth.js: no shared sign-in button (nothing mounts it)", !getEnabledAuthProviders().signin);
process.env.AUTH_RUNTIME = "accountkit";
const enabled = getEnabledAuthProviders();
ok("AccountKit with SIGNIN_*: the shared sign-in button shows", enabled.signin);
ok(
"the button uses AccountKit's own words",
// AccountKit's own words, whatever the release says (0.23.1 dropped Apple and X).
sharedSigninLabel(enabled) === DEFAULT_AUTH_LABELS.withSignin,
);
process.env.SIGNIN_CLIENT_SECRET = "";
ok("a missing secret hides it", sharedSigninLabel(getEnabledAuthProviders()) === null);
process.env = saved;
console.log(`\n${pass} passed, ${fail} failed`);
if (fail) process.exit(1);