Transcript
A chat thread where the agent's work is drawn: plans you edit, live swarms, diffs, previews and tests.
npx shadcn@latest add https://captain-transcript.vercel.app/r/captain-transcript.jsonAdd passkeys to sign-in. Keep passwords as a fallback, and don’t break the mobile app.
Captain
- Check passkey support on Safari, Chrome and AndroidResearch×2
- Threat-model the sign-in flowSecurity
- WebAuthn register and verify routesBuild×3
- Passkey button first, password behind itDesign×2
- Tests for every path, the mobile deep link tooTests×4
- Review it all, then open one PRReview×2
- src
- auth
- db
- app/(auth)/sign-in
- tests/auth
src/auth/passkey.tsadded +86
added
import { generateAuthenticationOptions, verifyAuthenticationResponse } from '@simplewebauthn/server';added
import { db } from '../db';added
import { createSession } from './session';added
added
const rpID = process.env.RP_ID ?? 'northwind.dev';added
added
export async function options(email: string) {added
const user = await db.user.findUnique({ where: { email }, include: { passkeys: true } });added
return generateAuthenticationOptions({added
rpID,added
userVerification: 'preferred',added
allowCredentials: user?.passkeys.map(k => ({ id: k.credentialId, transports: k.transports })) ?? [],added
});added
}added
added
export async function verify(email: string, response: AuthenticationResponseJSON, challenge: string) {added
const key = await db.passkey.findFirstOrThrow({ where: { credentialId: response.id } });added
const { verified, authenticationInfo } = await verifyAuthenticationResponse({added
response, expectedChallenge: challenge, expectedOrigin: `https://${rpID}`, expectedRPID: rpID,added
credential: { id: key.credentialId, publicKey: key.publicKey, counter: key.counter },added
});added
if (!verified) throw new Error('passkey did not verify');added
await db.passkey.update({ where: { id: key.id }, data: { counter: authenticationInfo.newCounter } });added
return createSession(key.userId);added
}- src
- auth
- passkey.tsadded +86
- routes.tsadded +24removed −6
- db
- schema.tsadded +12
- app/(auth)/sign-in
- page.tsxadded +52removed −31
- tests/auth
- passkey.test.tsadded +64
pnpm vitest run tests/auth --reporter=dot↓ tests/auth/legacy-sso.test.ts (3 skipped) Test Files 6 passed | 1 skipped (7) Tests 140 passed | 3 skipped (143) Duration 6.41s
exit 06s
northwind.dev/sign-in
Northwind
Sign in
Email
ada@northwind.dev
Password
••••••••••••
Sign in
Forgot your password?Northwind
Welcome back.Your key is on this device.
Sign in
Continue with a passkey
or
Email
Use your password insteadada@northwind.dev
140passed3 skipped · 6s
research-01WebAuthn spec 0:02 to 0:38
security-01Threat model 0:04 to 1:01
build-01passkey.ts 0:40 to 1:44, Return 401 2:30 to 2:46
design-01Sign-in screen 0:42 to 2:01, Waited on you 2:01 to 2:19
tests-02Deep link 1:04 to 1:32, Failed 1:32 to 1:41, Retried, passed 1:41 to 2:13
review-01Review 2:14 to 2:56
design-01Behind a link(picked)
<PasskeyButton /> <TextButton>Use your password instead</TextButton>
build-02Beside the passkey
<PasskeyButton /> <PasswordForm compact />
Where does the password field go?
Who gets passkeys first?
$3.84of $20.001.9M tokens · 14 agents
- Build$1.42
- Tests$0.86
- Design$0.58
- Review$0.41
- Research$0.34
- Security$0.23
Worked for 3m 12s · 14 agents · $3.84
Transcript is a Captain family piece with its own repo: github.com/jawadjalal/transcript. Install it with the command above.
Usage
import { CaptainTranscript } from "@/components/captain-transcript"
<div style={{ height: 600 }}>
<CaptainTranscript messages={messages} onAction={(e) => captain.act(e)} />
</div>Props
| Prop | Type | Default | What it does |
|---|---|---|---|
| messages | Message[] | The thread, controlled. | |
| defaultMessages | Message[] | Uncontrolled start. | |
| onAction | (e) => void | Approve, answer, pick, accept, run, ship. |
Keyboard
- J / K
- Next and previous turn
- End
- Jump to latest
Accessibility
- A log with an announcer for new turns.
- Virtualised to 100k messages.
- axe 0 violations in CI.