memory

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2026 License: MIT Imports: 9 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package memory is an in-memory canopy.Store. It is useful for tests and for local development. It is not durable and it does not scale across processes. Use a persistent store such as store/postgres in production.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

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

Store is an in-memory implementation of canopy.Store. It also implements the optional capability interfaces.

func New

func New() *Store

New returns an empty in-memory store.

func (*Store) AcceptInvitation

func (s *Store) AcceptInvitation(
	ctx context.Context,
	invitationID string,
	email string,
	now time.Time,
	member *canopy.Member,
) error

func (*Store) AddTeamMember

func (s *Store) AddTeamMember(ctx context.Context, member *canopy.TeamMember) error

func (*Store) ApplyPasswordReset

func (s *Store) ApplyPasswordReset(
	ctx context.Context,
	identifier string,
	value string,
	now time.Time,
	account *canopy.Account,
) error

ApplyPasswordReset atomically consumes the reset token, updates the password account, revokes sessions, and invalidates every other reset token.

func (*Store) CleanupExpired

func (s *Store) CleanupExpired(ctx context.Context, now time.Time) error

CleanupExpired removes expired session and verification records atomically.

func (*Store) ClearActiveOrganization

func (s *Store) ClearActiveOrganization(ctx context.Context, orgID, userID string) error

func (*Store) ConsumeBackupCode

func (s *Store) ConsumeBackupCode(ctx context.Context, userID, codeHash string) (bool, error)

func (*Store) ConsumeTOTPStep

func (s *Store) ConsumeTOTPStep(ctx context.Context, userID string, counter int64) (bool, error)

func (*Store) ConsumeVerification

func (s *Store) ConsumeVerification(ctx context.Context, identifier, value string, now time.Time) (*canopy.Verification, error)

func (*Store) CreateAccount

func (s *Store) CreateAccount(ctx context.Context, account *canopy.Account) error

func (*Store) CreateInvitation

func (s *Store) CreateInvitation(ctx context.Context, invitation *canopy.Invitation) error

func (*Store) CreateLinkedAccount

func (s *Store) CreateLinkedAccount(
	ctx context.Context,
	identifier string,
	value string,
	now time.Time,
	account *canopy.Account,
) error

CreateLinkedAccount atomically consumes the one-time link-confirmation verification and creates the provider account for the existing user.

func (*Store) CreateMember

func (s *Store) CreateMember(ctx context.Context, member *canopy.Member) error

func (*Store) CreateOrganization

func (s *Store) CreateOrganization(ctx context.Context, org *canopy.Organization) error

func (*Store) CreateOrganizationWithOwner

func (s *Store) CreateOrganizationWithOwner(ctx context.Context, org *canopy.Organization, owner *canopy.Member) error

func (*Store) CreateSession

func (s *Store) CreateSession(ctx context.Context, session *canopy.Session) error

func (*Store) CreateTeam

func (s *Store) CreateTeam(ctx context.Context, team *canopy.Team) error

func (*Store) CreateUser

func (s *Store) CreateUser(ctx context.Context, user *canopy.User) error

func (*Store) CreateUserAccount

func (s *Store) CreateUserAccount(ctx context.Context, user *canopy.User, account *canopy.Account) error

func (*Store) CreateVerification

func (s *Store) CreateVerification(ctx context.Context, v *canopy.Verification) error

func (*Store) DeleteExpiredSessions

func (s *Store) DeleteExpiredSessions(ctx context.Context, now time.Time) error

func (*Store) DeleteExpiredVerifications

func (s *Store) DeleteExpiredVerifications(ctx context.Context, now time.Time) error

func (*Store) DeleteMember

func (s *Store) DeleteMember(ctx context.Context, orgID, userID string) error

func (*Store) DeleteOrganization

func (s *Store) DeleteOrganization(ctx context.Context, id string) error

func (*Store) DeleteSessionByToken

func (s *Store) DeleteSessionByToken(ctx context.Context, token string) error

func (*Store) DeleteTeam

func (s *Store) DeleteTeam(ctx context.Context, orgID, teamID string) error

DeleteTeam removes the team and its team memberships atomically.

func (*Store) DeleteTwoFactor

func (s *Store) DeleteTwoFactor(ctx context.Context, userID string) error

func (*Store) DeleteUserSessions

func (s *Store) DeleteUserSessions(ctx context.Context, userID string) error

func (*Store) DeleteVerificationsByIdentifier

func (s *Store) DeleteVerificationsByIdentifier(ctx context.Context, identifier string) error

func (*Store) EnableTwoFactor

