mirror of
https://github.com/bitbaum/accountkit.git
synced 2026-12-04 05:57:23 +01:00
A free, Bitcoin-native way in: the person's own Lightning wallet signs a one-time challenge shown as a QR code (or opened through a lightning: link on the same device). No key, no third party, nothing paid. The signed key is a sign-in method (providerId "lightning"), never an email. - /lightning/start mints a challenge (five minutes, used once) and binds it to the asking browser with a signed cookie; /lightning/callback is the wallet's LUD-04 call and checks the DER secp256k1 signature of k1; /sign-in/lightning (polled) signs in or creates the person; /lightning/link adds a wallet to the signed-in person, never one that already signs in to someone else. - A second factor applies; minting and the wallet's call spend the credential bucket. - SignInForm and SignUpForm offer "Sign in with a Lightning wallet", AccountPanel "Add Lightning wallet"; words in all six languages. - Off until ACCOUNTKIT_LIGHTNING=1. Tests: LUD-01's own LNURL both ways, a signature made by OpenSSL, and the whole flow on a real database (PGlite) with a wallet that signs as LUD-04 says: sign-in and sign-in again, a forged signature, an onlooker without the browser's cookie, a second factor, linking and a taken wallet, and nothing mounted without the opt-in. Browser: QR, wallet link, 44px, no sideways scroll at 320 and 390px. Claude-Session: https://claude.ai/code/session_019MDtmuJhiHPASaR5k8raL9 Co-authored-by: Claude <noreply@anthropic.com>
42 lines
1.6 KiB
JavaScript
42 lines
1.6 KiB
JavaScript
import { passkeyClient } from "@better-auth/passkey/client";
|
|
import { emailOTPClient, magicLinkClient, twoFactorClient, } from "better-auth/client/plugins";
|
|
/** Lightning login's three calls (./lightning), for SignInForm and AccountPanel. */
|
|
export function lightningClient() {
|
|
return {
|
|
id: "accountkit-lightning",
|
|
getActions: ($fetch) => ({
|
|
lightning: {
|
|
start: (purpose = "sign-in") => $fetch("/lightning/start", {
|
|
method: "POST",
|
|
body: { purpose },
|
|
}),
|
|
signIn: () => $fetch("/sign-in/lightning", {
|
|
method: "POST",
|
|
body: {},
|
|
}),
|
|
link: () => $fetch("/lightning/link", { method: "POST", body: {} }),
|
|
},
|
|
}),
|
|
};
|
|
}
|
|
/**
|
|
* The plugins the browser client needs, the same in every product:
|
|
*
|
|
* import { createAuthClient } from "better-auth/react";
|
|
* import { authClientPlugins } from "@bitbaum/accountkit/auth/client";
|
|
* export const authClient = createAuthClient({ plugins: authClientPlugins() });
|
|
*
|
|
* The client itself is created by the product, because its fully inferred type
|
|
* cannot be written into a published declaration file. It talks only to this
|
|
* origin (/api/auth), which is all a strict CSP's `connect-src 'self'` allows.
|
|
*/
|
|
export function authClientPlugins() {
|
|
return [
|
|
twoFactorClient(),
|
|
passkeyClient(),
|
|
magicLinkClient(),
|
|
emailOTPClient(),
|
|
lightningClient(),
|
|
];
|
|
}
|
|
//# sourceMappingURL=client.js.map
|