npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@authtempo/core

v0.2.0

Published

```ts import { createAuth, createMemoryAdapter } from "@authtempo/core";

Readme

@authtempo/core

import { createAuth, createMemoryAdapter } from "@authtempo/core";

const auth = createAuth({
  baseURL: "https://api.example.com",
  secret: env.AUTH_SECRET,                 // at least 32 characters, 100 bits or more
  trustedOrigins: ["https://app.example.com", "consumera://"],
  storage: createMemoryAdapter(),          // use a D1 or Postgres adapter in production
  mail: { send: async (m) => { /* your transport */ } },
});

// In your fetch handler:
if (url.pathname.startsWith("/auth/")) return auth.handle(request);
const s = await auth.session(request);     // { user, session } or null

Give secret, or secrets as a list of { version, value } with the current version first. secret alone is version 1. A value has at least 32 characters.

The estimate of a secret is its length times log2 of its distinct characters. createAuth refuses a current secret under 100 bits and warns from 100 to 119 bits. The estimate does not catch a pattern. Make a secret with 32 random bytes: openssl rand -base64 32.

Routes under basePath (default /auth)

| Method | Path | Body or query | Answer | | --- | --- | --- | --- | | POST | /magic-link/request | { email, next? } | { sent: true } always; 429 when rate limited; 400 on a bad body | | GET | /magic-link/verify | ?token= | 200 HTML confirm page with a form that posts the token; 302 to /?auth_error=invalid_token on a malformed token. No side effect, so a mail scanner burns nothing | | POST | /magic-link/verify | form or JSON token, trustDevice? | form body: 302 to appURL plus next with the session cookie, or, for a user with the second factor on, 302 to the challenge page with no cookie, or 302 to /?auth_error=<code>; JSON body: 200 { user, session } with the cookie, or 200 { twoFactor: { challenge, expiresAt, methods } } with no cookie (plan 12c), or the error as JSON | | GET | /social/google/start, /social/apple/start | ?next= | 302 to the provider with a binding cookie; 302 to /?auth_error=rate_limited when limited. A route exists only for a configured provider | | GET | /social/google/callback | ?code&state | 302 to next with the session cookie; for a user with the second factor on, 302 to the challenge page with no cookie (plan 12c); 302 to /?auth_error=<code> on failure | | POST | /social/apple/callback | form code, state, user? from Apple | same as the Google callback. The Origin check is skipped here; the state row and the binding cookie bind the post | | GET | /social/<name>/start, /social/<name>/callback | ?next=; ?code&state | the same answers as the Google routes, for github, linkedin, and each social.oidc and social.oauth2 entry | | POST | /social/google/id-token/nonce, /social/apple/id-token/nonce | JSON {} | { nonce, providerNonce, expiresAt }: a nonce of one use that lives 5 minutes (plan 12i), and its SHA-256 hex for the provider. 429 rate_limited after 60 per IP per 15 minutes | | POST | /social/google/id-token, /social/apple/id-token | JSON { idToken, nonce?, name?, next?, trustDevice? } | { token, user, session, via? } with the session cookie, or { twoFactor }. The ID token of Google One Tap or of the native Apple sheet, with the nonce of the route. 400 invalid_token for a bad, used, or replayed token or nonce; 429 after 30 per IP per 15 minutes; the codes of the callback | | GET | /session | cookie or Authorization: Bearer | { user, session } or 401. With session.deferRefresh on, also needsRefresh, and no renewed cookie | | POST | /session/refresh | cookie or bearer | { user, session }, and the renewed cookie when the refresh was due; 401 (plan 12a) | | POST | /sign-out | cookie or bearer | { ok: true } and clears the cookie. With multiSession on, every session of the bag cookie ends too, and the bag cookie is cleared (plan 12i) | | GET | /multi-session | session cookie only, no Bearer scheme | { sessions }: the active session and each live session of the bag, each with sessionId, active, and user. No token. A bag session never slides. 401 to a Bearer request (plan 12i) | | POST | /multi-session/switch | session cookie, { sessionId } | { user, session } of the new active session; the old one moves into the bag. 404 not_found for an id outside the browser (plan 12i) | | POST | /multi-session/sign-out | session cookie, { sessionId } | { ok: true }; only that session ends. 404 not_found for an id outside the browser (plan 12i) | | POST | /passkey/register/options | session (fresh) | the creation options JSON for navigator.credentials.create; 401; 403 email_unverified, session_not_fresh | | POST | /passkey/register/verify | session, { response, name? } | { passkey }; 400 invalid_body, invalid_token, token_expired, passkey_failed; 401; 403 email_unverified. A credential id that is already registered answers passkey_failed. A name that is blank after the trim, or that breaks the passkey name rule, is stored as no name (see "Passkeys") | | POST | /passkey/authenticate/options | { hints?, extensions? } | the request options JSON for navigator.credentials.get; 400 invalid_body (a PRF salt that is not 32 bytes, or an extension that passkey.extensions does not turn on); 429 rate_limited | | POST | /passkey/authenticate/verify | { response } | { user, session } with the session cookie; 400 invalid_body, invalid_token, token_expired, passkey_failed (an unknown credential or a bad signature); 429 rate_limited | | GET | /passkeys | session | { passkeys: [{ id, credentialId, name, deviceType, backedUp, discoverable, prf, largeBlob, createdAt }], rpId, userHandle, userName, userDisplayName }; 401 | | POST | /passkeys/delete | session (fresh), { id } | { ok: true }; 400 invalid_body; 401; 403 session_not_fresh; 404 not_found; 409 last_credential (the last way in, see "The last-credential guard"), second_factor_last_method, conflict | | POST | /passkeys/rename | session, { id, name } | { passkey } in the shape of GET /passkeys (plan 12a). No fresh rule: a name is no way in. 400 invalid_body (a name that breaks the passkey name rule, or any other field); 401; 404 not_found (an unknown id, or an id of another user); 429 rate_limited | | POST | /password/sign-up | { email, password, name? } | { sent: true, signUpProof } with no session cookie for every address (password.uniformSignUp, the default); with uniformSignUp: false, { token, user, session, signUpProof } with the cookie, or { user, verifyRequired: true, signUpProof } with no session cookie under requireVerified or signUp: "invited". Every answer sets the proof cookie __Host-tempo_signup (see "The confirm of a sign-up"); 400 invalid_body, password_policy, password_breached, captcha_required; 403 sign_up_closed, captcha_failed; 409 email_taken, email_taken_unverified (only with uniformSignUp: false); 429 rate_limited; 503 breach_check_unavailable, captcha_unavailable. The captcha codes come only with captcha (see "Captcha"). The user is unverified until the mail link is confirmed | | POST | /password/sign-in | { email, password, signUpProof? } | { token, user, session } with the cookie; 400 invalid_body; 401 invalid_credentials; 429 rate_limited; 404 without a password config | | GET | /password/verify | ?token= | 200 HTML confirm page; 302 to /?auth_error=invalid_token on a malformed token. No side effect, so a mail scanner burns nothing | | POST | /password/verify | form or JSON token, the proof cookie | form body: 302 to appURL with the cookie, to appURL plus /?password=set when the password went, or to /?auth_error=<code>; JSON body: { verified: true, passwordKept }, with the cookie when the address was unverified, or the error as JSON. invalid_token when the password row is gone; token_expired | | POST | /password/verify/code | { email, code, signUpProof? }, the proof cookie | { token, user, session, passwordKept } with the cookie when the address was unverified, or { verified: true, passwordKept }; 400 invalid_code, too_many_attempts; 429 rate_limited. The code of password.verifyBy: "code" (see "The sign-up code") | | POST | /password/verify/resend | { email, signUpProof? }, the proof cookie | { sent: true } always; 400 invalid_body; 429 rate_limited. A mail goes only to an unverified user with a password, and the earlier link or code of the address stops working | | POST | /password/reset/request | { email, next? } | { sent: true } always; 429 rate_limited; 400 invalid_body | | GET | /password/reset | ?token= | 200 HTML form (password.resetPage replaces it); 302 to /?auth_error=invalid_token on a malformed token. No side effect | | POST | /password/reset | form or JSON token, password, trustDevice? | form body: 302 to next with the cookie, or, for a user with the second factor on, 302 to the challenge page with no cookie, or back to the form on password_policy, password_breached, or breach_check_unavailable, or 302 to /?auth_error=<code>; JSON body: { token, user, session } with the cookie, or { twoFactor: { challenge, expiresAt, methods } } with no cookie (plan 12c), or the error as JSON. invalid_token, token_expired, 429 rate_limited, 503 breach_check_unavailable. A reset that answers the challenge still sets the password and ends every session | | POST | /password/change | session, { currentPassword?, newPassword }; a fresh session for a first password and while the second factor is on | { ok: true }; 400 invalid_body, password_policy, password_breached; 401 without a session; 401 invalid_credentials for a missing or wrong current password; 403 email_unverified, session_not_fresh; 409 conflict; 429 rate_limited; 503 breach_check_unavailable | | POST | /otp/request | { email } | { sent: true } always; 400 invalid_body; 429 rate_limited. Mails a sign-in code | | POST | /otp/verify | { email, code, trustDevice? } | { token, user, session } with the cookie, or, for a user with the second factor on, { twoFactor: { challenge, expiresAt, methods } } with no cookie (plan 12c); 400 invalid_body, invalid_code (a wrong, expired, spent, or unknown code), too_many_attempts (the code took maxAttempts wrong guesses: request a new one); 429 rate_limited | | POST | /otp/reset/request | { email } | { sent: true } always; 400 invalid_body; 429 rate_limited. Mails a reset code. Only with a password config | | POST | /otp/reset | { email, code, password, trustDevice? } | { token, user, session } with the cookie, or, for a user with the second factor on, { twoFactor: { challenge, expiresAt, methods } } with no cookie and the password set (plan 12c); 400 invalid_body, invalid_code, too_many_attempts, password_policy and password_breached (both spend the code); 429 rate_limited; 503 breach_check_unavailable (it spends the code too). Only with a password config | | GET | /handoff/start | ?challenge=&redirect= | 200 the sign-in page, or 302 to the confirm page when the browser already has a session; 400 invalid_body; 429 rate_limited. Only with a handoff config | | GET | /handoff/continue | ?h= | 200 the confirm page with a session, the sign-in page without one; 302 to /?auth_error=<code> for a spent or unknown id | | POST | /handoff/continue | form h, Origin = baseURL | 302 to <redirect>?code=; 403 from any other origin; the sign-in page without a session | | POST | /handoff/redeem | { code, verifier } | { token, user, session } as a bearer answer, no cookie; 400 invalid_body, invalid_token, token_expired; 429 rate_limited | | POST | /tokens | session (fresh), { name, expiresInDays?, organizationId?, permissions?, metadata? } | { token, apiToken }, the clear token once; 400 invalid_body (also a set with an unknown name, a set with organizations off, or metadata over 4096 bytes); 401 without a session (a tk_ bearer too); 403 email_unverified, session_not_fresh, forbidden_rank for a set wider than the user's set in the bound organization; 404 not_found for an organization the user is not a member of; 409 token_limit at 50 tokens; 429 rate_limited. The route takes no window and no quota | | GET | /tokens | session | { tokens: [{ id, name, hint, expiresAt, lastUsedAt, organizationId, permissions, metadata, rateLimit, remaining, retired, createdAt }] }, newest first, never a token or its hash; 401; 403 email_unverified | | POST | /tokens/revoke | session, { id } | { ok: true }; 400 invalid_body; 401; 403 email_unverified; 404 not_found for another user's token | | POST | /tokens/update | session (fresh), { id, name?, permissions?, expiresAt? } | the apiToken after the change; it narrows only: 400 invalid_body for a wider set, null over a set, a later expiry, null over a date, or another key; 401; 403 email_unverified, session_not_fresh; 404 not_found for another user's token; 409 conflict when the row changed between the read and the write | | GET | /tokens/current | Authorization: Bearer tk_… only | { user, apiToken }, and one call of the quota spent; 401 for a session cookie, a ts_ bearer, or no credential, and token_retired for a key of tokens.movedPrefixes with no row; 429 rate_limited over the token's window, token_exhausted at a quota of zero; 409 conflict when a lost spend sees no other spend, or after 20 lost spends | | POST | /totp/setup | session, { password } or { emailCode } (a code of POST /reauth/email) | { secret, uri, backupCodes }, each answered once; backupCodes is empty when another method is on, because the factor keeps its list (plan 12c); 400 invalid_body (no proof, or two), invalid_code (a wrong, spent, or expired email code; no row is written), too_many_attempts (the guesses of the code are spent); 401, invalid_credentials (a wrong password; no row is written); 403 email_unverified; 404 for a proof that the deployment lacks (password with no password config, emailCode with emailOtp: false); 429 rate_limited (totp-setup:user, 5 per 15 minutes, and the verify limits of a mailed code); 409 totp_enabled, conflict (a parallel setup of the same user). A new setup replaces one that was not confirmed. Only with totp: on by default with password, and set by the app with no password | | POST | /totp/enable | session (fresh), { code } | { enabled, enabledAt, backupCodesLeft, trustedDevices, methods, backupCodesVersion }, as GET /totp; 400 invalid_body, invalid_code, totp_not_enabled (no setup, one older than 15 minutes, or a setup whose codes another method made stale: set up again); 401; 403 email_unverified, session_not_fresh; 409 totp_enabled, conflict (a parallel first enable of another method: retry); 429 rate_limited. As the first method, it ends every other session of the user with two_factor | | POST | /totp/disable | session (fresh), { code } (a current code or a backup code) | { ok: true }, and clears the trust cookie; it turns the TOTP method off, and with no method left the factor is off; 400 invalid_body, invalid_code, totp_not_enabled; 401; 403 session_not_fresh; 409 conflict; 429 rate_limited | | POST | /totp/backup-codes | session (fresh), { code } | { backupCodes }, a new list; the old codes stop working; 400 invalid_body, invalid_code, totp_not_enabled; 401; 403 session_not_fresh; 409 conflict (parallel writes won every try); 429 rate_limited | | GET | /totp | session | { enabled, enabledAt, backupCodesLeft, trustedDevices, methods, backupCodesVersion }: enabled is true when any method is on, methods lists them, and backupCodesVersion is 1 for the codes of plan 9f, 2 for the codes of 23 characters, and null with the factor off; never the secret or the URI; 401 | | POST | /totp/devices/revoke | session | { ok: true }: every trusted device of the user goes, and the trust cookie is cleared; 401 | | POST | /totp/verify | { challenge } and one of code, backupCode, emailCode, or passkey (an assertion over the options of /second-factor/passkey/options), trustDevice? | { token, user, session, next, backupCodesLeft, trustDevice } with the session cookie, and the trust cookie when trustDevice is true; 400 invalid_code, too_many_attempts (the fifth wrong code), invalid_token (unknown, spent, or older than 5 minutes), invalid_body (no proof, two proofs, or a method that the challenge does not offer), passkey_failed; 429 rate_limited | | GET | /totp/challenge | ?challenge= | 200 HTML form of the challenge's methods, with a trusted-device button when the browser sends a live trust cookie of the user (totp.challengePage replaces it); 302 to /?auth_error=invalid_token on a malformed or dead challenge. It reads rows and writes none | | POST | /totp/challenge | form challenge, and code, backupCode, or emailCode with trustDevice=1; or action=send-email; or action=trusted | 302 to next with the cookies; back to the form on invalid_code and after a send; 302 to /?auth_error=<code> otherwise. action=trusted passes with the trust cookie alone | | POST | /second-factor/passkey/enable | session (fresh), { password, response } (an assertion over /passkey/authenticate/options by a passkey of the user) | { methods, backupCodes }; the codes come once, with the first method; 400 invalid_body, passkey_failed; 401, invalid_credentials; 403 email_unverified, session_not_fresh; 404 not_found without passkey; 409 conflict; 429 rate_limited (totp-setup:user). Only with passkey | | POST | /second-factor/passkey/options | { challenge } | WebAuthn request options with the user's passkeys in allowCredentials, bound to the challenge; 400 invalid_body (the challenge does not offer passkey), invalid_token; 429 rate_limited (second-factor-passkey:ip, 30 per 15 minutes). Only with passkey | | POST | /second-factor/email/enable | session (fresh), { password } | { methods, backupCodes }, as the passkey enable; 400 invalid_body; 401, invalid_credentials; 403 email_unverified, session_not_fresh; 409 conflict; 429 rate_limited (totp-setup:user) | | POST | /second-factor/email/send | { challenge } | { sent: true }, and a 6-digit code to the user's address; a new send replaces the code; 400 invalid_body (the challenge does not offer email), invalid_token; 409 conflict; 429 rate_limited (3 sends per challenge, second-factor-email:user 5 per 15 minutes, totp:email-day 20 per 24 hours) | | POST | /second-factor/disable | session (fresh), { method, password } with method passkey or email | { ok: true, methods }, the methods left; with none left the factor is off and the trust cookie is cleared; 400 invalid_body, totp_not_enabled (the method is not on); 401, invalid_credentials; 403 session_not_fresh; 409 conflict; 429 rate_limited (totp-setup:user). TOTP has its own disable, with a code | | GET | /jwks | none | { keys }: the signing key and each key retired less than 24 hours ago, public JWKs with kid, alg, and use: "sig"; cache-control: public, max-age=300. The first call writes the first key. Absent with jwtMint: false | | GET | /token | session (cookie or ts_ bearer) | { token }: a session JWT; 401 with no session, a tk_ bearer, or a JWT bearer; 500 hook_failed when jwtMint.claims throws | | POST | /operator/keys/rotate | Authorization: Operator <secret> | { kid }: a new signing key; the old one verifies for 24 hours and signs nothing; 401 unauthorized for a missing or wrong secret; 429 rate_limited after 5 calls per IP per hour (operator:ip:<ip>), right or wrong. Only with operator and jwtMint | | GET | /operator/secrets/status | Authorization: Operator <secret> | { versions }: for each version, configured, current, totpSecrets, backupCodes, signingKeys, emailCodes, ssoClientSecrets, and stateData, as api.secrets.status(); 401 unauthorized; 429 rate_limited after 120 calls per IP per hour (operator-secrets:ip:<ip>), one count with rewrap and info, right or wrong. Only with operator | | POST | /operator/secrets/rewrap | Authorization: Operator <secret>, { limit?, after?, callBudget? } (limit 1 to 1000, default 100; after the next of the last answer; callBudget the storage calls of the call, 50 to 1000, default 50); an empty body is {} | { resealed, failed, skipped, more, next }, as api.secrets.rewrap({ limit, after }); 400 invalid_body for another key, a limit outside the range, or a cursor that is not totp:<id>, jwk:<id>, or ssoConnection:<id>; 401 unauthorized; 429 rate_limited (operator-secrets:ip:<ip>). Only with operator | | GET | /operator/info | Authorization: Operator <secret> | { core, schemaVersion, configKeys }: the version of core, its schema version, and the sorted key paths of the config, names only, never a value; 401 unauthorized; 429 rate_limited (operator-secrets:ip:<ip>). Only with operator | | GET | /operator/users | Authorization: Operator <secret> with the scope users, or a platform operator's session, ?after=&limit= | { users, next }: the users by id, 1 to 100 per page; 401 unauthorized; 403 operator_required; 429 rate_limited. Only with operator.users | | GET | /operator/users/search | Authorization: Operator <secret> with the scope users, or a platform operator's session, one of ?email=, ?emailPrefix=, ?id= | { users, next }; a prefix search reads the whole user table. Only with operator.users | | GET | /operator/users/get | Authorization: Operator <secret> with the scope users, or a platform operator's session, ?userId= | { user }; 404 not_found. Only with operator.users | | POST | /operator/users/ban | Authorization: Operator <secret> with the scope users, or a platform operator's session, { userId, reason, until? } | { auditId }; ends every challenge, handoff code, and OAuth refresh token and code of the user, and the sessions that fit the call. The sweep ends the rest. Only with operator.users | | POST | /operator/users/unban | Authorization: Operator <secret> with the scope users, or a platform operator's session, { userId, reason } | { auditId }; restores no session. Only with operator.users | | POST | /operator/users/platform-role | Authorization: Operator <secret> with the scope users, or a platform operator's session, { userId, grant, reason } | { auditId }; a revoke ends the sessions of the user that fit the call, and the sweep or a second revoke ends the rest. Only with operator.users and organizations.platformRole | | POST | /operator/users/second-factor/disable | Authorization: Operator <secret> with the scope users, or a platform operator's session, { userId, reason, proof: { method, reference, checkedAt } } | { auditId }; ASVS 5.0.0 6.4.4. Only with operator.users | | POST | /operator/users/create-admin | Authorization: Operator <secret> with the scope users; a session caller gets 403 operator_required | { userId, created, auditId }. Only with operator.users and organizations.platformRole | | POST | /operator/users/create | Authorization: Operator <secret> with the scope users, or a platform operator's session, { email, phone?, emailVerified?, name?, image?, firstSignIn?, reason } | { userId, mailed, auditId }; email may be null with phone, and a phone beside a non-null email answers 400 invalid_body (ruling 12 of plan 12f2); mailed is null after a failed mail, and for an address of a domain that enforces SSO, which gets no link; firstSignIn invite, reset, or none; a strict body, so password and role answer 400 invalid_body; 409 email_taken or phone_taken to a caller with the scope only; 429 rate_limited after 200 calls of one actor per hour (operator-create:actor:<kind>:<id>). Only with operator.users | | POST | /operator/users/update | Authorization: Operator <secret> with the scope users, or a platform operator's session, { userId, name?, image?, reason } | { user, auditId }; a strict body, so password, email, and emailVerified answer 400 invalid_body; no mail. Only with operator.users | | POST | /operator/users/delete | Authorization: Operator <secret> with the scope delete, or a platform operator's session, { userId, reason } | { organizations, auditId }; 409 sole_owner; 409 delete_too_large on D1 only; 429 rate_limited after 100 calls of one actor per hour (operator-delete:actor:<kind>:<id>). Only with operator.users | | GET | /user/invite/confirm | ?token= | 200 HTML confirm page of the invitation link of a created user (plan 12f2); 302 to /?auth_error=invalid_token on a malformed token. No storage read, no limit, no cookie. Only with operator.users | | POST | /user/invite/confirm | form or JSON token, trustDevice? | As POST /magic-link/verify: a session with the via invite, or the challenge for a user with the second factor on (totp.gate.invite). It proves the address. 400 invalid_token (a wrong, spent, or expired link, or a user whose address changed); 403 account_banned, hook_refused, sso_required; 409 conflict; 429 rate_limited (user-invite-confirm:ip:<ip>, 20 per 15 minutes); 500 hook_failed. Only with operator.users | | POST | /operator/sessions/end-user | Authorization: Operator <secret> with the scope sessions, or a platform operator's session, { userId, reason } | { ended, more, auditId }; call again while more is true. Only with operator.users | | POST | /operator/sessions/end-all | Authorization: Operator <secret> with the scope sessions, or a platform operator's session, { reason, limit? } | { ended, more, auditId }; keeps the caller's own session; call again while more is true. Only with operator.users | | GET | /operator/audit | Authorization: Operator <secret> with the scope audit, or a platform operator's session, ?targetUserId=&after=&limit= | { rows, next }: the audit rows, oldest first. Only with operator.users | | POST | /operator/impersonate | session (cookie or ts_ bearer) of a platform operator who passes the operator user guard; { userId, reason } | { expiresAt, auditId }. The session cookie gets the new session's token, and <cookie name>_actor gets the operator's own token. Both get the Max-Age of the new session. A bearer caller gets { token, expiresAt, auditId } and no cookie. The new session has actorId, no fresh time, and a fixed expiry at operator.impersonation.ttlMinutes. Errors: 401 unauthorized (also with an operator secret) and 403 operator_required. The answer is 403 impersonation_refused for the operator, a platform operator, a banned user, or no user. The limit operator-impersonate:user:<userId> answers 429 rate_limited after 20 per hour. Only with operator.impersonation | | POST | /operator/impersonate/stop | the impersonation session; { reason? }, an empty body is {} | { auditId, restored }. It ends the session and clears the actor cookie. It puts the operator's token back in the session cookie while that session lives, else it clears the session cookie. A session that is not an impersonation gets 404 not_found. Only with operator.impersonation | | POST | /oauth/register | JSON client metadata (RFC 7591) | 201 { client_id, client_id_issued_at, client_name?, redirect_uris, token_endpoint_auth_method, grant_types, response_types, subject_type, id_token_signed_response_alg, dpop_bound_access_tokens }, with client_secret once for a secret client; 400 invalid_redirect_uri, invalid_client_metadata; 401 invalid_token without the initial access token; 429. Only with oauth and registration.dynamic | | GET | /oauth/authorize | the OAuth 2.1 parameters, PKCE S256, resource, scope, state, nonce, prompt, dpop_jkt? (RFC 9449 section 10: the exchange needs a proof of that key) | 302 to /oauth/sign-in with no session, with next back to ?request_id=oq_…, a request that core holds for 10 minutes; request_id alone shows the held request, and an unknown, spent, or expired one, or one that the consent page showed to another user, also with no session, answers 400 invalid_request JSON and spends nothing for that caller; 200 the consent page; 302 to the client with code, state, and iss when a consent covers the scopes; 302 with error for a bad request; 400 or 401 JSON with no redirect for a bad client or redirect URI; 429 | | POST | /oauth/authorize | the consent form: request_id and decision=allow or deny; the user the page showed the request to; session; Origin equal to baseURL | 302 to the client with code or error=access_denied; 400 invalid_request for a spent, expired, or another user's request; 401; 403 | | GET | /oauth/sign-in | ?next=<basePath>/oauth/authorize?… | the sign-in page, which lands back on next; 302 to <appURL>/?auth_error=invalid_request for another next | | POST | /oauth/token | A form. The code grant sends grant_type=authorization_code with code, code_verifier, client_id, redirect_uri, and resource?. The refresh grant sends grant_type=refresh_token with refresh_token, client_id, scope?, and resource?. A confidential client adds its secret as HTTP Basic or client_secret. A DPoP header with a proof binds the tokens to its key (RFC 9449). | { access_token, token_type, expires_in, scope, refresh_token?, id_token? }. After a proof, token_type is "DPoP" and the access token holds cnf.jkt. A public client's refresh token is then bound to the key. With no proof, token_type is "Bearer". 400 invalid_grant, invalid_target, invalid_scope, invalid_request, unsupported_grant_type, invalid_dpop_proof; invalid_client, 401 after an Authorization header and 400 with none; 429 | | POST | /oauth/revoke | form token, client_id?, client_secret?, or HTTP Basic (RFC 7009) | 200 {} for a token it revoked, an unknown token, and an access token. A refresh token's family goes. 400 unauthorized_client for a refresh token of another client, which stays. invalid_client for a failed client auth, and for a confidential client's refresh token with no auth. It is 401 after an Authorization header and 400 with none. 400 invalid_request for a body that is not a form. 429. | | POST | /oauth/introspect | form token, token_type_hint?, and the client auth of /oauth/token, by a confidential client with introspect: true (RFC 7662) | { active: true, scope, client_id, sub, aud, iss, exp, iat, jti, token_type, cnf? } for a live access token, and for a live refresh token of the caller. A DPoP-bound access token answers token_type: "DPoP" and cnf: { jkt }. { active: false } alone for every other token. invalid_client for any other caller: 401 after an Authorization header, 400 with none. 400 invalid_request without token. 429 | | GET, POST | /oauth/userinfo | Authorization: Bearer <access token> with openid, or Authorization: DPoP <bound token> with a proof in the DPoP header | { sub, email?, email_verified?, name?, picture? } by scope; 401 invalid_token; 401 invalid_dpop_proof for a bound token with no valid proof; 403 insufficient_scope. A bound token as a bearer gets 401. WWW-Authenticate names both schemes (RFC 9449 section 7.2) | | GET, POST | /oauth/end-session | id_token_hint?, client_id?, post_logout_redirect_uri?, state? in the query or a form (OIDC RP-Initiated Logout 1.0). logout_hint and ui_locales are ignored. The yes of the page is a POST of confirm=yes with Origin equal to baseURL | A POST that carries no session answers 303 to the GET of the same fields, without confirm. A cross-site POST carries no SameSite=Lax cookie, and the top-level GET does. A valid hint of the session that the request carries ends it at once, also an expired hint. With no valid hint of the session, 200 the confirmation page, and nothing ends until the yes. A redirect to an exact post_logout_redirect_uri of the hint's client, with state, only with a valid hint (302, or 303 for a POST); else 200 the signed-out page. 400 invalid_request for a repeated parameter; 429 | | GET | /.well-known/oauth-authorization-server, /.well-known/openid-configuration | none | the issuer's metadata, cache-control: public, max-age=300; also at the origin root through auth.wellKnown. /.well-known/oauth-protected-resource answers 404 here |

Without a passkey config none of these routes exist, and the router answers 404.

Without a password config none of the password routes exist, and the router answers 404. The token routes exist in every deployment.

Since plan 9f a user with the second factor on gets { twoFactor: { challenge, expiresAt, methods } } from POST /password/sign-in in place of the session, with no cookie. Send the challenge and a code to POST /totp/verify, or send the browser to GET /totp/challenge?challenge=. The sign-in also takes trustDevice (a native app's td_ token; a browser sends the trust cookie) and next (where the challenge page lands). Without password, or with totp: false, none of the TOTP routes exist. Since plan 12c the magic link, the email code sign-in, social, and the reset answer the same challenge, and the challenge lists its methods. A form flow goes to the challenge page.

With emailOtp: false none of the code routes exist, and the router answers 404. Without a password config the two reset code routes do not exist.

The organization routes follow.

| Method | Path | Body or query | Answer | | --- | --- | --- | --- | | POST | /organizations/create | session, { slug, name, metadata? } | { organization, member }; 400 invalid_body, slug_reserved; 401; 403 email_unverified; 409 slug_taken | | GET | /organizations | session | { organizations: [{ organization, role }] }; 401 | | POST | /organizations/check-slug | session, { slug } | { slug, status } with available, taken, reserved, or invalid (a null slug); 400 invalid_body; 401 (a tk_ bearer too); 403 email_unverified; 429 rate_limited at 60 per minute | | POST | /organizations/has-permission | session, { organizationId, permissions } | { success }, false for a non-member; 400 invalid_body; 401 (a token bearer too) | | GET | /organizations/permissions | session, ?organizationId= | { role, permissions }, role: null and {} for a non-member; 400; 401 (a token bearer too) | | POST | /organizations/update | session, { organizationId, name?, slug?, metadata? } | { organization }; 400 invalid_body, slug_reserved; 401; 403 forbidden_rank, email_unverified; 404; 409 slug_taken | | POST | /organizations/delete | session, { organizationId } | { ok: true }; 400 slug_reserved; 401; 403 forbidden_rank, email_unverified; 404; 409 conflict after 5 rounds lost to a set of the active organization | | GET | /organizations/members | session, ?organizationId= | { members }; 400 invalid_body; 401; 403 forbidden_rank; 404 | | POST | /organizations/members/add | session, { organizationId, userId, role } | { member }; 400; 401; 403 forbidden_rank, email_unverified; 404; 409 already_member | | POST | /organizations/members/role | session, { organizationId, userId, role } | { member }; 400; 401; 403 forbidden_rank, email_unverified; 404 not_found; 409 last_owner, conflict | | POST | /organizations/members/remove | session, { organizationId, userId, revokeTokens? } | { ok: true }; 400; 401; 403 forbidden_rank (with revokeTokens: true, also without apiToken:revoke), email_unverified, session_not_fresh (with revokeTokens: true only); 404 not_found; 409 last_owner, conflict | | POST | /organizations/invite | session, { organizationId, email, role } | { invitation } with no token; 400; 401; 403 forbidden_rank, email_unverified; 404 not_found; 429 rate_limited | | GET | /organizations/invitations | session, ?organizationId= | { invitations }; 400; 401; 403 forbidden_rank; 404 not_found | | POST | /organizations/invitations/revoke | session, { organizationId, invitationId } | { ok: true }; 400; 401; 403 forbidden_rank, email_unverified; 404 | | POST | /organizations/invitations/accept | session, { token } | { organization, member }; 400 invalid_token, token_expired; 401; 403 email_mismatch, email_unverified; 409 already_member; 429 rate_limited | | POST | /organizations/invitations/decline | { token }, no session | { ok: true }; 400 invalid_token, token_expired | | POST | /organizations/active | session, { organizationId } (a string or null) | { user, session } with session.activeOrganizationId; 401; 403 forbidden_rank | | GET | /organizations/roles | session, ?organizationId= | { roles }, by name, with no row of a bad shape; 400; 401; 403 forbidden_rank without ac:read. Only with organizations.dynamicRoles | | GET | /organizations/roles/get | session, ?organizationId=&name= | { role }; 400; 401; 403 forbidden_rank without ac:read; 404 | | POST | /organizations/roles/create | session (fresh), { organizationId, name, rank?, permissions } | { role }; 400 invalid_body (also a name of the config or the platform role, a rank above yours, or a rank at the owner rank), statement_not_grantable for permissions that name audit; 401; 403 forbidden_rank without ac:create or for a set wider than yours, session_not_fresh; 409 role_taken, role_in_use while a member or a pending invitation holds the name, role_limit | | POST | /organizations/roles/update | session (fresh), { organizationId, name, rank?, permissions? } | { role }; 400, also statement_not_grantable; 401; 403 forbidden_rank without ac:update, for a role above you, or for a set wider than yours, session_not_fresh; 404; 409 conflict | | POST | /organizations/roles/delete | session (fresh), { organizationId, name } | { ok: true }; 400; 401; 403 forbidden_rank without ac:delete or for a role above you, session_not_fresh; 404; 409 role_in_use | | GET | /organizations/teams | session, ?organizationId= | { teams }, by name; 400; 401; 403 forbidden_rank for a non-member. Only with organizations.teams | | POST | /organizations/teams/create | session, { organizationId, name } | { team }; 400; 401; 403 forbidden_rank without team:create, email_unverified, hook_refused; 409 team_limit; 500 hook_failed | | POST | /organizations/teams/update | session, { teamId, name } | { team }; 400; 401; 403 forbidden_rank without team:update, email_unverified, hook_refused; 404; 500 hook_failed | | POST | /organizations/teams/delete | session, { teamId } | { ok: true }; 400; 401; 403 forbidden_rank without team:delete, email_unverified, hook_refused; 404; 409 last_team with keepLastTeam, conflict after 5 rounds lost to a set of the active team; 500 hook_failed | | GET | /organizations/teams/members | session, ?teamId= | { members }; 400; 401; 403 forbidden_rank without member:read; 404 | | POST | /organizations/teams/members/add | session, { teamId, userId } | { member }; 400; 401; 403 forbidden_rank without member:update or for a person you may not touch, email_unverified, hook_refused; 404 for a person who is not a member; 409 already_member, team_member_limit, conflict; 500 hook_failed | | POST | /organizations/teams/members/remove | session, { teamId, userId } | { ok: true }; 400; 401; 403 forbidden_rank without member:delete for another person, or for a person you may not touch, email_unverified, hook_refused; 404; 500 hook_failed. A member leaves with their own userId | | POST | /organizations/teams/active | session, { teamId } (a string or null) | { user, session } with session.activeTeamId; 400; 401; 403 forbidden_rank with no active organization, for a team of another organization, or for a team that you are not in | | GET | /organizations/teams/mine | session | { teams }, the user's teams in every organization; 401 | | POST | /organizations/tokens | session (fresh), { organizationId, name, permissions, expiresInDays?, metadata? } | { token, apiToken }, the to_ token once; 400 invalid_body (also permissions: null, a window, or a quota); 401 (a token bearer too); 403 forbidden_rank without apiToken:create or for a set wider than yours, email_unverified, session_not_fresh; 404; 409 organization_token_limit at 50 live tokens; 429 rate_limited (the key of POST /tokens) | | GET | /organizations/tokens | session, ?organizationId= | { tokens }, newest first, each with createdById and creatorIsMember; 400; 401; 403 forbidden_rank without apiToken:read, email_unverified; 404 | | POST | /organizations/tokens/update | session (fresh), { organizationId, id, name?, permissions?, expiresAt? } | the token after the change; it narrows only, as POST /tokens/update; 400; 401; 403 forbidden_rank without apiToken:update, email_unverified, session_not_fresh; 404; 409 conflict | | POST | /organizations/tokens/revoke | session, { organizationId, id } | { ok: true }; 400; 401; 403 forbidden_rank without apiToken:revoke (the creator has no right of their own), email_unverified; 404 | | GET | /organizations/tokens/current | Authorization: Bearer to_… only | { organization, apiToken }, and one call of the quota spent; 401 for any other credential; 429 rate_limited, token_exhausted; 409 conflict |

Without an organizations config none of the organization routes exist, and the router answers 404.

With hooks (see "Hooks" below), every organization write and every sign-in can also answer 403 hook_refused (with message) and 500 hook_failed. With organizations.limits, create answers 409 organization_limit, add and accept answer 409 member_limit, and invite answers 409 invitation_limit. A sign-in whose session hook names an organization the user is not a member of answers 404 not_found.

Set appName in the config to name the app. It is 1 to 80 characters with no control character. The default is the host of baseURL. The default pages show it in the title and the heading. The magic link mail subject is Sign in to <appName>. The invitation mail subject is You are invited to <organization name> on <appName>. Each page function receives appName in its input.

The confirm page is defaultConfirmPage. Replace it with magicLink.confirmPage in the config. The function returns the markup only; core sets cache-control, referrer-policy, x-robots-tag, and a content security policy that permits inline style, no script, and a form post to this origin only. A page that needs script or a remote stylesheet needs its own route in the app, because the policy header is fixed.

Sessions

A use of a session after session.slidingRefreshDays moves its expiry forward by session.ttlDays, under the cap of session.absoluteDays. The refresh never moves freshAt.

session.deferRefresh: true (plan 12a, Better Auth's deferSessionRefresh) moves that write from a GET request to a POST. Use it when a GET reads from a replica or must not write.

  • A GET request writes no session row: no sliding refresh, and no delete of an ended row, which the sweep deletes later.
  • GET /session answers needsRefresh: true when the refresh is due, and it sends no renewed cookie.
  • POST /session/refresh slides the expiry, renews the cookie, and answers the session or 401, with the key on or off.

The key is off by default. With it on, a client that never posts the refresh lets an active session end at its old expiry. The client calls client.session.refresh(). In process, auth.api.session.refresh(token) does the same write.

Entries for SDKs

Four entries hold the facts that an SDK reads, so each fact has one copy (plans 11d, 11g, and 12k).

  • @authtempo/core/routes: ROUTES, every route that core can serve, with literal types. RoutePath<"GET"> is the type of a GET path that core serves, so a typo in an SDK's path fails its compile. It also exports PROVIDER_NAME_RE and AUTH_ERROR_PARAM (auth_error).
  • @authtempo/core/credentials: the prefixes ts_ and tk_, the JWT typ values JWT and at+jwt, DEFAULT_COOKIE_NAME (__Host-tempo_session), readBearer, readSessionToken, the compact JWS check on Web Crypto (decodeJws, verifyJws), and resourceOf, the rule that finds the resource a URL falls under.
  • @authtempo/core/access: the pure checks of permission statements (can, union, intersect, isSubset, effectiveOf, roleHasPermission, statementFault) and CORE_STATEMENTS. It imports nothing, so a browser bundle can use it. The server check decides; a client check only hides a control.
  • @authtempo/core/openapi: openApiDocument(options) builds the OpenAPI 3.1 document of the routes; openApiOptionsFrom(config) gives the options of a config, with only the features that it turns on. openapi: true serves the same document at GET <basePath>/openapi.json. The key is off by default.

@authtempo/core/testing still exports ROUTES for an app's own route tests.

@authtempo/core/bindings

A third entry, of a different kind: the gate of the framework bindings (plan 11d2). Each server binding fits it to its framework, so the rule has one copy.

  • readGate(options, request, routed?, returnTo?): the Gate of a page request. session is the session or null. redirect is the 307 to the sign-in page for a protected path with no session, or null. cookie is the renewed session cookie after the sliding refresh, or null. A path of core reads nothing, because auth.handle reads and renews the session itself. routed is the path that the framework's router matched, with the query: a string, or a URL object that the framework parsed. The gate uses its path for the base path check and the protect rule. It reads the cookie from request, and the origin of the redirect from request.url, so the redirect never leaves that origin. A binding that passes no routed gets the raw request.url, which is right only when the router matches the raw path. A fourth argument, returnTo, is the page URL for a request whose URL is not the page URL, such as SvelteKit's /account/__data.json or React Router's /account.data. next holds the path and the query of returnTo when given, else of a routed URL object, else of request.url. It never comes from a routed string, because a decoded text is not a safe next: /%2561ccount decodes to /%61ccount, which a browser opens as /account. The binding passes the text its router matched and, when the request URL is not the page URL, the page URL as returnTo. protect gets the path exactly as the router matched it. The gate does not change it: no resolution of . or .., no decoding, no encoding, no merge of slashes. Of a string the gate drops the fragment and splits the query at the first ?. A path with no leading / gets one, so no request throws. Of a URL object the gate takes pathname and search, as the framework parsed them. A router that decodes %3F or %23 into the path makes ? or # part of the path text. A binding of such a router passes the object form { pathname, search? } (the type RoutedPath), and the gate judges pathname as given, with no split at ? and no drop of #. The gate does not read its search, because next comes from returnTo or request.url, which hold the query. The string form keeps its split, for a router whose decode keeps %3F escaped. Each binding's README states how its router decodes the path and compares the case.
  • signInRedirect(url, signInPath): the 307 to signInPath, with next set to the path and the query of url. next gets one leading slash, and then the safeNext rule of core's own flows: a value with a backslash or a control character, or one that names another origin, becomes /. So next cannot name another origin. A query of signInPath stays.
  • withSetCookie(response, cookie): adds the cookie to the page's answer. An answer with fixed headers, such as one of Response.redirect, gets a copy.
  • checkGateOptions(options): a binding calls it at construction. It throws when protect has no signInPath, when signInPath is not a path of this origin (it must start with one /, not // or /\; the check reads the path with the URL parser that the redirect uses, so a tab, a newline, or a carriage return after the first / cannot make it another origin), and when basePath does not start with / or ends with /.
  • isAuthPath(pathname, basePath?): true for a path under the base path, not the base path itself. It answers false for a malformed base path ("", no leading /, or a / at the end), so a hand-made auth object with such a base path makes the gate judge every request as a page.
  • DEFAULT_BASE_PATH: "/auth", the default basePath of core.
  • The types GateOptions (auth, protect, signInPath, basePath), GateAuth (handle, session, sessionCookie, and the optional basePath and baseURL), Gate, and RoutedPath (pathname, optional search).

The gate reads the base path from auth.basePath, the resolved basePath of the config, so an app names it once. auth.baseURL is the resolved baseURL. A binding that builds the request URL from the Host header uses new URL(auth.baseURL).origin when that header does not parse, so a bad Host gets no 500 of the binding's own. GateAuth has baseURL as an optional member, beside basePath, so a binding typed on it can read it.

The base path check trusts the router: a path under the base path reads no session and gets no redirect, because core answers it. So a binding mounts core for every method under the base path. A binding that mounts core for some methods only lets a catch-all page under the base path run with no gate, and the check is then no control. The basePath option of the gate is for a proxy that mounts core under another prefix.

The gate skips the session read and the protect rule only when the raw path of request.url and the routed path are both under the base path. When only one of them is, the gate judges the request as a page. A binding sends a request to auth.handle by the raw path of request.url, which is the path that core's router reads. A binding that sends a request to core when only the decoded path is under the base path gets a 404 from core, not a page.

Apps on another origin

Set appURL to the app's origin and list it in trustedOrigins. Every redirect after a sign-in then lands on appURL plus next, and errors go to appURL/?auth_error=<code>. A next under basePath stays on baseURL; that is how the handoff rides through a sign-in.

A trusted origin gets credentialed CORS: the router answers its preflight with 204 and marks every response with Access-Control-Allow-Origin and Access-Control-Allow-Credentials. The browser still needs the session cookie on the request. With the default SameSite=Lax the cookie goes on every same-site request, so an app on a sibling subdomain of the API works as is. An app on another site needs cookie: { sameSite: "None" }; then any site can make the browser send the cookie, and the Origin rule on POST is what refuses them. The session cookie is __Host-tempo_session and the binding cookie is __Secure-tempo_session_oauth (plan 12b).

Every POST also passes the Fetch Metadata rule. A form post (a form, multipart, text/plain, or no content type) needs Sec-Fetch-Site to be same-origin or none. A JSON post from another site (cross-site or same-site) needs a trusted Origin. A request with no Sec-Fetch-Site passes. A refusal answers 403 origin_not_trusted. Apple's callback skips both rules: Apple posts it from its own site.

A list of hosts

baseURL takes a list of 1 to 20 exact origins (plan 12i Task 18). Each is https:, or http: on localhost or 127.0.0.1, in the normal form of the URL parser. The router picks the entry equal to the origin of request.url, and answers 421 host_not_allowed to any other host before any handler. Core never reads x-forwarded-host or forwarded.

The issuer, the metadata documents, the mail links, the social callback, the failure redirect, the default appURL, the Origin check, and the default jwtMint.audience follow the picked entry. A session JWT of any entry verifies on each entry. An OAuth code or a held authorize request answers invalid_grant, or is not found, on another entry. Outside a request, core uses the first entry. A baseURL string serves any host, as before.

Handoff for native and desktop apps

Set handoff: { schemes: ["consumera://"] }. The app makes a PKCE verifier and its S256 challenge, then opens the system browser at GET /auth/handoff/start?challenge=<c>&redirect=consumera://auth. Core shows the sign-in page: a magic link form, the configured social buttons, a passkey button, and, with a password config, an email and password form with a Forgot password button. With a password config the form also has a Create account button. It posts the email and the password to POST /auth/password/sign-up; that answer sets the session cookie, and the page goes on to the continue path. Every method ends by visiting /auth/handoff/continue?h=<id> on the API origin, which shows a confirm page. When the person presses the button, core mints a one-time code and redirects to consumera://auth?code=<code>. The app then calls POST /auth/handoff/redeem { code, verifier } and keeps the bearer token. A code lives two minutes and redeems once; a start lives ten minutes, or as long as a magic link if that is longer.

The continue is a consent step. A signed-in browser sees a page that names the account and the app, and the code is minted only when the person presses the button. The post is accepted from the API origin only.

In development devRedirectPattern admits a full redirect URL, for example /^exp:\/\/[\d.]+:\d+\/--\/auth$/ for Expo Go. Core refuses a pattern with the g or y flag, and refuses any admitted http or https URL that is not on a loopback host.

The handoff confirm page adds the source of the matched dev redirect to form-action: its scheme (exp:), or the origin of a loopback URL (http://127.0.0.1:8081). A dev redirect on [::1] cannot be listed. Use 127.0.0.1.

signInPage replaces the page. The function gets the base path, the continue path, the enabled methods, and the script nonce. It must put the nonce on its script tag. The methods input has the flags magicLink, google, apple, passkey, and password, and providers, a list of { name, label } for every configured provider other than Google and Apple. password is true when the config has a password section. A custom signInPage must render methods.providers, or the buttons for GitHub, LinkedIn, and the list providers do not show. @authtempo/handoff (plan 5b) does the app side.

Social sign-in

Configure social.google with { clientId, clientSecret } and social.apple with { clientId, teamId, keyId, privateKey }. The Apple clientId is the Services ID, and privateKey is the PKCS#8 PEM from the developer portal. Core signs a five-minute Apple client secret on every token exchange, so nothing stored expires. Rotate the key in the portal and change privateKey.

Register <baseURL><basePath>/social/<provider>/callback as the redirect URI at the provider. The flow sends state, a PKCE S256 challenge, and, for an OpenID Connect provider, nonce. Apple's support for PKCE is unverified; the state, the nonce, and the binding cookie bind the exchange without it. Core sends the client secret in the token request body (client_secret_post). A provider that expects client_secret_basic answers invalid_client.

Linking: a social identity links to an existing user only when the provider reports the email as verified and it equals the user's email. A signed-in user links a provider with POST /social/:provider/link (see "Account"). Otherwise core creates a new user, or answers email_taken_unverified when the address is in use. A profile with no email answers email_required.

An account created through an unverified email is a claim. When a sign-in proves the address (a magic link, or a provider that reports the email verified), core first holds the user row or takes a lease of the claim. Then it deletes that user's other identities, password rows, and passkeys. Then it marks the email verified, and last it deletes every session. The claimant loses those ways in, and the owner keeps the account. A session of the claimant was made before the proof, so it holds no verified power.

GitHub and LinkedIn are presets: social.github and social.linkedin each take { clientId, clientSecret }. GitHub issues no ID token, so core reads GET https://api.github.com/user and GET https://api.github.com/user/emails with the access token, under the scope read:user user:email. The subject is the numeric GitHub id. The address counts as verified only when the primary address has verified: true. A person whose primary address is unverified gets a new unverified account, or email_taken_unverified when the address has an account. Core never links it. LinkedIn: core reads GET https://api.linkedin.com/v2/userinfo with the access token, under the scope openid profile email, as Better Auth does. The subject is LinkedIn's sub. Core ignores LinkedIn's ID token. Add the product "Sign In with LinkedIn using OpenID Connect" to the LinkedIn app.

Any other provider is a list entry. social.oidc takes OpenID Connect providers, and social.oauth2 takes providers that issue no ID token. A name matches ^[a-z][a-z0-9-]{0,31}$, is unique across both lists, and is not a preset name, email, or credential. The preset names are google, apple, github, linkedin, microsoft, discord, gitlab, slack, twitter, and facebook. The label is the button text on the sign-in page. An oidc entry reads <issuer>/.well-known/openid-configuration on its first start and keeps the endpoints for the life of the createAuth instance. The document's issuer must equal issuer exactly. Set endpoints and core never reads the document, so a sign-in does not depend on the provider's discovery at request time.

social: {
  github: { clientId: env.GITHUB_CLIENT_ID, clientSecret: env.GITHUB_CLIENT_SECRET },
  oidc: [
    {
      name: "entra",
      label: "Continue with Microsoft",
      issuer: `https://login.microsoftonline.com/${env.ENTRA_TENANT_ID}/v2.0`,
      clientId: env.ENTRA_CLIENT_ID,
      clientSecret: env.ENTRA_CLIENT_SECRET,
    },
  ],
  oauth2: [
    {
      name: "discord-app",
      label: "Continue with Discord",
      authorizeUrl: "https://discord.com/oauth2/authorize",
      tokenUrl: "https://discord.com/api/oauth2/token",
      clientId: env.DISCORD_CLIENT_ID,
      clientSecret: env.DISCORD_CLIENT_SECRET,
      scope: "identify email",
      async userinfo(accessToken, fetch) {
        const res = await fetch("https://discord.com/api/users/@me", {
          headers: { authorization: `Bearer ${accessToken}` },
        });
        if (!res.ok) throw new Error(`discord answered ${res.status}`);
        const u = (await res.json()) as {
          id: string;
          email?: string | null;
          verified?: boolean;
          global_name?: string | null;
        };
        return {
          subject: u.id,
          email: u.email ?? null,
          emailVerified: u.verified === true,
          name: u.global_name ?? null,
          image: null,
        };
      },
    },
  ],
},

