Documentation ¶
Index ¶
- Variables
- type Client
- type ClientWithPrometheus
- func (_d ClientWithPrometheus) CreateIssuer(ctx context.Context, issuer string, maxTokens int) (err error)
- func (_d ClientWithPrometheus) CreateIssuerV3(ctx context.Context, createIssuerV3 IssuerRequest) (err error)
- func (_d ClientWithPrometheus) GetIssuer(ctx context.Context, issuer string) (ip1 *IssuerResponse, err error)
- func (_d ClientWithPrometheus) GetIssuerV3(ctx context.Context, issuer string) (ip1 *IssuerResponse, err error)
- func (_d ClientWithPrometheus) RedeemCredential(ctx context.Context, issuer string, preimage string, signature string, ...) (err error)
- func (_d ClientWithPrometheus) RedeemCredentialV3(ctx context.Context, issuer string, preimage string, signature string, ...) (err error)
- func (_d ClientWithPrometheus) RedeemCredentials(ctx context.Context, credentials []CredentialRedemption, payload string) (err error)
- func (_d ClientWithPrometheus) SignCredentials(ctx context.Context, issuer string, creds []string) (cp1 *CredentialsIssueResponse, err error)
- type CredentialRedeemRequest
- type CredentialRedemption
- type CredentialsIssueRequest
- type CredentialsIssueResponse
- type CredentialsRedeemRequest
- type HTTPClient
- func (c *HTTPClient) CreateIssuer(ctx context.Context, issuer string, maxTokens int) error
- func (c *HTTPClient) CreateIssuerV3(ctx context.Context, issuerRequest IssuerRequest) error
- func (c *HTTPClient) GetIssuer(ctx context.Context, issuer string) (*IssuerResponse, error)
- func (c *HTTPClient) GetIssuerV3(ctx context.Context, issuer string) (*IssuerResponse, error)
- func (c *HTTPClient) RedeemCredential(ctx context.Context, issuer string, preimage string, signature string, ...) error
- func (c *HTTPClient) RedeemCredentialV3(ctx context.Context, issuer string, preimage string, signature string, ...) error
- func (c *HTTPClient) RedeemCredentials(ctx context.Context, credentials []CredentialRedemption, payload string) error
- func (c *HTTPClient) SignCredentials(ctx context.Context, issuer string, creds []string) (*CredentialsIssueResponse, error)
- type IssuerCreateRequest
- type IssuerRequest
- type IssuerResponse
Constants ¶
This section is empty.
Variables ¶
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 creates an issuer. CreateIssuer(ctx context.Context, issuer string, maxTokens int) error // CreateIssuerV3 creates a version 3 issuer. CreateIssuerV3(ctx context.Context, createIssuerV3 IssuerRequest) error // GetIssuer returns issuers prior to version 3. GetIssuer(ctx context.Context, issuer string) (*IssuerResponse, error) // GetIssuerV3 returns issuers based on issuer name. Should be used when retrieving version 3 issuers. GetIssuerV3(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 RedeemCredentialV3(ctx context.Context, issuer string, preimage string, signature string, payload string) error }
Client abstracts over the underlying client
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) CreateIssuerV3 ¶
func (_d ClientWithPrometheus) CreateIssuerV3(ctx context.Context, createIssuerV3 IssuerRequest) (err error)
CreateIssuerV3 implements Client
func (ClientWithPrometheus) GetIssuer ¶
func (_d ClientWithPrometheus) GetIssuer(ctx context.Context, issuer string) (ip1 *IssuerResponse, err error)
GetIssuer implements Client
func (ClientWithPrometheus) GetIssuerV3 ¶
func (_d ClientWithPrometheus) GetIssuerV3(ctx context.Context, issuer string) (ip1 *IssuerResponse, err error)
GetIssuerV3 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) RedeemCredentialV3 ¶
func (_d ClientWithPrometheus) RedeemCredentialV3(ctx context.Context, issuer string, preimage string, signature string, payload string) (err error)
RedeemCredentialV3 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 ¶
CreateIssuer with the provided name and token cap
func (*HTTPClient) CreateIssuerV3 ¶
func (c *HTTPClient) CreateIssuerV3(ctx context.Context, issuerRequest IssuerRequest) error
CreateIssuerV3 creates a version 3 issuer.
func (*HTTPClient) GetIssuer ¶
func (c *HTTPClient) GetIssuer(ctx context.Context, issuer string) (*IssuerResponse, error)
GetIssuer by name
func (*HTTPClient) GetIssuerV3 ¶
func (c *HTTPClient) GetIssuerV3(ctx context.Context, issuer string) (*IssuerResponse, error)
GetIssuerV3 returns issuers based on issuer name. Should be used when retrieving version 3 issuers.
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) RedeemCredentialV3 ¶
func (c *HTTPClient) RedeemCredentialV3(ctx context.Context, issuer string, preimage string, signature string, payload string) error
RedeemCredentialV3 redeems a version 3 token 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 ¶
IssuerCreateRequest is a request to create a new issuer
type IssuerRequest ¶
type IssuerRequest struct { Name string `json:"name"` Version int `json:"version"` Cohort int16 `json:"cohort"` MaxTokens int `json:"max_tokens"` ValidFrom *time.Time `json:"valid_from"` // start of issuance ExpiresAt *time.Time `json:"expires_at"` Duration string `json:"duration"` // valid duration of each sub issuer Buffer int `json:"buffer"` // number of sub issuers in the future Overlap int `json:"overlap"` // number of days sub issuer should overlap }
IssuerRequest - create a new issuer request structure