service

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2026 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUserAlreadyRegistered  = errors.New("user already registered")
	ErrNotWhitelisted         = errors.New("address not whitelisted for registration")
	ErrPartyAlreadyAllocated  = errors.New("canton party already allocated for this user")
	ErrInvalidCantonSignature = errors.New("invalid Canton signature")
	ErrPartyAlreadyRegistered = errors.New("canton party already registered")
)
View Source
var (
	ErrTopologyNotFound = errors.New("topology not found")
	ErrTopologyExpired  = errors.New("topology expired")
)

Functions

func RegisterRoutes

func RegisterRoutes(r chi.Router, service Service, logger *zap.Logger)

RegisterRoutes registers HTTP endpoints for registration service on the given chi router

Types

type HTTP

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

HTTP wraps the Service to provide HTTP endpoints

type Service

type Service interface {
	RegisterWeb3User(ctx context.Context, req *user.RegisterRequest) (*user.RegisterResponse, error)
	RegisterCantonNativeUser(ctx context.Context, req *user.RegisterRequest) (*user.RegisterResponse, error)
	PrepareExternalRegistration(ctx context.Context, req *user.RegisterRequest) (*user.PrepareTopologyResponse, error)
	GetUser(ctx context.Context, evmAddress, msg, sig string) (*user.User, error)
}

Service defines the interface for the registration business logic

func NewLog

func NewLog(svc Service, logger *zap.Logger) Service

NewLog creates a logging decorator for the registration Service. It logs method entry/exit, duration, errors, and sanitized request/response data.

func NewService

func NewService(
	store Store,
	cantonClient canton.Identity,
	keyCipher keys.KeyCipher,
	logger *zap.Logger,
	skipCantonSignatureVerification bool,
	skipWhitelistCheck bool,
	topologyCache TopologyCacheProvider,
) Service

NewService creates a new registration service

type Store

type Store interface {
	UserExists(ctx context.Context, evmAddress string) (bool, error)
	IsWhitelisted(ctx context.Context, evmAddress string) (bool, error)
	CreateUser(ctx context.Context, user *user.User) error
	GetUserByCantonPartyID(ctx context.Context, partyID string) (*user.User, error)
	GetUserByEVMAddress(ctx context.Context, evmAddress string) (*user.User, error)
	DeleteUser(ctx context.Context, evmAddress string) error
}

Store is the narrow data-access interface for the registration service. Defined here to keep registration service decoupled from userstore implementation details.

type TopologyCache

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

TopologyCache stores pending topology data for two-step external user registration.

func NewTopologyCache

func NewTopologyCache(ttl time.Duration) *TopologyCache

NewTopologyCache creates a new topology cache with the given TTL.

func (*TopologyCache) GetAndDelete

func (c *TopologyCache) GetAndDelete(token string) (*user.PendingTopology, error)

GetAndDelete atomically retrieves and removes a pending topology.

func (*TopologyCache) Put

func (c *TopologyCache) Put(token string, topo *identity.ExternalPartyTopology, spkiKey []byte)

Put stores a pending topology keyed by registration token.

func (*TopologyCache) Start

func (c *TopologyCache) Start(ctx context.Context) error

Start runs a background goroutine that periodically removes expired entries.

type TopologyCacheProvider

type TopologyCacheProvider interface {
	Put(token string, topo *identity.ExternalPartyTopology, spkiKey []byte)
	GetAndDelete(token string) (*user.PendingTopology, error)
}

TopologyCacheProvider is the interface for storing and retrieving pending topology data.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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