Skip to content

API reference

auth(options) creates a Layeron Auth module for sessions, route user context, and managed or custom user storage.

Terminal window
import { auth } from "@layeron/modules"

Create a Layeron Auth module.

Terminal window
auth(options?: AuthModuleOptions): AuthModule

Cookie settings for Auth sessions.

FieldTypeDescription
namestring | undefinedCookie name used when session mode is cookie or both.

Session settings for Auth.

FieldTypeDescription
modeAuthSessionMode | undefinedToken transport mode. Defaults to both.
accessTokenTtlstring | undefinedAccess token lifetime. Use an integer followed by s, m, h, or d. Defaults to 15m.
refreshTokenTtlstring | undefinedRefresh token lifetime. Use an integer followed by s, m, h, or d. Defaults to 30d.
refreshTokenRotationboolean | undefinedWhen true, refreshSession rotates the refresh token on every successful refresh. Defaults to true.
reuseDetectionboolean | undefinedWhen true, Auth detects reuse of revoked, replaced, expired, or reused refresh tokens. Defaults to true.
revokeFamilyOnReuseboolean | undefinedWhen true, Auth revokes the refresh token family after reuse is detected. Defaults to true.
cookieAuthSessionCookieOptions | undefinedCookie settings.

Password strength settings for email sign-up.

FieldTypeDescription
enabledboolean | undefinedEnable email and password sign-up, sign-in, password update, and password reset flows. Defaults to true.
minLengthint32 | undefinedMinimum password length. The value must be at least 8. Defaults to 8.
requireLowercaseboolean | undefinedRequire at least one lowercase letter.
requireUppercaseboolean | undefinedRequire at least one uppercase letter.
requireNumberboolean | undefinedRequire at least one number.
requireSymbolboolean | undefinedRequire at least one symbol.
hashAuthPasswordHashOptions | undefinedPassword hash algorithm and cost settings. Defaults to Argon2id with the balanced security level.

Password hash settings.

FieldTypeDescription
algorithmAuthPasswordHashAlgorithm | undefinedHash algorithm. Defaults to argon2id.
levelAuthPasswordHashLevel | undefinedSecurity preset. Defaults to balanced.
argon2idAuthArgon2idPasswordHashOptions | undefinedArgon2id cost settings.
pbkdf2Sha256AuthPbkdf2Sha256PasswordHashOptions | undefinedPBKDF2-SHA256 cost settings.

Argon2id password hash settings.

FieldTypeDescription
memoryKiBint32 | undefinedMemory cost in KiB. Defaults to 32768 at the balanced level.
iterationsint32 | undefinedTime cost measured in Argon2 iterations. Defaults to 2 at the balanced level.
parallelismint32 | undefinedArgon2 parallelism parameter. Defaults to 1 for Workers.
saltBytesint32 | undefinedRandom salt length in bytes. Defaults to 16.
hashBytesint32 | undefinedDerived hash length in bytes. Defaults to 32.
maxMemoryKiBint32 | undefinedMaximum temporary memory budget in KiB. Defaults to at least twice memoryKiB.
asyncTickMsint32 | undefinedMaximum scheduler block time in milliseconds for async hashing. Defaults to 10.

PBKDF2-SHA256 password hash settings.

FieldTypeDescription
iterationsint32 | undefinedPBKDF2 iteration count. Defaults to 600000.
saltBytesint32 | undefinedRandom salt length in bytes. Defaults to 16.
hashBytesint32 | undefinedDerived hash length in bytes. Defaults to 32.

OTP verification settings for email sign-up.

FieldTypeDescription
enabledboolean | undefinedEnable this email OTP flow. Defaults to true.
requiredboolean | undefinedWhen true, sign-up sends an OTP and creates a session only after verification.
lengthint32 | undefinedNumber of OTP digits. Defaults to 6.
tokenLengthint32 | undefinedNumber of OTP digits. This aliases length for TypeScript users.
ttlstring | undefinedOTP lifetime. Use an integer followed by s, m, h, or d. Defaults to 10m.
minSendIntervalstring | undefinedMinimum time before Auth sends another email for the same active OTP flow. Use an integer followed by s, m, h, or d. Defaults to 1m.
maxAttemptsint32 | undefinedMaximum failed verification attempts before the OTP is exhausted. Defaults to 5.
templateunknown | undefinedEmail template name or Email template object used for this OTP message.

Remember-device settings for password sign-in with email OTP.

FieldTypeDescription
enabledboolean | undefinedWhen true, verified sign-in OTP requests can return a remember token.
ttlstring | undefinedRemember token lifetime. Use an integer followed by s, m, h, or d. Defaults to 30d.

Email OTP settings for password sign-in.

FieldTypeDescription
rememberAuthRememberOptions | undefinedRemember-device settings for password sign-in OTP.

Password sign-in settings.

FieldTypeDescription
emailOtpAuthSignInEmailOtpOptions | undefinedEmail OTP settings for password sign-in. Set required to true to require OTP after the password check.

Email OTP settings for password updates.

FieldTypeDescription

Password update settings.

FieldTypeDescription
requireCurrentPasswordboolean | undefinedWhen true, updatePassword requires the current password before changing the password. Defaults to true.
emailOtpAuthPasswordUpdateEmailOtpOptions | undefinedEmail OTP settings for password updates. Set required to true to require OTP before changing the password.

