db

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 19, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthAccount

type AuthAccount struct {
	ID                    string
	UserID                string
	Provider              string
	ProviderAccountID     string
	Email                 string
	EmailVerified         bool
	AccessTokenEncrypted  []byte
	RefreshTokenEncrypted []byte
	TokenExpiresAt        *time.Time
	Scopes                []string
	CreatedAt             time.Time
	UpdatedAt             time.Time
}

type AuthAccountLock

type AuthAccountLock struct {
	UserID   string
	LockedAt time.Time
}

type AuthEmailLoginToken

type AuthEmailLoginToken struct {
	ID        string
	Email     string
	Kind      string
	TokenHash string
	Attempts  int32
	ExpiresAt time.Time
	UsedAt    *time.Time
	CreatedAt time.Time
}

type AuthEmailVerificationToken

type AuthEmailVerificationToken struct {
	ID        string
	UserID    string
	TokenHash string
	ExpiresAt time.Time
	UsedAt    *time.Time
	CreatedAt time.Time
}

type AuthFailedLoginAttempt

type AuthFailedLoginAttempt struct {
	ID        string
	Email     string
	IpAddress string
	CreatedAt time.Time
}

type AuthPasswordResetToken

type AuthPasswordResetToken struct {
	ID        string
	UserID    string
	TokenHash string
	ExpiresAt time.Time
	UsedAt    *time.Time
	CreatedAt time.Time
}

type AuthPendingTwoFactorSession

type AuthPendingTwoFactorSession struct {
	ID        string
	UserID    string
	TokenHash string
	ExpiresAt time.Time
	CreatedAt time.Time
}

type AuthRefreshToken

type AuthRefreshToken struct {
	ID        string
	UserID    string
	TokenHash string
	ExpiresAt time.Time
	RevokedAt *time.Time
	UserAgent string
	IpAddress string
	CreatedAt time.Time
}

type AuthSuperuser

type AuthSuperuser struct {
	ID           string
	Email        string
	PasswordHash string
	DisplayName  string
	IsActive     bool
	CreatedBy    *string
	LastLoginAt  *time.Time
	CreatedAt    time.Time
	UpdatedAt    time.Time
}

type AuthSuperuserPendingTwoFactorSession

type AuthSuperuserPendingTwoFactorSession struct {
	ID          string
	SuperuserID string
	TokenHash   string
	ExpiresAt   time.Time
	CreatedAt   time.Time
}

type AuthSuperuserRefreshToken

type AuthSuperuserRefreshToken struct {
	ID          string
	SuperuserID string
	TokenHash   string
	ExpiresAt   time.Time
	RevokedAt   *time.Time
	UserAgent   string
	IpAddress   string
	CreatedAt   time.Time
}

type AuthSuperuserTotpSetting

type AuthSuperuserTotpSetting struct {
	ID                 string
	SuperuserID        string
	SecretEncrypted    []byte
	Enabled            bool
	VerifiedAt         *time.Time
	RecoveryCodeHashes []string
	RecoveryCodesUsed  int32
	CreatedAt          time.Time
	UpdatedAt          time.Time
}

type AuthTotpSetting

type AuthTotpSetting struct {
	ID                 string
	UserID             string
	SecretEncrypted    []byte
	Enabled            bool
	VerifiedAt         *time.Time
	RecoveryCodeHashes []string
	RecoveryCodesUsed  int32
	CreatedAt          time.Time
	UpdatedAt          time.Time
}

type AuthUser

type AuthUser struct {
	ID              string
	Email           string
	PasswordHash    string
	EmailVerified   bool
	EmailVerifiedAt *time.Time
	CreatedAt       time.Time
	UpdatedAt       time.Time
}

type AuthWebauthnChallenge

type AuthWebauthnChallenge struct {
	ID        string
	TokenHash string
	UserID    *string
	Data      []byte
	ExpiresAt time.Time
	CreatedAt time.Time
}

type AuthWebauthnCredential

