bind

package
v0.1.0-beta.6 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2026 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCodeNotFound = errors.New("bind code not found")
	ErrCodeUsed     = errors.New("bind code already used")
	ErrCodeExpired  = errors.New("bind code expired")
	ErrCodeMismatch = errors.New("bind code context mismatch")
	ErrLinkConflict = errors.New("channel identity user link conflict")
)

Functions

This section is empty.

Types

type Code

type Code struct {
	ID                      string    `json:"id"`
	Platform                string    `json:"platform,omitempty"`
	Token                   string    `json:"token"`
	IssuedByUserID          string    `json:"issued_by_user_id"`
	ExpiresAt               time.Time `json:"expires_at,omitempty"`
	UsedAt                  time.Time `json:"used_at,omitempty"`
	UsedByChannelIdentityID string    `json:"used_by_channel_identity_id,omitempty"`
	CreatedAt               time.Time `json:"created_at"`
}

Code represents a one-time bind code for linking channel identity to user.

type Service

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

Service manages channel identity->user bind code lifecycle.

func NewService

func NewService(log *slog.Logger, pool *pgxpool.Pool, queries *sqlc.Queries) *Service

NewService creates a bind code service.

func (*Service) Consume

func (s *Service) Consume(ctx context.Context, code Code, channelIdentityID string) error

Consume validates and consumes a bind code and links the channel identity to issuer user.

func (*Service) Get

func (s *Service) Get(ctx context.Context, token string) (Code, error)

Get looks up a bind code by token.

func (*Service) Issue

func (s *Service) Issue(ctx context.Context, issuedByUserID, platform string, ttl time.Duration) (Code, error)

Issue creates a new bind code issued by the given user. Platform is optional; when provided, bind consume must happen on the same channel platform.

Jump to

Keyboard shortcuts

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