Password reset token settings.

FieldTypeDescription
ttlstring | undefinedPassword reset token lifetime. Use an integer followed by s, m, h, or d. Defaults to 10m.
maxAttemptsint32 | undefinedMaximum failed verification attempts before the reset token is exhausted. Defaults to 5.

Password reset email settings.

FieldTypeDescription
templateunknown | undefinedEmail template name or Email template object used for password reset messages.
minSendIntervalstring | undefinedMinimum time before Auth sends another password reset email for the same active reset flow. Use an integer followed by s, m, h, or d. Defaults to 1m.
tokenAuthPasswordResetTokenOptions | undefinedReset token settings.

Passkey relying party settings.

FieldTypeDescription
idstring | undefinedRelying party id. Defaults to the request host.
namestring | undefinedRelying party display name. Defaults to Layeron App.
originsstring[] | undefinedAllowed WebAuthn origins. Defaults to the current request origin.

Passkey login settings.

FieldTypeDescription
enabledboolean | undefinedEnable passkey sign-in. Defaults to true when passkeys are enabled.
allowUsernamelessboolean | undefinedAllow usernameless passkey sign-in with discoverable credentials. Defaults to true.

Passkey MFA settings.

FieldTypeDescription
requireUserVerificationboolean | undefinedRequire user verification for passkey MFA and step-up ceremonies. Defaults to true.

Passkey registration, login, and MFA settings.

FieldTypeDescription
enabledboolean | undefinedEnable Passkey/WebAuthn registration and authentication. Defaults to false.
relyingPartyAuthPasskeyRelyingPartyOptions | undefinedRelying party settings.
userVerificationPasskeyUserVerification | undefinedUser verification policy for registration and login. Defaults to preferred.
residentKeyPasskeyResidentKey | undefinedResident key policy. Defaults to preferred.
authenticatorAttachmentPasskeyAuthenticatorAttachment | undefinedAuthenticator attachment policy. Defaults to any.
attestationPasskeyAttestation | undefinedAttestation conveyance preference. Defaults to none.
timeoutMsint32 | undefinedCeremony timeout in milliseconds. Defaults to 60000.
loginAuthPasskeyLoginOptions | undefinedPasskey login settings.
mfaAuthPasskeyMfaOptions | undefinedPasskey MFA settings.

Built-in OAuth provider configuration.

FieldTypeDescription
provider”github” | “google”Built-in provider kind.
clientIdstring | undefinedOAuth client id issued by the provider.
clientSecretstring | undefinedOAuth client secret issued by the provider.
scopesstring[] | undefinedOAuth scopes requested during authorization.
stateTtlstring | undefinedState lifetime for authorization requests. Use an integer followed by s, m, h, or d. Defaults to 10m.
redirectToAllowliststring[] | undefinedAbsolute post-login redirect origins or relative paths accepted for redirectTo.

OpenID Connect provider configuration.

FieldTypeDescription
provider”oidc”Provider kind.
idstringStable provider id used in auth.oauth.createAuthorizationUrl and auth.oauth.verifyCallback.
issuerstringOIDC issuer URL. The discovery document issuer must match this value.
clientIdstringOIDC client id issued by the provider.
clientSecretstring | undefinedOIDC client secret issued by the provider when the token endpoint uses a confidential client.
scopesstring[] | undefinedOIDC scopes requested during authorization. Defaults to openid, email, and profile.
tokenEndpointAuthMethodAuthOAuthTokenEndpointAuthMethod | undefinedToken endpoint authentication method. Defaults to client_secret_basic when clientSecret is set, and none otherwise.
stateTtlstring | undefinedState and PKCE verifier lifetime. Use an integer followed by s, m, h, or d. Defaults to 10m.
redirectToAllowliststring[] | undefinedAbsolute post-login redirect origins or relative paths accepted for redirectTo.
userIdClaimstring | undefinedClaim used as the application user id for custom, mapped, and external user storage. Defaults to sub.
emailClaimstring | undefinedClaim used as the email address. Defaults to email.
emailVerifiedClaimstring | undefinedClaim used as the email verification flag. Defaults to email_verified.
displayNameClaimstring | undefinedClaim used as the display name. Defaults to name.
avatarUrlClaimstring | undefinedClaim used as the avatar URL. Defaults to picture.
usernameClaimstring | undefinedClaim used as the username. Defaults to preferred_username.

Email settings for Auth sign-up.

FieldTypeDescription
productunknownEmail product used to send sign-up messages.
templateunknown | undefinedEmail template name or Email template object used for sign-up messages.
otpAuthEmailOtpOptions | undefinedOTP verification settings.

Managed user id settings.

FieldTypeDescription
idPrefixstring | undefinedPrefix used when Auth generates a managed user id. Defaults to user.

Fully managed Auth database mode.

FieldTypeDescription
mode”managed” | undefinedFully managed user and session storage.

Managed core Auth database mode.

FieldTypeDescription
mode”managed_core”Core user fields and session storage.

Custom user store functions.

