Credentials.ts overview
A thin Effect wrapper over BetterAuth’s own sign-up, sign-in and sign-out. It promises nothing of the core’s AuthLifecycleService: verification, second factors and hooks are BetterAuth’s.
Since v0.1.0
Exports Grouped by Category
models
CredentialResult (type alias)
A sign-in or sign-up’s answer, with the Set-Cookie lines BetterAuth set (its signed session cookie, or the two-factor cookie) for the response:
signed-in: BetterAuth issued a session.pending-verification: a sign-up that issued no session, because BetterAuth waits for the email to be verified. UnderrequireEmailVerificationBetterAuth answers a sign-up for a taken address the same way, so the answer reveals nothing.second-factor: a sign-in that BetterAuth’stwoFactor()plugin holds for the second factor ({ twoFactorRedirect: true }); it carries no user.
Signature
type CredentialResult =
| {
readonly status: "signed-in" | "pending-verification"
readonly user: Auth.Types.User
readonly setCookie: ReadonlyArray<string>
}
| { readonly status: "second-factor"; readonly setCookie: ReadonlyArray<string> }
Since v0.1.0
RequestInput (interface)
The inputs every call takes: the incoming request’s headers, which BetterAuth reads for the client’s address, its rate limits and, on sign-out, the session cookie.
Signature
export interface RequestInput {
readonly headers: Headers
}
Since v0.1.0
services
BetterAuthCredentials (class)
BetterAuth’s sign-up, sign-in and sign-out as Effects, with APIError mapped into the typed error channel (InvalidCredentialsError, EmailInUseError, EmailNotVerifiedError, else AuthError).
Signature
declare class BetterAuthCredentials
Since v0.1.0