func (s *Store) EnableTwoFactor(ctx context.Context, tf *canopy.TwoFactor, codeHashes []string) error

func (*Store) FindAccount

func (s *Store) FindAccount(ctx context.Context, providerID, accountID string) (*canopy.Account, error)

func (*Store) FindAccountByUserProvider

func (s *Store) FindAccountByUserProvider(ctx context.Context, userID, providerID string) (*canopy.Account, error)

func (*Store) FindInvitation

func (s *Store) FindInvitation(ctx context.Context, id string) (*canopy.Invitation, error)

func (*Store) FindMember

func (s *Store) FindMember(ctx context.Context, orgID, userID string) (*canopy.Member, error)

func (*Store) FindOrganizationByID

func (s *Store) FindOrganizationByID(ctx context.Context, id string) (*canopy.Organization, error)

func (*Store) FindOrganizationBySlug

func (s *Store) FindOrganizationBySlug(ctx context.Context, slug string) (*canopy.Organization, error)

func (*Store) FindSessionByToken

func (s *Store) FindSessionByToken(ctx context.Context, token string) (*canopy.SessionData, error)

func (*Store) FindTeamByID

func (s *Store) FindTeamByID(ctx context.Context, id string) (*canopy.Team, error)

func (*Store) FindTeamMember

func (s *Store) FindTeamMember(ctx context.Context, teamID, userID string) (*canopy.TeamMember, error)

func (*Store) FindUserByEmail

func (s *Store) FindUserByEmail(ctx context.Context, email string) (*canopy.User, error)

func (*Store) FindUserByID

func (s *Store) FindUserByID(ctx context.Context, id string) (*canopy.User, error)

func (*Store) GetTwoFactor

func (s *Store) GetTwoFactor(ctx context.Context, userID string) (*canopy.TwoFactor, error)

func (*Store) ListInvitationsForOrg

func (s *Store) ListInvitationsForOrg(ctx context.Context, orgID string) ([]canopy.Invitation, error)

func (*Store) ListMembers

func (s *Store) ListMembers(ctx context.Context, orgID string) ([]canopy.Member, error)

func (*Store) ListOrganizationsForUser

func (s *Store) ListOrganizationsForUser(ctx context.Context, userID string) ([]canopy.Organization, error)

func (*Store) ListTeamMembers

func (s *Store) ListTeamMembers(ctx context.Context, teamID string) ([]canopy.TeamMember, error)

func (*Store) ListTeamsForOrg

func (s *Store) ListTeamsForOrg(ctx context.Context, orgID string) ([]canopy.Team, error)

func (*Store) ListUserSessions

func (s *Store) ListUserSessions(ctx context.Context, userID string) ([]canopy.Session, error)

func (*Store) ListUsers

func (s *Store) ListUsers(ctx context.Context, q canopy.UserQuery) ([]canopy.User, int, error)

func (*Store) RemoveMemberAndClearSessions

func (s *Store) RemoveMemberAndClearSessions(ctx context.Context, orgID, userID string, now time.Time) error

func (*Store) RemoveTeamMember

func (s *Store) RemoveTeamMember(ctx context.Context, teamID, userID string) error

func (*Store) ReplaceBackupCodes

func (s *Store) ReplaceBackupCodes(ctx context.Context, userID string, codeHashes []string) error

func (*Store) ReplaceVerification

func (s *Store) ReplaceVerification(ctx context.Context, v *canopy.Verification) error

func (*Store) UpdateAccount

func (s *Store) UpdateAccount(ctx context.Context, account *canopy.Account) error

func (*Store) UpdateInvitation

func (s *Store) UpdateInvitation(ctx context.Context, invitation *canopy.Invitation) error

func (*Store) UpdateMember

func (s *Store) UpdateMember(ctx context.Context, member *canopy.Member) error

func (*Store) UpdateMemberRole

func (s *Store) UpdateMemberRole(ctx context.Context, member *canopy.Member, protectedRole string) error

func (*Store) UpdateOrganization

func (s *Store) UpdateOrganization(ctx context.Context, org *canopy.Organization) error

func (*Store) UpdateSession

func (s *Store) UpdateSession(ctx context.Context, session *canopy.Session) error

func (*Store) UpdateTeam

func (s *Store) UpdateTeam(ctx context.Context, team *canopy.Team) error

func (*Store) UpdateUser

func (s *Store) UpdateUser(ctx context.Context, user *canopy.User) error

func (*Store) UpsertTwoFactor

func (s *Store) UpsertTwoFactor(ctx context.Context, tf *canopy.TwoFactor) error

Jump to

Keyboard shortcuts

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