The Entra and Discord entries are examples. Core does not test them. The names microsoft and discord belong to the presets social.microsoft and social.discord. Check each endpoint and claim in the provider's documentation on the day you configure it. Microsoft Entra ID sends no email_verified claim by default, so an Entra sign-in never links to an existing account by its address.

An oauth2 entry with a token exchange of its own sets tokenRequest. Core runs it after the state and binding checks, with a fetch that calls only tokenUrl, and checks its { accessToken, extra } answer. userinfo gets extra as its third argument. authorizeClientIdParam, authorizeSuffix, and pkce: false shape the authorize URL. An entry with addressless: true gets no address from its profile: core finds or makes the user by the identity alone. @authtempo/core/social-entries gives two such entries, tiktokEntry({ clientKey, clientSecret }) and wechatEntry({ appId, appSecret }).

userinfo gets the access token and a fetch. Call the provider with that fetch: core puts a 10 s limit on it, and the whole step stops at 10 s. Answer emailVerified: true only when the provider says that this person proved the address. Core counts no other value as verified. Core never stores or logs the access token, and a failure logs the error name, never its message.

social.fetch and jwt exist for tests: inject a fetch for the token endpoint and a fake verifier, so no test reaches a provider.

With social.stateData: {} (off by default), the start and the link start take data: the base64url of a UTF-8 JSON object of at most 1024 bytes and a depth of 4. The state row holds it sealed, and the callback gives it to hooks.session.afterCreate and hooks.identity.afterLink as stateData. The browser sent it, so never trust it.