type AuthWebauthnCredential struct {
	ID             string
	UserID         string
	CredentialID   []byte
	Data           []byte
	Name           string
	Transports     []string
	BackupEligible bool
	BackupState    bool
	CloneWarning   bool
	LastUsedAt     *time.Time
	CreatedAt      time.Time
	UpdatedAt      time.Time
}

type CountRecentFailedLoginAttemptsParams

type CountRecentFailedLoginAttemptsParams struct {
	Email     string
	CreatedAt time.Time
}

type CreateAccountParams

type CreateAccountParams struct {
	ID                    string
	UserID                string
	Provider              string
	ProviderAccountID     string
	Email                 string
	EmailVerified         bool
	AccessTokenEncrypted  []byte
	RefreshTokenEncrypted []byte
	TokenExpiresAt        *time.Time
	Scopes                []string
	CreatedAt             time.Time
	UpdatedAt             time.Time
}

type CreateEmailLoginTokenParams

type CreateEmailLoginTokenParams struct {
	ID        string
	Email     string
	Kind      string
	TokenHash string
	Attempts  int32
	ExpiresAt time.Time
	UsedAt    *time.Time
	CreatedAt time.Time
}

type CreateEmailVerificationTokenParams

type CreateEmailVerificationTokenParams struct {
	ID        string
	UserID    string
	TokenHash string
	ExpiresAt time.Time
	UsedAt    *time.Time
	CreatedAt time.Time
}

type CreatePasswordResetTokenParams

type CreatePasswordResetTokenParams struct {
	ID        string
	UserID    string
	TokenHash string
	ExpiresAt time.Time
	UsedAt    *time.Time
	CreatedAt time.Time
}

type CreatePendingTwoFactorSessionParams

type CreatePendingTwoFactorSessionParams struct {
	ID        string
	UserID    string
	TokenHash string
	ExpiresAt time.Time
	CreatedAt time.Time
}

type CreateRefreshTokenParams

type CreateRefreshTokenParams struct {
	ID        string
	UserID    string
	TokenHash string
	ExpiresAt time.Time
	RevokedAt *time.Time
	UserAgent string
	IpAddress string
	CreatedAt time.Time
}

type CreateSuperuserParams

type CreateSuperuserParams struct {
	ID           string
	Email        string
	PasswordHash string
	DisplayName  string
	IsActive     bool
	CreatedBy    *string
	LastLoginAt  *time.Time
	CreatedAt    time.Time
	UpdatedAt    time.Time
}

type CreateSuperuserPendingTwoFactorSessionParams

type CreateSuperuserPendingTwoFactorSessionParams struct {
	ID          string
	SuperuserID string
	TokenHash   string
	ExpiresAt   time.Time
	CreatedAt   time.Time
}

type CreateSuperuserRefreshTokenParams

type CreateSuperuserRefreshTokenParams struct {
	ID          string
	SuperuserID string
	TokenHash   string
	ExpiresAt   time.Time
	RevokedAt   *time.Time
	UserAgent   string
	IpAddress   string
	CreatedAt   time.Time
}

type CreateSuperuserTOTPSettingsParams

type CreateSuperuserTOTPSettingsParams struct {
	ID                 string
	SuperuserID        string
	SecretEncrypted    []byte
	Enabled            bool
	VerifiedAt         *time.Time
	RecoveryCodeHashes []string
	RecoveryCodesUsed  int32
	CreatedAt          time.Time
	UpdatedAt          time.Time
}

type CreateTOTPSettingsParams

type CreateTOTPSettingsParams struct {
	ID                 string
	UserID             string
	SecretEncrypted    []byte
	Enabled            bool
	VerifiedAt         *time.Time
	RecoveryCodeHashes []string
	RecoveryCodesUsed  int32
	CreatedAt          time.Time
	UpdatedAt          time.Time
}

type CreateUserParams