FieldTypeDescription
mode”custom”Custom user lookup with Auth-managed sessions.
getUserunknownFunction that resolves a user by id.
createUserunknown | undefinedFunction that creates an application-owned user for email sign-up.
isUserEnabledunknown | undefinedFunction that decides whether a resolved user can use a session.
updateLastSignInunknown | undefinedFunction called after Auth creates a session.
updateEmailVerifiedAtunknown | undefinedFunction called after Auth verifies an email OTP.

Mapped user table fields in a user-owned Database product.

FieldTypeDescription
tablestringTable that stores application user profiles.
idColumnstringColumn that stores the stable user id.
emailColumnstring | undefinedColumn that stores the user’s email address.
phoneColumnstring | undefinedColumn that stores the user’s phone number.
usernameColumnstring | undefinedColumn that stores the username.
displayNameColumnstring | undefinedColumn that stores the display name.
avatarUrlColumnstring | undefinedColumn that stores the avatar URL.
metadataColumnstring | undefinedColumn that stores JSON metadata for subject attributes.
createdAtColumnstring | undefinedColumn that stores the created timestamp.
updatedAtColumnstring | undefinedColumn that stores the updated timestamp.

Mapped Auth database mode.

FieldTypeDescription
mode”mapped”Application user profiles live in this Database product.
productunknownDatabase product instance that owns the mapped user table.
usersAuthMappedUsersOptionsMapped user table and column names.

External Auth database mode.

FieldTypeDescription
mode”external”Application user profiles are resolved outside Auth.
resolveUserunknownFunction that resolves a user profile by id.

Options accepted by auth(options).

FieldTypeDescription
namestring | undefinedStable Auth instance name. Defaults to default.
namespacestring | undefinedPlatform namespace for the instance. Defaults to default.
databaseAuthManagedDatabaseOptions | AuthManagedCoreDatabaseOptions | AuthCustomDatabaseOptions | AuthMappedDatabaseOptions | AuthExternalDatabaseOptions | undefinedDatabase storage mode.
emailAuthEmailOptions | undefinedEmail product and template settings for email sign-up.
passwordAuthPasswordOptions | undefinedPassword strength settings for email sign-up.
signInWithPasswordAuthSignInWithPasswordOptions | undefinedPassword sign-in settings.
updatePasswordAuthUpdatePasswordOptions | undefinedPassword update settings.
resetPasswordForEmailAuthResetPasswordForEmailOptions | undefinedPassword reset email settings.
passkeyAuthPasskeyOptions | undefinedPasskey/WebAuthn registration, login, and MFA settings.
providersAuthBuiltInOAuthProviderOptions | AuthOidcProviderOptions[] | undefinedOAuth and OIDC providers available to this Auth instance.
usersAuthManagedUsersOptions | undefinedManaged user id settings.
sessionAuthSessionOptions | undefinedSession settings.
observabilityLayeron.Observability.ObservabilityConfig | undefinedObservability settings for the Auth Product Worker.

Core user fields available in every Auth user result.

FieldTypeDescription
idstringStable Auth user id.
emailstring | undefinedPrimary email address for the user.
emailVerifiedAtstring | undefinedISO timestamp recorded when the primary email address was verified.
phonestring | undefinedPrimary phone number for the user.
phoneVerifiedAtstring | undefinedISO timestamp recorded when the primary phone number was verified.
primaryIdentityIdstring | undefinedPrimary identity id associated with the user.
usernamestring | undefinedApplication username associated with the user.
displayNamestring | undefinedDisplay name shown for the user.
avatarUrlstring | undefinedAvatar image URL for the user.
statusAuthUserStatus | undefinedCurrent user status.
createdAtstring | undefinedISO timestamp recorded when the user was created.
updatedAtstring | undefinedISO timestamp recorded when the user was last updated.
lastSignInAtstring | undefinedISO timestamp recorded when the user last completed sign-in.
disabledAtstring | undefinedISO timestamp recorded when the user was disabled.

Auth user returned by managed or custom user storage.

FieldTypeDescription
defaultTenantIdstring | undefinedDefault tenant id attached to the user.
isAnonymousboolean | undefinedWhether the user was created as an anonymous user.
rolesstring[] | undefinedRole names attached to the user.
scopesstring[] | undefinedPermission scopes attached to the user.
attributesRecord<unknown> | undefinedSubject attributes exposed to Policy and route context.
appMetadataRecord<unknown> | undefinedApplication-controlled metadata for server-side decisions.
userMetadataRecord<unknown> | undefinedUser-editable metadata stored with the user profile.

User fields accepted when creating a managed session.

FieldTypeDescription
idstring | undefinedStable user id used for the new session.
emailstring | undefinedPrimary email address for the session user.
emailVerifiedAtstring | undefinedISO timestamp proving the email address was verified.
phonestring | undefinedPrimary phone number for the session user.
phoneVerifiedAtstring | undefinedISO timestamp proving the phone number was verified.
primaryIdentityIdstring | undefinedPrimary identity id associated with the session user.
usernamestring | undefinedApplication username associated with the session user.
displayNamestring | undefinedDisplay name shown for the session user.
avatarUrlstring | undefinedAvatar image URL for the session user.
statusAuthUserStatus | undefinedUser status to store or verify for the session user.
defaultTenantIdstring | undefinedDefault tenant id attached to the session user.
isAnonymousboolean | undefinedWhether the session user is anonymous.
rolesstring[] | undefinedRole names attached to the session user.
scopesstring[] | undefinedPermission scopes attached to the session user.
attributesRecord<unknown> | undefinedSubject attributes exposed to Policy and route context.
appMetadataRecord<unknown> | undefinedApplication-controlled metadata for server-side decisions.
userMetadataRecord<unknown> | undefinedUser-editable metadata stored with the user profile.

