ReferenceTypeScript Types

TypeScript Types

Key types exported from guardo. Everything ships with JSDoc, so you get in-editor docs on hover.

TypeShape / description
User{ id: string; email?: string; phone?: string; role?: string; [key: string]: unknown }
SessionFull session object - sessionId, userId, device?, ip?, userAgent?, createdAt, lastActiveAt.
SessionMeta{ device?: string; ip?: string; userAgent?: string } - passed when creating a session.
TokenPair{ accessToken: string; refreshToken: string }
TokenPayloadDecoded JWT - sub, email?, role?, sessionId?, type: "access" | "refresh", iat?, exp?.
LoginResult{ user, accessToken, refreshToken, sessionId }
LoginWithOtpOptions{ identifier, otp, meta? }
SendOtpOptions{ identifier, channel?, ip? }
VerifyOtpOptions{ identifier, otp }
VerifyOtpResult{ success, verified, error?, code? }
OtpChannel"email" | "sms"
StorageAdapterInterface for custom storage backends.
NotifierInterface with a single sendOTP(payload) method.
NotifyPayload{ to, code, channel, expiresInSeconds? }
GuardoErrorCodeUnion of machine-readable error codes - see Error Handling.
GuardoEventsMap of lifecycle event names to handler signatures - see Events.
CookieOptionshttpOnly cookie configuration.
AuthConfigTop-level config passed to createAuth().

Type-only helpers SmtpConfig and EmailNotifierOptions are exported for the email notifier as well.