type CreateUserParams struct {
	ID              string
	Email           string
	PasswordHash    string
	EmailVerified   bool
	EmailVerifiedAt *time.Time
	CreatedAt       time.Time
	UpdatedAt       time.Time
}

type CreateWebAuthnChallengeParams

type CreateWebAuthnChallengeParams struct {
	ID        string
	TokenHash string
	UserID    *string
	Data      []byte
	ExpiresAt time.Time
	CreatedAt time.Time
}

type CreateWebAuthnCredentialParams

type CreateWebAuthnCredentialParams struct {
	ID             string
	UserID         string
	CredentialID   []byte
	Data           []byte
	Name           string
	Transports     []string
	BackupEligible bool
	BackupState    bool
	CloneWarning   bool
	LastUsedAt     *time.Time
	CreatedAt      time.Time
	UpdatedAt      time.Time
}

type DBTX

type DBTX interface {
	Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
	Query(context.Context, string, ...interface{}) (pgx.Rows, error)
	QueryRow(context.Context, string, ...interface{}) pgx.Row
}

type DeleteEmailLoginTokensParams

type DeleteEmailLoginTokensParams struct {
	Email string
	Kind  string
}

type GetAccountByProviderParams

type GetAccountByProviderParams struct {
	Provider          string
	ProviderAccountID string
}

type GetEmailLoginTokenByEmailParams

type GetEmailLoginTokenByEmailParams struct {
	Email string
	Kind  string
}

type MarkEmailLoginTokenUsedParams

type MarkEmailLoginTokenUsedParams struct {
	ID     string
	UsedAt *time.Time
}

type Queries

type Queries struct {
	// contains filtered or unexported fields
}

func New

func New(db DBTX) *Queries

func (*Queries) ClearFailedLoginAttempts

func (q *Queries) ClearFailedLoginAttempts(ctx context.Context, email string) error

func (*Queries) ConsumeWebAuthnChallenge

func (q *Queries) ConsumeWebAuthnChallenge(ctx context.Context, tokenHash string) (AuthWebauthnChallenge, error)

The DELETE decides, so two concurrent redemptions cannot both get the row.

func (*Queries) CountRecentFailedLoginAttempts

func (q *Queries) CountRecentFailedLoginAttempts(ctx context.Context, arg CountRecentFailedLoginAttemptsParams) (int64, error)

func (*Queries) CountSuperusers

func (q *Queries) CountSuperusers(ctx context.Context) (int64, error)

func (*Queries) CreateAccount

func (q *Queries) CreateAccount(ctx context.Context, arg CreateAccountParams) error

func (*Queries) CreateEmailLoginToken

func (q *Queries) CreateEmailLoginToken(ctx context.Context, arg CreateEmailLoginTokenParams) error

func (*Queries) CreateEmailVerificationToken

func (q *Queries) CreateEmailVerificationToken(ctx context.Context, arg CreateEmailVerificationTokenParams) error

func (*Queries) CreatePasswordResetToken

func (q *Queries) CreatePasswordResetToken(ctx context.Context, arg CreatePasswordResetTokenParams) error

func (*Queries) CreatePendingTwoFactorSession

func (q *Queries) CreatePendingTwoFactorSession(ctx context.Context, arg CreatePendingTwoFactorSessionParams) error

func (*Queries) CreateRefreshToken

func (q *Queries) CreateRefreshToken(ctx context.Context, arg CreateRefreshTokenParams) error

func (*Queries) CreateSuperuser

func (q *Queries) CreateSuperuser(ctx context.Context, arg CreateSuperuserParams) error

func (*Queries) CreateSuperuserPendingTwoFactorSession

func (q *Queries) CreateSuperuserPendingTwoFactorSession(ctx context.Context, arg CreateSuperuserPendingTwoFactorSessionParams) error

func (*Queries) CreateSuperuserRefreshToken

func (q *Queries) CreateSuperuserRefreshToken(ctx context.Context, arg CreateSuperuserRefreshTokenParams) error

func (*Queries) CreateSuperuserTOTPSettings

