cbr

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2021 License: MPL-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrDupRedeem - Error for duplicate redemptions
	ErrDupRedeem = errors.New("cbr duplicate redemption")
	// ErrBadRequest - Error for cbr bad requests
	ErrBadRequest = errors.New("cbr bad request")
)

Functions

This section is empty.

Types

type Client

type Client interface {
	CreateIssuer(ctx context.Context, issuer string, maxTokens int) error
	GetIssuer(ctx context.Context, issuer string) (*IssuerResponse, error)
	SignCredentials(ctx context.Context, issuer string, creds []string) (*CredentialsIssueResponse, error)
	RedeemCredential(ctx context.Context, issuer string, preimage string, signature string, payload string) error
	RedeemCredentials(ctx context.Context, credentials []CredentialRedemption, payload string) error
}

Client abstracts over the underlying client

func New

func New() (Client, error)

New returns a new HTTPClient, retrieving the base URL from the environment

type ClientWithPrometheus

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

ClientWithPrometheus implements Client interface with all methods wrapped with Prometheus metrics

func NewClientWithPrometheus

func NewClientWithPrometheus(base Client, instanceName string) ClientWithPrometheus

NewClientWithPrometheus returns an instance of the Client decorated with prometheus summary metric

func (ClientWithPrometheus) CreateIssuer

func (_d ClientWithPrometheus) CreateIssuer(ctx context.Context, issuer string, maxTokens int) (err error)

CreateIssuer implements Client

func (ClientWithPrometheus) GetIssuer

func (_d ClientWithPrometheus) GetIssuer(ctx context.Context, issuer string) (ip1 *IssuerResponse, err error)

GetIssuer implements Client

func (ClientWithPrometheus) RedeemCredential

func (_d ClientWithPrometheus) RedeemCredential(ctx context.Context, issuer string, preimage string, signature string, payload string) (err error)

RedeemCredential implements Client

func (ClientWithPrometheus) RedeemCredentials

func (_d ClientWithPrometheus) RedeemCredentials(ctx context.Context, credentials []CredentialRedemption, payload string) (err error)

RedeemCredentials implements Client

func (ClientWithPrometheus) SignCredentials

func (_d ClientWithPrometheus) SignCredentials(ctx context.Context, issuer string, creds []string) (cp1 *CredentialsIssueResponse, err error)

SignCredentials implements Client

type CredentialRedeemRequest

type CredentialRedeemRequest struct {
	TokenPreimage string `json:"t"`
	Signature     string `json:"signature"`
	Payload       string `json:"payload"`
}

CredentialRedeemRequest is a request to redeem a single token toward some payload

type CredentialRedemption

type CredentialRedemption struct {
	Issuer        string `json:"issuer"`
	TokenPreimage string `json:"t"`
	Signature     string `json:"signature"`
}

CredentialRedemption includes info needed to redeem a single token

type CredentialsIssueRequest

type CredentialsIssueRequest struct {
	BlindedTokens []string `json:"blinded_tokens"`
}

CredentialsIssueRequest is a request to issue more tokens

type CredentialsIssueResponse

type CredentialsIssueResponse struct {
	BatchProof   string   `json:"batch_proof"`
	SignedTokens []string `json:"signed_tokens"`
}

CredentialsIssueResponse contains the signed tokens and batch proof

type CredentialsRedeemRequest

type CredentialsRedeemRequest struct {
	Credentials []CredentialRedemption `json:"tokens"`
	Payload     string                 `json:"payload"`
}

CredentialsRedeemRequest is a request to redeem one or more tokens toward some payload

type HTTPClient

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

HTTPClient wraps http.Client for interacting with the cbr server

func (*HTTPClient) CreateIssuer

func (c *HTTPClient) CreateIssuer(ctx context.Context, issuer string, maxTokens int) error

CreateIssuer with the provided name and token cap

func (*HTTPClient) GetIssuer

func (c *HTTPClient) GetIssuer(ctx context.Context, issuer string) (*IssuerResponse, error)

GetIssuer by name

func (*HTTPClient) RedeemCredential

func (c *HTTPClient) RedeemCredential(ctx context.Context, issuer string, preimage string, signature string, payload string) error

RedeemCredential that was issued by the specified issuer

func (*HTTPClient) RedeemCredentials

func (c *HTTPClient) RedeemCredentials(ctx context.Context, credentials []CredentialRedemption, payload string) error

RedeemCredentials that were issued by the specified issuer

func (*HTTPClient) SignCredentials

func (c *HTTPClient) SignCredentials(ctx context.Context, issuer string, creds []string) (*CredentialsIssueResponse, error)

SignCredentials using a particular issuer

type IssuerCreateRequest

type IssuerCreateRequest struct {
	Name      string `json:"name"`
	MaxTokens int    `json:"max_tokens"`
}

IssuerCreateRequest is a request to create a new issuer

type IssuerResponse

type IssuerResponse struct {
	Name      string `json:"name"`
	PublicKey string `json:"public_key"`
}

IssuerResponse contains detais about a newly created or fetched issuer

Directories

Path Synopsis
Package mock_cbr is a generated GoMock package.
Package mock_cbr is a generated GoMock package.

Jump to

Keyboard shortcuts

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