User fields accepted by auth.signUp().

FieldTypeDescription
usernamestring | undefinedApplication username to store on the new user.
displayNamestring | undefinedDisplay name to store on the new user.
avatarUrlstring | undefinedAvatar image URL to store on the new user.
defaultTenantIdstring | undefinedDefault tenant id to attach to the new user.
rolesstring[] | undefinedRole names to attach to the new user.
scopesstring[] | undefinedPermission scopes to attach to the new user.
attributesRecord<unknown> | undefinedSubject attributes exposed to Policy and route context.
appMetadataRecord<unknown> | undefinedApplication-controlled metadata for server-side decisions.
userMetadataRecord<unknown> | undefinedUser-editable metadata stored with the user profile.

Input accepted by auth.signUp().

FieldTypeDescription
emailstringEmail address used to create the password identity.
passwordstringPlain-text password to validate and hash for the new identity.
userAuthSignUpUserInput | undefinedOptional user profile fields for managed and custom user storage.

Email verification state returned by auth.signUp().

FieldTypeDescription
requiredbooleanWhether the caller must complete email OTP verification before a session is issued.
idstring | undefinedVerification challenge id used when verifying the OTP.
emailstringEmail address being verified.
expiresAtstring | undefinedISO timestamp when the verification challenge expires.
emailMessageIdstring | undefinedEmail Product message id returned for the verification email.

Result returned by auth.signUp().

FieldTypeDescription
userAuthUserUser created or resolved by sign-up.
verificationAuthEmailVerificationResultEmail verification state for the sign-up flow.
accessTokenstring | undefinedAccess token issued when verification is complete.
sessionAuthSession | undefinedSession issued when verification is complete.
setCookiestring | undefinedSet-Cookie header value when the session mode writes cookies.

Auth session record.

FieldTypeDescription
idstringStable session id.
userIdstringUser id that owns the session.
createdAtstringISO timestamp recorded when the session was created.
expiresAtstringISO timestamp when the access session expires.
lastUsedAtstring | undefinedISO timestamp recorded when the session was last used.
revokedAtstring | undefinedISO timestamp recorded when the session was revoked.
deviceAuthSessionDevice | undefinedDevice metadata stored with the session.

Session device metadata.

FieldTypeDescription
idstring | undefinedStable device id supplied by the application.
namestring | undefinedHuman-readable device name supplied by the application.
ipHashstring | undefinedHash of the client IP address.
userAgentHashstring | undefinedHash of the client user agent.

Input accepted by auth.verifyEmailOtp().

FieldTypeDescription
emailstringEmail address being verified.
otpstringOne-time password sent to the email address.
verificationIdstring | undefinedVerification challenge id returned by sign-up.

Result returned by auth.createSession().

FieldTypeDescription
accessTokenstringBearer access token for the session.
refreshTokenstring | undefinedRefresh token for the session when refresh tokens are enabled.
sessionAuthSessionSession record created by Auth.
userAuthUserUser that owns the session.
setCookiestring | undefinedSet-Cookie header value when the session mode writes cookies.

Result returned by auth.verifyEmailOtp().

FieldTypeDescription
emailVerifiedAtstringISO timestamp recorded when the email address was verified.

Input accepted by auth.signInWithPassword().

FieldTypeDescription
emailstringEmail address for the password credential.
passwordstringPlain-text password to verify.
rememberTokenstring | undefinedRemember-device token returned by a prior sign-in OTP verification.

Result returned by auth.signInWithPassword().

FieldTypeDescription
userAuthUserUser resolved for the password credential.
verificationAuthEmailVerificationResultEmail OTP state when the sign-in flow requires a second step.
accessTokenstring | undefinedAccess token issued when sign-in is complete.
sessionAuthSession | undefinedSession issued when sign-in is complete.
setCookiestring | undefinedSet-Cookie header value when the session mode writes cookies.

Input accepted by auth.verifySignInEmailOtp().

FieldTypeDescription
emailstringEmail address used for the sign-in OTP.
otpstringOne-time password sent to the email address.
verificationIdstring | undefinedVerification challenge id returned by password sign-in.
rememberboolean | undefinedWhen true, Auth returns a remember-device token after successful OTP verification.

Result returned by auth.verifySignInEmailOtp().

FieldTypeDescription
rememberTokenstring | undefinedRemember-device token issued after successful OTP verification.
rememberTokenExpiresAtstring | undefinedISO timestamp when the remember-device token expires.

Input accepted by auth.createSession().

FieldTypeDescription
userIdstring | undefinedUser id that should own the new session.
userAuthCreateSessionUserInput | undefinedUser profile fields used when Auth creates or resolves the session user.
ttlSecondsint32 | undefinedAccess token lifetime in seconds for this session.
expiresAtstring | undefinedISO timestamp when the access session should expire.
accessTokenstring | undefinedCaller-supplied access token for trusted session minting.
sessionIdstring | undefinedCaller-supplied session id for trusted session minting.
deviceAuthSessionDevice | undefinedDevice metadata to store with the session.