func (q *Queries) CreateSuperuserTOTPSettings(ctx context.Context, arg CreateSuperuserTOTPSettingsParams) error

func (*Queries) CreateTOTPSettings

func (q *Queries) CreateTOTPSettings(ctx context.Context, arg CreateTOTPSettingsParams) error

func (*Queries) CreateUser

func (q *Queries) CreateUser(ctx context.Context, arg CreateUserParams) error

func (*Queries) CreateWebAuthnChallenge

func (q *Queries) CreateWebAuthnChallenge(ctx context.Context, arg CreateWebAuthnChallengeParams) error

func (*Queries) CreateWebAuthnCredential

func (q *Queries) CreateWebAuthnCredential(ctx context.Context, arg CreateWebAuthnCredentialParams) error

func (*Queries) DeleteAccount

func (q *Queries) DeleteAccount(ctx context.Context, id string) (int64, error)

func (*Queries) DeleteEmailLoginTokens

func (q *Queries) DeleteEmailLoginTokens(ctx context.Context, arg DeleteEmailLoginTokensParams) error

func (*Queries) DeletePendingTwoFactorSession

func (q *Queries) DeletePendingTwoFactorSession(ctx context.Context, id string) error

func (*Queries) DeleteSuperuserPendingTwoFactorSession

func (q *Queries) DeleteSuperuserPendingTwoFactorSession(ctx context.Context, id string) error

func (*Queries) DeleteSuperuserTOTPSettings

func (q *Queries) DeleteSuperuserTOTPSettings(ctx context.Context, superuserID string) error

func (*Queries) DeleteTOTPSettings

func (q *Queries) DeleteTOTPSettings(ctx context.Context, userID string) error

func (*Queries) DeleteUserEmailVerificationTokens

func (q *Queries) DeleteUserEmailVerificationTokens(ctx context.Context, userID string) error

func (*Queries) DeleteUserPasswordResetTokens

func (q *Queries) DeleteUserPasswordResetTokens(ctx context.Context, userID string) error

func (*Queries) DeleteWebAuthnCredential

func (q *Queries) DeleteWebAuthnCredential(ctx context.Context, id string) (int64, error)

func (*Queries) GetAccount

func (q *Queries) GetAccount(ctx context.Context, id string) (AuthAccount, error)

func (*Queries) GetAccountByProvider

func (q *Queries) GetAccountByProvider(ctx context.Context, arg GetAccountByProviderParams) (AuthAccount, error)

func (*Queries) GetEmailLoginTokenByEmail

func (q *Queries) GetEmailLoginTokenByEmail(ctx context.Context, arg GetEmailLoginTokenByEmailParams) (AuthEmailLoginToken, error)

func (*Queries) GetEmailLoginTokenByHash

func (q *Queries) GetEmailLoginTokenByHash(ctx context.Context, tokenHash string) (AuthEmailLoginToken, error)

func (*Queries) GetEmailVerificationTokenByHash

func (q *Queries) GetEmailVerificationTokenByHash(ctx context.Context, tokenHash string) (AuthEmailVerificationToken, error)

func (*Queries) GetPasswordResetTokenByHash

func (q *Queries) GetPasswordResetTokenByHash(ctx context.Context, tokenHash string) (AuthPasswordResetToken, error)

func (*Queries) GetPendingTwoFactorSessionByHash

func (q *Queries) GetPendingTwoFactorSessionByHash(ctx context.Context, tokenHash string) (AuthPendingTwoFactorSession, error)

func (*Queries) GetRefreshTokenByHash

func (q *Queries) GetRefreshTokenByHash(ctx context.Context, tokenHash string) (AuthRefreshToken, error)

func (*Queries) GetSuperuserByEmail

func (q *Queries) GetSuperuserByEmail(ctx context.Context, email string) (AuthSuperuser, error)

func (*Queries) GetSuperuserByID

func (q *Queries) GetSuperuserByID(ctx context.Context, id string) (AuthSuperuser, error)

