12 Commits
Author SHA1 Message Date
CatoandClaude 6d97c7e22a fix(auth): a text action is centred in any form layout (#99)
As an inline box it sat at the left edge in a product whose form is a plain
block stack (Loki's sign-in, live 2026-11-14). It is now a full-width row
with its words centred.


Claude-Session: https://claude.ai/code/session_019MDtmtUQb9BM11ycpApwGq

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-14 12:22:17 +01:00
CatoandClaude 587b65e0f1 fix(auth): one thing the sign-in screen asks for (#98)
"Email me a sign-in link instead" and "Forgot your password?" are text
actions (classes.textAction), not outlined boxes. Loki's sign-in at 390px
stacked nine outlined boxes of equal weight and the filled Sign in read as
one of many. A text action is still a full touch target.


Claude-Session: https://claude.ai/code/session_019MDtmtUQb9BM11ycpApwGq

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-14 10:24:18 +01:00
CatoandClaude f1c5c7c16c feat(menu): rows shown only below 768px (shown: "narrow") (#95)
An AccountMenu item or group may carry shown: "always" | "narrow"
(default "always"), and extra has the same choice as extraShown. A narrow
row is in the menu below 768px only: hidden by the package stylesheet in a
media query (no width read in script, right on the server render and the
first paint), skipped by the arrow keys, and a hidden group takes its
divider with it.

For a row that repeats a control the header carries from md up, such as
OrangeCat's theme toggle, which its menu also showed as "Appearance".


Claude-Session: https://claude.ai/code/session_019MDtmvT2nQyPBK4EfWf3Rn

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-13 11:53:47 +01:00
CatoandClaude f8d61aa720 feat(menu): AccountControl, a panel that stays on screen, remote session read (#92)
* feat(menu): AccountControl, a panel that stays on screen, remote session read

A consumer gets, from the browser-safe "." entry:
- AccountControl: one header control for loading (an inert box the
  trigger's size), signed out (one 44px "Sign in" link) and signed in
  (AccountMenu, unchanged), plus accountSignInHtml({ href, label }), the
  same signed-out markup byte for byte for a static page.
- fetchAccountSummary(url, { signal?, fetch?, timeoutMs? }): a
  credentialed, no-store GET of a session held on another origin that
  resolves null on any failure and never rejects, including an injected
  fetch that returns something that is not a Response. timeoutMs (default
  8000; 0, negative or Infinity turns it off) bounds the whole read, body
  included, combined with the caller's signal (AbortSignal.any where
  available, by hand otherwise), so a stalled server cannot leave a header
  loading for ever and the header fails closed to "Sign in".
- returnPath, the same-origin path guard, no longer only behind the
  server-only ./orangecat entry.

Fix: the open panel ran off the screen when the trigger was not last in its
row (-112px at 390 in Bitbaum's header). The menu now measures the open
panel and moves it inside only when it crosses an edge; a last trigger's
panel is unchanged. It is measured again while open on a window resize and,
without one, when the panel or its header row (nearest flex or grid
ancestor) or a control in that row changes size, or a control is added to
or removed from the row (ResizeObserver and MutationObserver, feature
detected, disconnected on close and unmount).

Checked by pnpm run verify: browser checks at 320 and 390, light and dark,
on four demo rows (a 44px control before or after the trigger, both
aligns), which failed on the old stylesheet; with the menu open, a 44px
control added after the trigger, and the existing one widened, without a
window resize (left -47px at 320 before); render tests comparing
AccountControl with accountSignInHtml and AccountMenu, escaping hostile
input; unit tests for fetchAccountSummary with an injected fetch (non-
Response values, a fetch and a body that never settle, the 8000ms default
under mock timers, the caller's abort with a timeout armed, the fallback
without AbortSignal.any, Infinity) and for returnPath from ".". The browser
check honours CHROMIUM_PATH. dist/orangecat.d.ts only shows a union
reordered by the compiler, not a source change.

Claude-Session: https://claude.ai/code/session_019MDtmsSWTTpVpe4wh3v1sb

* fix(menu): the panel is moved in layout, so nothing scrolls sideways

The pull request's own browser check failed in CI and passed locally:
with the panel open in the two `align="start"` demo rows the page
scrolled sideways by 186px and 242px, at 320 and 390 wide, while the
panel itself measured inside the screen. CI runs Chromium 156; the local
run was Chromium 153. The panel was moved back on screen with
`translate`, and the page still counted the place it had come from.

What a consumer gets: the panel is moved on the edge it is pinned by, in
layout (`inset-inline-start` or `inset-inline-end` take `--acct-shift`).
A box laid out inside the screen cannot make the page scroll in any
browser. The move follows the text direction: in a right-to-left page
the pinned edge is the other one, and the offset changes sign with it.

How it is checked: test/browser.mjs opens the four demo rows again with
the page set right to left, at 320 and 390px, light and dark, and asserts
the panel is inside the viewport and nothing scrolls sideways. The
existing left-to-right checks are unchanged. `pnpm run verify` passes on
Chromium 153; CI decides for 156.

Claude-Session: https://claude.ai/code/session_019MDtmsSWTTpVpe4wh3v1sb

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-12 10:40:08 +01:00
CatoandClaude 08e2e3a666 feat(menu): AccountMenu shows what waits in another account (#91)
An account in accounts may carry waiting, a count of what waits there
(unread messages, notifications). It is shown at the end of that account's
row, capped at 99+, and as a dot beside the trigger, so a person knows
before opening the menu. The trigger's accessible name says so too.

- Zero, absent or not a positive number shows nothing; so does a count with
  no onSwitchAccount, because there is nowhere to go.
- The dot sits beside the trigger, not in it: the trigger clips to keep a
  photo round and would clip the dot with it.
- The count and the dot are the text colour inverted, not the accent, which
  the fleet keeps for Bitcoin and for the action that brings someone in.
- A long name truncates before the count instead of pushing it off the row.


Claude-Session: https://claude.ai/code/session_019MDtmubu4vMeqp2pdae1Zy

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-12 06:13:07 +01:00
CatoandClaude e15ed7f353 feat(menu): AccountMenu switches accounts (#89)
One person can hold several accounts: OrangeCat's identities are the first
case. The other accounts are listed under who is signed in, and a tap
switches.

- New optional props accounts ({ id, user, note? }) and onSwitchAccount(id).
  A row is a face (photo, initials from the name, or a glyph), the name, and
  one line with the note and the handle. The note leads so it survives a long
  handle; another account's email is never shown.
- Same failure contract as sign-out: the row says it is switching, and a
  switch that rejects keeps the menu open and says it did not complete.
- The rows are menu items, so arrows, Home and End reach them.
- Without the new props the menu renders exactly as before.

Browser suite: listed under a heading, 44px rows, a long name and handle
keep the panel on a 390px and a 320px screen, keyboard reach, a failed
switch, a completed one.


Claude-Session: https://claude.ai/code/session_019MDtmubu4vMeqp2pdae1Zy

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-12 04:43:04 +01:00
CatoandClaude e282d1e6e4 feat(auth): Lightning login (LNURL-auth, LUD-04), opt-in per deployment (#75)
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>
2026-11-02 23:34:27 +01:00
Cato d528260d49 feat(auth): CJS ./auth/password and one new-password field on reset (0.9.1) (#37)
* feat(auth): CommonJS build of ./auth/password; reset form asks for the new password once, in the same field as sign-up

* feat(auth): PasswordField as its own entry for products with their own pages

* fix(styles): the eye's room applies to any input in the box

* feat(auth): ./auth/hash, bcrypt over SHA-256 with verify-and-rehash of old hashes

* feat(auth): PasswordField accepts name and placeholder
2026-10-28 03:54:02 +01:00
CatoandClaude 5dcc30d7c7 feat(auth): one password field at sign-up, with the eye inside it (#29)
0.7.2 asked for the password twice and put a full-width 'Show password'
bar between the fields and the button, which read as a third action. The
owner asked for sign-up without friction (2026-10-26). Seeing what you
typed is what the repeat field was for: the show/hide control is now an
eye inside the password field (two new class slots, inputWrap and
reveal, styled on --acct-* tokens, a 44px target), and sign-up has one
password field. Password reset keeps its repeat field, where a typo
locks the person out.


Claude-Session: https://claude.ai/code/session_01YK5nTo2tfxq8V8mKtuRGJH

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-26 21:38:22 +01:00
CatoandClaude Opus 5.5 43fb3110fb feat(auth): shared sign-in, sign-up and account screens (v0.4.0) (#6)
* feat(auth): shared sign-in, sign-up and account screens (auth/react, v0.4.0)

Logic in the package, words and look from the product: labels (English
default) and classes (acct-auth-* defaults on --acct-* variables).

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

* feat(auth): fall back to AUTH_SECRET so a product moving off next-auth needs no new secret

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-15 09:35:31 -07:00
CatoandClaude Opus 5.5 b6af2684d5 feat(orangecat): Sign in with OrangeCat, once — provider, session refresh, identity rules, error screen (v0.2.0) (#2)
Nine apps hand-rolled OrangeCat OIDC; this is the best of each:
- provider for Auth.js v5 and next-auth v4: client_secret_post, pkce+state,
  identity scopes; profile() without email (contactEmail as data)
- syncOcSession (heidi/solon refresh): invalid_grant ends the session,
  anything else retries in 60 s
- authorizationParams / returnPath (solon)
- placeholder email, withOrangecatIdentity adapter wrapper and
  resolveOrangecatUser (petvity, surf-your-life, datacat race),
  decideOrangecatSignIn + link token (evig), emailEarnsPromotion,
  mayReceivePasswordReset
- SignInError: Try again restarts sign-in

Contract tests mutated: basic auth, dropped pkce, email in profile,
ignored invalid_grant, kept actorId, reused taken email, admin promotion,
reset for OC-only — each turns the suite red.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-02 10:33:05 -07:00
CatoandClaude Opus 5.5 54dc11cf47 feat: one account menu for every product (v0.1.0) (#1)
Each product wrote its own account menu, and each learned half of what
the other had:

  Loki AccountMenu              OrangeCat UserProfileDropdown
  initials from the name only   never rebuilds a name from the email
  custom rows (Appearance)      photo with a fallback, arrow keys
  36px trigger                  44px trigger
  name falls back to the        —
    email local-part

and Loki's public pages had no menu at all, so a signed-in person could
not find sign-out (loki#870 papered over that by reusing the app's menu).

This is the one menu with both halves. It knows nothing about how a
product signs people in — NextAuth, Supabase, better-auth all pass the
person, the places, and a sign-out function — and keeps routing with a
renderLink seam (Next <Link>; a plain <a> by default).

Shared and not configurable, because each shipped broken somewhere:
- the name is never built from the email (OrangeCat's rule; Loki broke it)
- initials only from the name; else a person glyph
- a broken photo falls back to initials
- 44px trigger and rows; the panel never runs off a 390px screen
- Escape closes and returns focus wherever focus was
- sign-out says it is happening, and says when it FAILED (menu stays open)

The real-browser check caught a bug before release: Escape did nothing
after a MOUSE open, because the handler sat on the panel and focus was
on the trigger. It is now a document listener while open.

Styled from @bitbaum/design-tokens through --acct-* variables at zero
specificity (chatkit's pattern), so an app's own :root wins and an OKLCH
app maps its tokens once.

dist/ is committed so `github:bitbaum/accountkit#v0.1.0` installs with no
build and no allowBuilds entry; CI fails if it drifts from the source.

verify: format, lint, types, build, 13 unit+render tests, browser checks
at 390px light and dark. Proved by mutation — letting the name fall back
to the email local-part fails "a name is NEVER reconstructed from the
email address".

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-02 05:45:04 -07:00