The ID-token route (plan 12i) serves Google One Tap and the native Apple sheet. It is on while google or apple is set; social.idToken: false turns it off. The app asks POST /social/<provider>/id-token/nonce for a nonce. It gives providerNonce, the SHA-256 hex of the nonce, to the provider, and keeps the raw nonce. Then it posts the ID token with the raw nonce to POST /social/<provider>/id-token. The token's nonce claim must be the hash of the posted nonce. While requireNonce is on, a party that holds only the token sees the hash, so it cannot post the nonce. With social.idToken.requireNonce: false, a token posted with no nonce skips the hash check, except an Apple token with nonce_supported true. So a party that holds only such a token can sign in before the app. Only the one-use row of the token then stops a second use. Core verifies the token against the provider's key set, and then spends the nonce once. The aud must be clientId or an entry of audiences, the list of the app's native client ids. A row for each token bars a second use on every instance. The account rules, the gate, and the anonymous upgrade are those of the callback.

Passkeys

Set passkey: { rpID, rpName, origins }. rpID is the registrable domain the credentials bind to, and every origin in origins must be on it (the host equals it or ends with .<rpID>). Registration needs a session and a verified email. Sign-in uses a discoverable credential, so the options carry no credential list, and both ceremonies require user verification. Every origin in origins must also be baseURL or in trustedOrigins, or the router refuses its posts; resolveConfig checks this.

The browser side is navigator.credentials.create(options) and navigator.credentials.get(options) with the options JSON from the routes (through PublicKeyCredential.parseCreationOptionsFromJSON and parseRequestOptionsFromJSON), and the credential's toJSON() goes back as response. Plan 5's client package wraps this.

@authtempo/core/testing exports SoftAuthenticator, a software authenticator on Web Crypto that produces both responses, so an app's tests prove the whole flow without a browser.

The passkey name rule (plan 12a): a name is a string of 1 to 64 code units, under the character rule of a user name (see "Account"). A bidi override or a zero-width space must not make one passkey read as another in a device list. The rename refuses a name that breaks the rule. The registration never refuses a credential for its name, because the device has made the credential by then. It stores a name that is blank after the trim, or that breaks the rule, as no name. The rename (POST /passkeys/rename, api.renamePasskey) needs a session, not a fresh session. It sends no notice, because a name is not a credential. The id of another user's passkey answers not_found, as an unknown id does, by the same calls. Its limit is passkey-rename:user:<userId> (see "Account").

The passkey extensions (plan 12i): passkey.extensions asks for credProps, prf, and largeBlob at the registration, and stores the fl