Input accepted by auth.refreshSession().

FieldTypeDescription
refreshTokenstringRefresh token issued by Auth.
ttlSecondsint32 | undefinedAccess token lifetime in seconds for the refreshed session.
expiresAtstring | undefinedISO timestamp when the refreshed access session should expire.
deviceAuthSessionDevice | undefinedDevice metadata to store with the refreshed session.

Result returned by auth.refreshSession().

FieldTypeDescription

Input accepted by Auth session lookup methods.

FieldTypeDescription
accessTokenstring | undefinedAccess token to verify. When omitted, Auth reads the current request using the configured session mode.

Input accepted by auth.revokeSession().

FieldTypeDescription
sessionIdstring | undefinedSession id to revoke.
accessTokenstring | undefinedAccess token whose session should be revoked.

Input accepted by auth.revokeAllSessions().

FieldTypeDescription
userIdstring | undefinedUser id whose active sessions should be revoked. When omitted, Auth uses the current active session.
accessTokenstring | undefinedAccess token used to identify the current active session.

Result returned by auth.revokeAllSessions().

FieldTypeDescription
userIdstringUser id whose sessions were revoked.
revokedAtstringISO timestamp recorded when the sessions were revoked.
revokedSessionCountint32Number of active sessions revoked.

Input accepted by auth.updatePassword().

FieldTypeDescription
currentPasswordstring | undefinedCurrent password used when the configured policy requires reauthentication.
newPasswordstringNew plain-text password to validate and hash.
accessTokenstring | undefinedAccess token identifying the active user. When omitted, Auth reads the current request.

Result returned by auth.updatePassword().

FieldTypeDescription
userAuthUserUser whose password is being updated.
verificationAuthEmailVerificationResultEmail OTP state when the update requires a second step.
updatedAtstring | undefinedISO timestamp recorded when the password was updated.

Input accepted by auth.verifyPasswordUpdateEmailOtp().

FieldTypeDescription
otpstringOne-time password sent to confirm the password update.
verificationIdstring | undefinedVerification challenge id returned by updatePassword.
accessTokenstring | undefinedAccess token identifying the active user. When omitted, Auth reads the current request.

Result returned by auth.verifyPasswordUpdateEmailOtp().

FieldTypeDescription
userAuthUserUser whose password was updated.
updatedAtstringISO timestamp recorded when the password was updated.

Input accepted by auth.resetPasswordForEmail().

FieldTypeDescription
emailstringEmail address that should receive the password reset message.

Result returned by auth.resetPasswordForEmail().

FieldTypeDescription
emailstringEmail address that received the password reset flow.
senttrueWhether Auth accepted the reset request for delivery.

Input accepted by auth.verifyPasswordResetToken().

FieldTypeDescription
tokenstringPassword reset token sent to the user’s email address.
verificationIdstring | undefinedVerification challenge id associated with the reset token.

Result returned by auth.verifyPasswordResetToken().

FieldTypeDescription
validtrueWhether the reset token is valid.
emailstringEmail address associated with the reset token.
expiresAtstringISO timestamp when the reset token expires.

Input accepted by auth.setPasswordWithResetToken().

FieldTypeDescription
tokenstringPassword reset token sent to the user’s email address.
verificationIdstring | undefinedVerification challenge id associated with the reset token.
newPasswordstringNew plain-text password to validate and hash.

Result returned by auth.setPasswordWithResetToken().

FieldTypeDescription
userAuthUserUser whose password was reset.
updatedAtstringISO timestamp recorded when the password was reset.

Input accepted by auth.oauth.createAuthorizationUrl().

FieldTypeDescription
providerstringOAuth provider id. Use github for GitHub, or the configured OIDC provider id.
callbackUrlstringAbsolute callback URL registered with the OAuth or OIDC provider.
redirectTostring | undefinedRelative post-login path or allowlisted absolute URL returned after callback verification.
scopesstring[] | undefinedScopes requested for this authorization request. OIDC requests must include openid.

Result returned by auth.oauth.createAuthorizationUrl().

FieldTypeDescription
authorizationUrlstringProvider authorization URL with a one-time state value.
statestringOpaque state value that must be returned to auth.oauth.verifyCallback().
expiresAtstringISO timestamp when the state and PKCE verifier expire.
codeChallengestring | undefinedPKCE S256 challenge sent to providers that support PKCE.
codeChallengeMethod”S256” | undefinedPKCE challenge method.

Input accepted by auth.oauth.verifyCallback().

FieldTypeDescription
providerstringOAuth provider id. Use github for GitHub, or the configured OIDC provider id.
codestringAuthorization code returned by the OAuth or OIDC provider.
statestringState returned by the OAuth or OIDC provider.
callbackUrlstring | undefinedCallback URL used for the authorization request. Auth verifies it when supplied.

Result returned by auth.oauth.verifyCallback().

FieldTypeDescription
redirectTostring | undefinedPost-login redirect value stored during authorization URL creation.

WebAuthn credential response fields returned by the browser.

FieldTypeDescription
clientDataJSONstringBase64url-encoded clientDataJSON.
attestationObjectstring | undefinedBase64url-encoded attestationObject for registration.
authenticatorDatastring | undefinedBase64url-encoded authenticatorData for authentication.
signaturestring | undefinedBase64url-encoded assertion signature for authentication.
userHandlestring | undefinedBase64url-encoded user handle returned by the authenticator.

WebAuthn credential returned by navigator.credentials.create or navigator.credentials.get.

FieldTypeDescription
idstringBase64url-encoded credential id.
rawIdstring | undefinedBase64url-encoded raw credential id.
type”public-key” | undefinedCredential type. WebAuthn passkeys use public-key.
responseAuthWebAuthnCredentialResponseWebAuthn response fields.
authenticatorAttachmentPasskeyAuthenticatorAttachment | undefinedAuthenticator attachment reported by the browser.
transportsstring[] | undefinedAuthenticator transports reported by the browser.
clientExtensionResultsRecord<unknown> | undefinedClient extension results returned by the browser.

Stored passkey credential.

FieldTypeDescription
idstringStable Auth passkey id.
userIdstringUser id that owns the passkey.
credentialIdstringBase64url WebAuthn credential id.
friendlyNamestring | undefinedHuman-readable passkey name.
transportsstring[]Authenticator transports.
backedUpbooleanWhether the authenticator reported that the credential is backed up.
backupEligiblebooleanWhether the authenticator reported that the credential is backup eligible.
deviceType”singleDevice” | “multiDevice”Credential device type inferred from backup eligibility.
userVerifiedbooleanWhether the last ceremony had user verification.
createdAtstringISO timestamp recorded when the passkey was registered.
lastUsedAtstring | undefinedISO timestamp recorded when the passkey was last used.
lastUsedIpHashstring | undefinedHash of the IP address recorded during last use.
aaguidstring | undefinedAuthenticator AAGUID in hex.

Input accepted by auth.passkey.beginRegistration().

FieldTypeDescription
userIdstring | undefinedUser id to register for. When supplied, it must match the active session.
friendlyNamestring | undefinedHuman-readable passkey name.

Result returned by auth.passkey.beginRegistration().

FieldTypeDescription
ceremonyIdstringOne-time ceremony id.
expiresAtstringISO timestamp when the ceremony expires.
publicKeyRecord<unknown>PublicKeyCredentialCreationOptions JSON using base64url binary fields.

Input accepted by auth.passkey.finishRegistration().

FieldTypeDescription
ceremonyIdstringOne-time ceremony id returned by beginRegistration.
credentialAuthWebAuthnCredentialWebAuthn credential returned by the browser.
friendlyNamestring | undefinedHuman-readable passkey name.

Input accepted by auth.passkey.beginAuthentication().

FieldTypeDescription
userIdstring | undefinedUser id for non-discoverable passkey login.
emailstring | undefinedEmail address for managed-user passkey lookup.
purpose”login” | “mfa” | “step_up” | undefinedCeremony purpose. Defaults to login.

Result returned by auth.passkey.beginAuthentication().

FieldTypeDescription
ceremonyIdstringOne-time ceremony id.
expiresAtstringISO timestamp when the ceremony expires.
publicKeyRecord<unknown>PublicKeyCredentialRequestOptions JSON using base64url binary fields.

Input accepted by auth.passkey.finishAuthentication().

FieldTypeDescription
ceremonyIdstringOne-time ceremony id returned by beginAuthentication.
credentialAuthWebAuthnCredentialWebAuthn assertion returned by the browser.
stepUpPurposestring | undefinedApplication purpose recorded for a step-up session.

Result returned by auth.passkey.finishAuthentication().

FieldTypeDescription

Input accepted by auth.passkey.rename().

FieldTypeDescription
passkeyIdstringPasskey id to rename.
friendlyNamestringNew human-readable passkey name.

Input accepted by auth.passkey.remove().

FieldTypeDescription
passkeyIdstringPasskey id to remove.

Structured Auth error returned through AuthError JSON serialization and gateway error responses.

FieldTypeDescription
codeAuthErrorCodeStable Auth error code.
messagestringHuman-readable error message.
statusint32HTTP status code associated with the error.
detailsRecord<unknown> | undefinedAdditional structured error details.

Policy subject resolved from an Auth user.

FieldTypeDescription
kind”user”Subject kind used by Policy.
idstringSubject user id.
rolesstring[] | undefinedRole names attached to the subject.
scopesstring[] | undefinedPermission scopes attached to the subject.
tenantIdstring | undefinedTenant id attached to the subject.
attributesRecord<unknown> | undefinedSubject attributes exposed to Policy.

Layeron Auth module returned by auth(options).

FieldTypeDescription
name”auth”Module name recorded in the app spec.
configAuthModuleOptionsAuth module configuration recorded in the app spec.
observabilityLayeron.Observability.ObservabilityConfig | undefinedEffective observability policy recorded on the module declaration.

How Auth reads access tokens from requests.

ValueDescription
cookieRead and write the configured session cookie.
bearerRead bearer tokens from the Authorization header.
bothRead bearer tokens first, then the configured session cookie.

Password hash algorithm.

ValueDescription
argon2idArgon2id memory-hard password hashing.
pbkdf2_sha256PBKDF2 using SHA-256 through Web Crypto.

Password hash security level.

ValueDescription
interactiveLower memory cost for latency-sensitive Workers.
balancedDefault production setting. Argon2id uses 32 MiB of memory.
sensitiveHigher memory and time cost for sensitive applications.
customUse the explicit hash parameters supplied by the application.

Passkey user verification policy.

ValueDescription
requiredRequire authenticator user verification.
preferredPrefer authenticator user verification.
discouragedDiscourage authenticator user verification.

Passkey resident key policy.

ValueDescription
requiredRequire a discoverable credential.
preferredPrefer a discoverable credential.
discouragedDiscourage a discoverable credential.

Passkey authenticator attachment policy.

ValueDescription
platformUse a platform authenticator.
cross-platformUse a roaming authenticator.
anyAllow any authenticator attachment.

Passkey attestation conveyance preference.

ValueDescription
noneDo not request attestation.
indirectRequest indirect attestation.
directRequest direct attestation.
enterpriseRequest enterprise attestation.

OAuth and OIDC token endpoint client authentication method.

ValueDescription
client_secret_basicSend the client secret with HTTP Basic authentication.
client_secret_postSend the client secret in the form body.
noneUse PKCE without a client secret.

User status stored by Auth.

ValueDescription
activeThe user can sign in and use active sessions.
disabledThe user cannot sign in and existing sessions are rejected.

Auth error codes returned by AuthError.

ValueDescription
auth_runtime_not_attachedAuth runtime helpers were used without attaching the Auth runtime.
auth_runtime_context_missingThe current request has no Auth runtime context.
auth_invalid_configurationAuth configuration is invalid for the requested operation.
auth_invalid_inputThe request input failed Auth validation.
auth_custom_hook_requiredA required custom user-store hook is missing.
auth_email_product_requiredThe configured flow requires an Email product instance.
auth_email_invalidThe email address is invalid.
auth_email_already_registeredThe email address already has a password identity.
auth_email_not_verifiedThe email address must be verified before the operation can continue.
auth_password_weakThe password does not satisfy the configured strength policy.
auth_invalid_credentialsThe supplied credential is invalid.
auth_otp_invalidThe supplied OTP is invalid.
auth_otp_expiredThe supplied OTP is expired.
auth_otp_attempts_exhaustedThe OTP challenge has no remaining verification attempts.
auth_token_invalidThe supplied token is invalid.
auth_token_expiredThe supplied token is expired.
auth_token_attempts_exhaustedThe token challenge has no remaining verification attempts.
auth_oauth_provider_unsupportedThe OAuth or OIDC provider is missing, unsupported, or misconfigured.
auth_oauth_state_invalidThe OAuth or OIDC state is invalid, expired, consumed, or exhausted.
auth_oauth_callback_invalidThe OAuth or OIDC callback failed token exchange or id_token validation.
auth_invalid_refresh_tokenThe supplied refresh token is invalid, expired, reused, or revoked.
auth_remember_disabledRemember-device tokens are disabled for this flow.
auth_session_requiredThe operation requires an active session.
auth_session_not_foundThe requested session was not found.
auth_user_requiredThe operation requires a user id or user object.
auth_user_not_foundThe requested user was not found.
auth_user_disabledThe user is disabled.
auth_password_credential_not_foundThe user has no password credential.
auth_current_password_requiredThe current password is required.
auth_current_password_invalidThe current password is invalid.
auth_module_rpc_unavailableThe Auth Product Worker RPC entrypoint is unavailable.
auth_rpc_unsupported_operationThe Auth Product Worker does not support the requested RPC operation.

How Auth stores user records.

ValueDescription
managedAuth owns the user table, all Auth user profile fields, metadata fields, and sessions.
managed_coreAuth owns only core user identity fields and sessions.
customAuth owns sessions and resolves users through application functions.
mappedAuth owns security state and reads application user profiles from a mapped Database product table.
externalAuth owns login, sessions, and tokens, then resolves application user profiles through a resolver function.

Create an Auth session.

Terminal window
authCreateSession(input: AuthCreateSessionInput): AuthCreateSessionResult

Refresh an Auth session using a refresh token.

Terminal window
authRefreshSession(input: AuthRefreshSessionInput): AuthRefreshSessionResult

Create a user with email and password, send the configured sign-up email, and return a session when OTP verification is not required.

Terminal window
authSignUp(input: AuthSignUpInput): AuthSignUpResult

Verify a sign-up OTP and create a session.

Terminal window
authVerifyEmailOtp(input: AuthVerifyEmailOtpInput): AuthVerifyEmailOtpResult

Verify an email and password credential, then create a session or send the configured sign-in OTP.

Terminal window
authSignInWithPassword(input: AuthSignInWithPasswordInput): AuthSignInWithPasswordResult

Verify a password sign-in OTP and create a session.

Terminal window
authVerifySignInEmailOtp(input: AuthVerifySignInEmailOtpInput): AuthVerifySignInEmailOtpResult

Verify an access token and return the active session.

Terminal window
authVerifyAccessToken(input?: AuthVerifyAccessTokenInput): AuthSession | null

Return the active session.

Terminal window
authGetSession(input?: AuthVerifyAccessTokenInput): AuthSession | null

