Documentation
¶
Overview ¶
Package memory is the in-process Repository driver. It backs both fast unit tests (no gRPC, no docker) and local-development runs where a full EntDB stack is overkill.
All operations are mutex-protected so tests using t.Parallel() are race-free. The driver keeps the same surface as the EntDB-backed driver — service.Repository plus a no-op service.DB — so the driver-selection helper in internal/repo/driver.go can hand it back from Build like any other backend.
Index ¶
- type Repo
- func (r *Repo) ConsumeRefreshTokenByHash(_ context.Context, hash string, atMs int64) error
- func (r *Repo) CountRefreshTokensForUser(userID string) int
- func (r *Repo) CreateEmailChangeToken(_ context.Context, t *service.EmailChangeToken) error
- func (r *Repo) CreateEmailVerificationToken(_ context.Context, t *service.EmailVerificationToken) error
- func (r *Repo) CreateIdentityVerification(_ context.Context, rec *service.IdentityVerificationRecord) error
- func (r *Repo) CreateLoginChallenge(_ context.Context, rec *service.LoginChallengeRecord) (string, error)
- func (r *Repo) CreateOAuthIdentity(_ context.Context, oi *service.OAuthIdentity) error
- func (r *Repo) CreatePasskeyChallenge(_ context.Context, rec *service.PasskeyChallengeRecord) (string, error)
- func (r *Repo) CreatePasskeyCredential(_ context.Context, rec *service.PasskeyCredRecord) (string, error)
- func (r *Repo) CreatePasswordResetToken(_ context.Context, t *service.PasswordResetToken) error
- func (r *Repo) CreateQrLoginSession(_ context.Context, rec *service.QrLoginSessionRecord) (string, error)
- func (r *Repo) CreateRecoveryCode(_ context.Context, rec *service.RecoveryCodeRecord) (string, error)
- func (r *Repo) CreateRefreshToken(_ context.Context, rec *service.RefreshTokenRecord) (string, error)
- func (r *Repo) CreateTotpCredential(_ context.Context, rec *service.TotpCredRecord) (string, error)
- func (r *Repo) CreateUser(_ context.Context, u *service.User) (string, error)
- func (r *Repo) DeleteLoginChallenge(_ context.Context, nodeID string) error
- func (r *Repo) DeletePasskeyChallenge(_ context.Context, nodeID string) error
- func (r *Repo) DeleteRecoveryCodesForUser(_ context.Context, userID string) error
- func (r *Repo) DeleteRefreshToken(_ context.Context, nodeID string) error
- func (r *Repo) DeleteRefreshTokensForUser(_ context.Context, userID string) error
- func (r *Repo) DeleteTotpCredential(_ context.Context, nodeID string) error
- func (r *Repo) DeleteTotpCredentialsForUser(_ context.Context, userID string) error
- func (r *Repo) ExecuteAtomic(context.Context, string, string, string, []sdk.Operation) (*sdk.CommitResult, error)
- func (r *Repo) FindEmailChangeTokenByHash(_ context.Context, hash string) (*service.EmailChangeToken, error)
- func (r *Repo) FindEmailVerificationTokenByHash(_ context.Context, hash string) (*service.EmailVerificationToken, error)
- func (r *Repo) FindInvitationByHash(_ context.Context, tokenHash string) (*service.InvitationRecord, error)
- func (r *Repo) FindPasswordResetTokenByHash(_ context.Context, hash string) (*service.PasswordResetToken, error)
- func (r *Repo) FindQrLoginSession(_ context.Context, sessionID string) (*service.QrLoginSessionRecord, error)
- func (r *Repo) FindRecoveryCodeByHash(_ context.Context, userID, hash string) (*service.RecoveryCodeRecord, error)
- func (r *Repo) FindRefreshTokenByHash(_ context.Context, hash string) (*service.RefreshTokenRecord, error)
- func (r *Repo) FindRefreshTokenByHashIncludingConsumed(_ context.Context, hash string) (*service.RefreshTokenRecord, error)
- func (r *Repo) FindUserByEmail(_ context.Context, email string) (*service.User, error)
- func (r *Repo) FindUserByProviderID(_ context.Context, provider, providerUserID string) (*service.User, error)
- func (r *Repo) GetEdgesFrom(context.Context, string, string, string, int) ([]*sdk.Edge, error)
- func (r *Repo) GetEdgesTo(context.Context, string, string, string, int) ([]*sdk.Edge, error)
- func (r *Repo) GetIdentityVerification(_ context.Context, verificationID string) (*service.IdentityVerificationRecord, error)
- func (r *Repo) GetLatestIdentityVerificationForUser(_ context.Context, userID string) (*service.IdentityVerificationRecord, error)
- func (r *Repo) GetLoginChallengeByChallengeID(_ context.Context, challengeID string) (*service.LoginChallengeRecord, error)
- func (r *Repo) GetNode(context.Context, string, string, int, string) (*sdk.Node, error)
- func (r *Repo) GetPasskeyChallenge(_ context.Context, nodeID string) (*service.PasskeyChallengeRecord, error)
- func (r *Repo) GetPasskeyCredentialByCredID(_ context.Context, credentialID string) (*service.PasskeyCredRecord, error)
- func (r *Repo) GetTotpCredential(_ context.Context, userID string) (*service.TotpCredRecord, error)
- func (r *Repo) GetUser(_ context.Context, userID string) (*service.User, error)
- func (r *Repo) IncrementFailedLoginCount(_ context.Context, userID string) (int32, error)
- func (r *Repo) ListOAuthIdentitiesForUser(_ context.Context, userID string) ([]*service.OAuthIdentity, error)
- func (r *Repo) ListPasskeyCredentials(_ context.Context, userID string) ([]*service.PasskeyCredRecord, error)
- func (r *Repo) MarkEmailChangeTokenConsumed(_ context.Context, id string, atMs int64) error
- func (r *Repo) MarkEmailVerificationTokenConsumed(_ context.Context, id string, atMs int64) error
- func (r *Repo) MarkPasswordResetTokenConsumed(_ context.Context, id string, atMs int64) error
- func (r *Repo) QueryNodes(context.Context, string, string, int, map[string]any) ([]*sdk.Node, error)
- func (r *Repo) ResetFailedLoginCount(_ context.Context, userID string) error
- func (r *Repo) SearchNodes(context.Context, string, string, int, string) ([]*sdk.Node, error)
- func (r *Repo) SetUserEmailVerified(_ context.Context, userID string, atMs int64) error
- func (r *Repo) SetUserIDVVerified(_ context.Context, userID string, atMs int64) error
- func (r *Repo) SetUserLockedUntil(_ context.Context, userID string, lockedUntilMs int64) error
- func (r *Repo) UpdateIdentityVerificationStatus(_ context.Context, verificationID, status, rejectionReason string, ...) error
- func (r *Repo) UpdateInvitation(_ context.Context, nodeID string, fields map[string]any) error
- func (r *Repo) UpdatePasskeyCredential(_ context.Context, nodeID string, fields map[string]any) error
- func (r *Repo) UpdateQrLoginSession(_ context.Context, nodeID string, fields map[string]any) error
- func (r *Repo) UpdateRecoveryCode(_ context.Context, nodeID string, fields map[string]any) error
- func (r *Repo) UpdateTotpCredential(_ context.Context, nodeID string, fields map[string]any) error
- func (r *Repo) UpdateUser(_ context.Context, userID string, fields map[string]any) error
- func (r *Repo) UpdateUserEmail(_ context.Context, userID, newEmail string, atMs int64) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Repo ¶
type Repo struct {
// contains filtered or unexported fields
}
Repo is the in-memory implementation of service.Repository.
func (*Repo) ConsumeRefreshTokenByHash ¶
ConsumeRefreshTokenByHash atomically marks the row consumed. Returns service.ErrUnauthenticated if the row is missing or already consumed, so concurrent rotations resolve to exactly one winner.
func (*Repo) CountRefreshTokensForUser ¶
CountRefreshTokensForUser is a test helper for assertions about session count.