handlers

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package handlers contains the handlers for the API. This layer is responsible for handling the requests and responses, in more details: - validating the requests - formatting the responses - handling the errors - delegating the requests to the services

Index

Constants

View Source
const (
	// Authentication headers
	HeaderClientID = "X-Client-ID"

	// iDenfy webhook headers
	HeaderIdenfySignature = "Idenfy-Signature"

	// Query parameters
	QueryParamClientID = "client_id"
	QueryParamTwinID   = "twin_id"

	HandlerTimeout = 5 * time.Second
)

Variables

This section is empty.

Functions

func HandleError

func HandleError(c *fiber.Ctx, err error) error

func HandleServiceError

func HandleServiceError(c *fiber.Ctx, err *errors.ServiceError) error

Types

type Handler

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

func NewHandler

func NewHandler(kycService *services.KYCService, config *config.Config, logger *slog.Logger) *Handler

@contact.name threefold.io @contact.url https://threefold.io @contact.email info@threefold.io @BasePath /

func (*Handler) GetOrCreateVerificationToken

func (h *Handler) GetOrCreateVerificationToken() fiber.Handler

@Summary Get or Generate iDenfy Verification Token @Description Returns a token for a client @Tags Token @Accept json @Produce json @Param X-Client-ID header string true "TFChain SS58Address" minlength(48) maxlength(48) @Param X-Challenge header string true "hex-encoded message `{api-domain}:{timestamp}`" @Param X-Signature header string true "hex-encoded sr25519|ed25519 signature" minlength(128) maxlength(128) @Success 200 {object} object{result=responses.TokenResponse} "Existing token retrieved" @Success 201 {object} object{result=responses.TokenResponse} "New token created" @Failure 400 {object} object{error=string} @Failure 401 {object} object{error=string} @Failure 402 {object} object{error=string} @Failure 403 {object} object{error=string} @Failure 409 {object} object{error=string} @Failure 500 {object} object{error=string} @Failure 503 {object} object{error=string} @Router /api/v1/token [post]

func (*Handler) GetServiceConfigs

func (h *Handler) GetServiceConfigs() fiber.Handler

@Summary Get Service Configs @Description Returns the service configs @Tags Misc @Success 200 {object} object{result=responses.AppConfigsResponse} @Router /api/v1/configs [get]

func (*Handler) GetServiceVersion

func (h *Handler) GetServiceVersion() fiber.Handler

@Summary Get Service Version @Description Returns the service version @Tags Misc @Success 200 {object} object{result=responses.AppVersionResponse} @Router /api/v1/version [get]

func (*Handler) GetVerificationData

func (h *Handler) GetVerificationData() fiber.Handler

@Summary Get Verification Data @Description Returns the verification data for a client @Tags Verification @Accept json @Produce json @Param X-Client-ID header string true "TFChain SS58Address" minlength(48) maxlength(48) @Param X-Challenge header string true "hex-encoded message `{api-domain}:{timestamp}`" @Param X-Signature header string true "hex-encoded sr25519|ed25519 signature" minlength(128) maxlength(128) @Success 200 {object} object{result=responses.VerificationDataResponse} @Failure 400 {object} object{error=string} @Failure 401 {object} object{error=string} @Failure 404 {object} object{error=string} @Failure 500 {object} object{error=string} @Router /api/v1/data [get]

func (*Handler) GetVerificationStatus

func (h *Handler) GetVerificationStatus() fiber.Handler

@Summary Get Verification Status @Description Returns the verification status for a client @Tags Verification @Accept json @Produce json @Param client_id query string false "TFChain SS58Address" minlength(48) maxlength(48) @Param twin_id query string false "Twin ID" minlength(1) @Success 200 {object} object{result=responses.VerificationStatusResponse} @Failure 400 {object} object{error=string} @Failure 404 {object} object{error=string} @Failure 500 {object} object{error=string} @Failure 503 {object} object{error=string} @Router /api/v1/status [get]

func (*Handler) HealthCheck

func (h *Handler) HealthCheck(dbClient *mongo.Client) fiber.Handler

@Summary Health Check @Description Returns the health status of the service @Tags Health @Success 200 {object} object{result=responses.HealthResponse} @Router /api/v1/health [get]

func (*Handler) ProcessDocExpirationNotification

func (h *Handler) ProcessDocExpirationNotification() fiber.Handler

@Summary Process Doc Expiration Notification @Description Processes the doc expiration notification for a client @Tags Webhooks @Accept json @Produce json @Success 200 @Router /webhooks/idenfy/id-expiration [post]

func (*Handler) ProcessVerificationResult

func (h *Handler) ProcessVerificationResult() fiber.Handler

@Summary Process Verification Update @Description Processes the verification update for a client @Tags Webhooks @Accept json @Produce json @Success 200 @Router /webhooks/idenfy/verification-update [post]

Jump to

Keyboard shortcuts

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