Return the active user.

Terminal window
authGetUser(input?: AuthVerifyAccessTokenInput): AuthUser | null

Return the active user id.

Terminal window
authGetUserId(input?: AuthVerifyAccessTokenInput): string | null

Revoke the active session.

Terminal window
authSignOut(input?: AuthRevokeSessionInput): AuthSession | null

Revoke a session.

Terminal window
authRevokeSession(input?: AuthRevokeSessionInput): AuthSession | null

Revoke every active session for a user.

Terminal window
authRevokeAllSessions(input?: AuthRevokeAllSessionsInput): AuthRevokeAllSessionsResult

Update the active user’s password or send a password update OTP.

Terminal window
authUpdatePassword(input: AuthUpdatePasswordInput): AuthUpdatePasswordResult

Verify a password update OTP and apply the pending password hash.

Terminal window
authVerifyPasswordUpdateEmailOtp(input: AuthVerifyPasswordUpdateEmailOtpInput): AuthVerifyPasswordUpdateEmailOtpResult

Send a password reset email when the address has a password credential.

Terminal window
authResetPasswordForEmail(input: AuthResetPasswordForEmailInput): AuthResetPasswordForEmailResult

Verify a password reset token.

Terminal window
authVerifyPasswordResetToken(input: AuthVerifyPasswordResetTokenInput): AuthVerifyPasswordResetTokenResult

Set a new password with a valid password reset token.

Terminal window
authSetPasswordWithResetToken(input: AuthSetPasswordWithResetTokenInput): AuthSetPasswordWithResetTokenResult

Create an OAuth or OIDC authorization URL with state and provider-specific protection.

Terminal window
authCreateOAuthAuthorizationUrl(input: AuthOAuthCreateAuthorizationUrlInput): AuthOAuthCreateAuthorizationUrlResult

Verify an OAuth or OIDC callback, link or create the identity, and create a session.

Terminal window
authVerifyOAuthCallback(input: AuthOAuthVerifyCallbackInput): AuthOAuthVerifyCallbackResult

List passkeys registered to the active user.

Terminal window
authListPasskeys(input?: AuthVerifyAccessTokenInput): PasskeyCredential[]

Begin passkey registration for the active user.

Terminal window
authBeginPasskeyRegistration(input?: AuthPasskeyBeginRegistrationInput): AuthPasskeyBeginRegistrationResult

Finish passkey registration and store the verified credential.

Terminal window
authFinishPasskeyRegistration(input: AuthPasskeyFinishRegistrationInput): PasskeyCredential

Begin passkey authentication for login, MFA, or step-up.

Terminal window
authBeginPasskeyAuthentication(input?: AuthPasskeyBeginAuthenticationInput): AuthPasskeyBeginAuthenticationResult

Finish passkey authentication and create a session.

Terminal window
authFinishPasskeyAuthentication(input: AuthPasskeyFinishAuthenticationInput): AuthPasskeyFinishAuthenticationResult

Rename an active user’s passkey.

Terminal window
authRenamePasskey(input: AuthPasskeyRenameInput): PasskeyCredential

Remove an active user’s passkey.

Terminal window
authRemovePasskey(input: AuthPasskeyRemoveInput): PasskeyCredential | null

Resolve the active subject for Policy and route context.

Terminal window
authResolveSubject(input?: AuthVerifyAccessTokenInput): AuthSubject | null
OptionDescription
magicLinkMagic link sign-in settings.
passkeyPasskey login and MFA settings.
mfaMulti-factor authentication settings.
MethodDescription
requireUserId()Require an active user and return its id.
verifyAccessToken()Verify an access token and return the active session.
refreshSession()Refresh an existing Auth session.
signInWithOtp()Start an email OTP sign-in.
verifyOtp()Verify an email OTP sign-in challenge.
signInWithMagicLink()Start a magic link sign-in.
verifyMagicLink()Verify a magic link token.
requireAal()Require a specific authentication assurance level.
requireStepUp()Require a step-up authentication challenge.
resolveSubject()Resolve the active Policy subject.
oauth.createAuthorizationUrl()Create an OAuth authorization URL.
oauth.verifyCallback()Verify an OAuth callback.
passkey.list()List passkeys for the active user.
passkey.beginRegistration()Begin passkey registration.
passkey.finishRegistration()Finish passkey registration.
passkey.beginAuthentication()Begin passkey authentication.
passkey.finishAuthentication()Finish passkey authentication.
passkey.rename()Rename a passkey.
passkey.remove()Remove a passkey.
mfa.enroll()Enroll an MFA factor.
mfa.challenge()Create an MFA challenge.
mfa.verify()Verify an MFA challenge.
mfa.getAal()Read the active authentication assurance level.
mfa.unenroll()Unenroll an MFA factor.

These TypeScript result contracts are part of the public module API.

Result
EmailSendResult
AuthSignInWithOtpResult
AuthSignInWithMagicLinkResult
AuthOAuthCreateAuthorizationUrlResult
AuthWebAuthnCredentialResponse
AuthPasskeyBeginRegistrationResult
AuthPasskeyBeginAuthenticationResult
AuthMfaEnrollResult
AuthMfaChallengeResult
AuthMfaVerifyResult
AuthMfaGetAalResult