func (*Queries) GetSuperuserPendingTwoFactorSessionByHash

func (q *Queries) GetSuperuserPendingTwoFactorSessionByHash(ctx context.Context, tokenHash string) (AuthSuperuserPendingTwoFactorSession, error)

func (*Queries) GetSuperuserRefreshTokenByHash

func (q *Queries) GetSuperuserRefreshTokenByHash(ctx context.Context, tokenHash string) (AuthSuperuserRefreshToken, error)

func (*Queries) GetSuperuserTOTPSettings

func (q *Queries) GetSuperuserTOTPSettings(ctx context.Context, superuserID string) (AuthSuperuserTotpSetting, error)

func (*Queries) GetTOTPSettingsByUserID

func (q *Queries) GetTOTPSettingsByUserID(ctx context.Context, userID string) (AuthTotpSetting, error)

func (*Queries) GetUserByEmail

func (q *Queries) GetUserByEmail(ctx context.Context, email string) (AuthUser, error)

func (*Queries) GetUserByID

func (q *Queries) GetUserByID(ctx context.Context, id string) (AuthUser, error)

func (*Queries) GetWebAuthnCredential

func (q *Queries) GetWebAuthnCredential(ctx context.Context, id string) (AuthWebauthnCredential, error)

func (*Queries) GetWebAuthnCredentialByCredentialID

func (q *Queries) GetWebAuthnCredentialByCredentialID(ctx context.Context, credentialID []byte) (AuthWebauthnCredential, error)

func (*Queries) IncrementEmailLoginTokenAttempts

func (q *Queries) IncrementEmailLoginTokenAttempts(ctx context.Context, id string) (int32, error)

The database computes the count so parallel guesses each cost one.

func (*Queries) IsAccountLocked

func (q *Queries) IsAccountLocked(ctx context.Context, userID string) (bool, error)

func (*Queries) ListAccountsByUser

func (q *Queries) ListAccountsByUser(ctx context.Context, userID string) ([]AuthAccount, error)

func (*Queries) ListActiveRefreshTokens

func (q *Queries) ListActiveRefreshTokens(ctx context.Context, userID string) ([]AuthRefreshToken, error)

func (*Queries) ListActiveSuperuserRefreshTokens

func (q *Queries) ListActiveSuperuserRefreshTokens(ctx context.Context, superuserID string) ([]AuthSuperuserRefreshToken, error)

func (*Queries) ListSuperusers

func (q *Queries) ListSuperusers(ctx context.Context) ([]AuthSuperuser, error)

func (*Queries) ListWebAuthnCredentialsByUser

func (q *Queries) ListWebAuthnCredentialsByUser(ctx context.Context, userID string) ([]AuthWebauthnCredential, error)

func (*Queries) LockAccount

func (q *Queries) LockAccount(ctx context.Context, userID string) error

func (*Queries) MarkEmailLoginTokenUsed

func (q *Queries) MarkEmailLoginTokenUsed(ctx context.Context, arg MarkEmailLoginTokenUsedParams) (int64, error)

Compare-and-set: no rows means another redemption won.

func (*Queries) MarkEmailVerificationTokenUsed

func (q *Queries) MarkEmailVerificationTokenUsed(ctx context.Context, id string) (int64, error)

func (*Queries) MarkPasswordResetTokenUsed

func (q *Queries) MarkPasswordResetTokenUsed(ctx context.Context, id string) (int64, error)

func (*Queries) RecordFailedLoginAttempt

func (q *Queries) RecordFailedLoginAttempt(ctx context.Context, arg RecordFailedLoginAttemptParams) error

func (*Queries) RevokeAllSuperuserRefreshTokens

func (q *Queries) RevokeAllSuperuserRefreshTokens(ctx context.Context, superuserID string) error

func (*Queries) RevokeAllUserRefreshTokens

func (q *Queries) RevokeAllUserRefreshTokens(ctx context.Context, userID string) error

