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) AddOrganizationMember(_ context.Context, m *service.OrganizationMembership) (string, error)
- func (r *Repo) ConsumeQrLoginSession(_ context.Context, nodeID string, atMs int64) error
- 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) CreateOrganization(_ context.Context, o *service.Organization) (string, 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) DeleteExpiredEmailChangeTokens(_ context.Context, beforeMs int64, limit int) (int, error)
- func (r *Repo) DeleteExpiredEmailVerificationTokens(_ context.Context, beforeMs int64, limit int) (int, error)
- func (r *Repo) DeleteExpiredLoginChallenges(_ context.Context, beforeMs int64, limit int) (int, error)
- func (r *Repo) DeleteExpiredPasswordResetTokens(_ context.Context, beforeMs int64, limit int) (int, error)
- func (r *Repo) DeleteExpiredWebAuthnChallenges(_ context.Context, beforeMs int64, limit int) (int, 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, []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) GetOrganization(_ context.Context, orgID string) (*service.Organization, error)
- func (r *Repo) GetOrganizationBySlug(_ context.Context, slug string) (*service.Organization, 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) ListOrganizationsForUser(_ context.Context, userID string) ([]*service.Organization, 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) RegisterUserInTenant(_ context.Context, _, _, _, _, _ string) 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) AddOrganizationMember ¶ added in v0.7.1
func (*Repo) ConsumeQrLoginSession ¶ added in v0.7.2
ConsumeQrLoginSession atomically transitions an approved session to consumed. The mutex held across read+check+write makes this CAS trivially correct for the in-process driver: any second caller sees status != "approved" and returns ErrQrLoginNotPending.
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.
func (*Repo) CreateEmailChangeToken ¶
func (*Repo) CreateEmailVerificationToken ¶
func (*Repo) CreateIdentityVerification ¶ added in v0.4.0
func (*Repo) CreateLoginChallenge ¶
func (*Repo) CreateOAuthIdentity ¶
func (*Repo) CreateOrganization ¶ added in v0.7.1
func (*Repo) CreatePasskeyChallenge ¶
func (*Repo) CreatePasskeyCredential ¶
func (*Repo) CreatePasswordResetToken ¶
func (*Repo) CreateQrLoginSession ¶
func (*Repo) CreateRecoveryCode ¶
func (*Repo) CreateRefreshToken ¶
func (*Repo) CreateTotpCredential ¶
func (*Repo) CreateUser ¶
func (*Repo) DeleteExpiredEmailChangeTokens ¶ added in v0.7.1
func (*Repo) DeleteExpiredEmailVerificationTokens ¶ added in v0.7.1
func (*Repo) DeleteExpiredLoginChallenges ¶ added in v0.7.1
func (*Repo) DeleteExpiredPasswordResetTokens ¶ added in v0.7.1
func (*Repo) DeleteExpiredWebAuthnChallenges ¶ added in v0.7.1
func (*Repo) DeleteLoginChallenge ¶
func (*Repo) DeletePasskeyChallenge ¶
func (*Repo) DeleteRecoveryCodesForUser ¶
func (*Repo) DeleteRefreshToken ¶
func (*Repo) DeleteRefreshTokensForUser ¶
func (*Repo) DeleteTotpCredential ¶
func (*Repo) DeleteTotpCredentialsForUser ¶
func (*Repo) ExecuteAtomic ¶
func (*Repo) FindEmailChangeTokenByHash ¶
func (*Repo) FindEmailVerificationTokenByHash ¶
func (*Repo) FindInvitationByHash ¶
func (*Repo) FindPasswordResetTokenByHash ¶
func (*Repo) FindQrLoginSession ¶
func (*Repo) FindRecoveryCodeByHash ¶
func (*Repo) FindRefreshTokenByHash ¶
func (*Repo) FindRefreshTokenByHashIncludingConsumed ¶
func (*Repo) FindUserByEmail ¶
func (*Repo) FindUserByProviderID ¶
func (*Repo) GetEdgesFrom ¶
func (*Repo) GetEdgesTo ¶
func (*Repo) GetIdentityVerification ¶ added in v0.4.0
func (*Repo) GetLatestIdentityVerificationForUser ¶ added in v0.4.0
func (*Repo) GetLoginChallengeByChallengeID ¶
func (*Repo) GetOrganization ¶ added in v0.7.1
func (*Repo) GetOrganizationBySlug ¶ added in v0.7.1
func (*Repo) GetPasskeyChallenge ¶
func (*Repo) GetPasskeyCredentialByCredID ¶
func (*Repo) GetTotpCredential ¶
func (*Repo) IncrementFailedLoginCount ¶
func (*Repo) ListOAuthIdentitiesForUser ¶
func (*Repo) ListOrganizationsForUser ¶ added in v0.7.1
func (*Repo) ListPasskeyCredentials ¶
func (*Repo) MarkEmailChangeTokenConsumed ¶
func (*Repo) MarkEmailVerificationTokenConsumed ¶
func (*Repo) MarkPasswordResetTokenConsumed ¶
func (*Repo) QueryNodes ¶
func (*Repo) RegisterUserInTenant ¶ added in v0.7.1
RegisterUserInTenant is a no-op on the in-memory driver. The in-memory store bypasses the EntDB two-tier model entirely, so there is no global registry / tenant-membership to enforce.