func (*Queries) RevokeRefreshToken

func (q *Queries) RevokeRefreshToken(ctx context.Context, id string) (int64, error)

func (*Queries) RevokeSuperuserRefreshToken

func (q *Queries) RevokeSuperuserRefreshToken(ctx context.Context, id string) (int64, error)

func (*Queries) TouchRefreshToken

func (q *Queries) TouchRefreshToken(ctx context.Context, arg TouchRefreshTokenParams) (int64, error)

A revoked session must not be extended back to life.

func (*Queries) UnlockAccount

func (q *Queries) UnlockAccount(ctx context.Context, userID string) error

func (*Queries) UpdateAccount

func (q *Queries) UpdateAccount(ctx context.Context, arg UpdateAccountParams) (int64, error)

func (*Queries) UpdateSuperuser

func (q *Queries) UpdateSuperuser(ctx context.Context, arg UpdateSuperuserParams) (int64, error)

func (*Queries) UpdateSuperuserTOTPSettings

func (q *Queries) UpdateSuperuserTOTPSettings(ctx context.Context, arg UpdateSuperuserTOTPSettingsParams) (int64, error)

func (*Queries) UpdateTOTPSettings

func (q *Queries) UpdateTOTPSettings(ctx context.Context, arg UpdateTOTPSettingsParams) (int64, error)

func (*Queries) UpdateUser

func (q *Queries) UpdateUser(ctx context.Context, arg UpdateUserParams) (int64, error)

func (*Queries) UpdateWebAuthnCredential

func (q *Queries) UpdateWebAuthnCredential(ctx context.Context, arg UpdateWebAuthnCredentialParams) (int64, error)

func (*Queries) WithTx

func (q *Queries) WithTx(tx pgx.Tx) *Queries

type RecordFailedLoginAttemptParams

type RecordFailedLoginAttemptParams struct {
	ID        string
	Email     string
	IpAddress string
	CreatedAt time.Time
}

type TouchRefreshTokenParams

type TouchRefreshTokenParams struct {
	ID        string
	ExpiresAt time.Time
}

type UpdateAccountParams

type UpdateAccountParams struct {
	ID                    string
	UserID                string
	Provider              string
	ProviderAccountID     string
	Email                 string
	EmailVerified         bool
	AccessTokenEncrypted  []byte
	RefreshTokenEncrypted []byte
	TokenExpiresAt        *time.Time
	Scopes                []string
	UpdatedAt             time.Time
}

type UpdateSuperuserParams

type UpdateSuperuserParams struct {
	ID           string
	Email        string
	PasswordHash string
	DisplayName  string
	IsActive     bool
	LastLoginAt  *time.Time
	UpdatedAt    time.Time
}

type UpdateSuperuserTOTPSettingsParams

type UpdateSuperuserTOTPSettingsParams struct {
	SuperuserID        string
	SecretEncrypted    []byte
	Enabled            bool
	VerifiedAt         *time.Time
	RecoveryCodeHashes []string
	RecoveryCodesUsed  int32
	UpdatedAt          time.Time
}

type UpdateTOTPSettingsParams

type UpdateTOTPSettingsParams struct {
	UserID             string
	SecretEncrypted    []byte
	Enabled            bool
	VerifiedAt         *time.Time
	RecoveryCodeHashes []string
	RecoveryCodesUsed  int32
	UpdatedAt          time.Time
}

type UpdateUserParams

type UpdateUserParams struct {
	ID              string
	Email           string
	PasswordHash    string
	EmailVerified   bool
	EmailVerifiedAt *time.Time
	UpdatedAt       time.Time
}

type UpdateWebAuthnCredentialParams

type UpdateWebAuthnCredentialParams struct {
	ID             string
	CredentialID   []byte
	Data           []byte
	Name           string
	Transports     []string
	BackupEligible bool
	BackupState    bool
	CloneWarning   bool
	LastUsedAt     *time.Time
	UpdatedAt      time.Time
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL