{"modulePath":"github.com/eric-erki/https-hyperledger.org","version":"v1.4.4","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package server\n\nCopyright IBM Corp. All Rights Reserved.\n\nSPDX-License-Identifier: Apache-2.0\n\nCopyright IBM Corp. All Rights Reserved.\n\nSPDX-License-Identifier: Apache-2.0\n\nCopyright IBM Corp. All Rights Reserved.\n\nSPDX-License-Identifier: Apache-2.0\n\n## Functions\n\n```go\nfunc UnmarshalCommand(raw []byte) (*token.Command, error)\n```\nUnmarshalCommand unmarshal token.Command messages\n\n## Types\n\n```go\ntype ACLProvider interface {\n\t// CheckACL checks access control for the resource for the given channel.\n\t// idinfo is an object such as []*common.SignedData from which\n\t// an id can be extracted for testing against a policy\n\tCheckACL(resName string, channelID string, idinfo interface{}) error\n}\n```\n\n```go\ntype ACLResources struct {\n\tIssueTokens    string\n\tTransferTokens string\n\tListTokens     string\n}\n```\n\n```go\ntype CapabilityChecker interface {\n\tFabToken(channelId string) (bool, error)\n}\n```\nCapabilityChecker is used to check whether or not a channel supports token functions.\n\n```go\ntype Issuer interface {\n\t// Issue creates an import request transaction.\n\tRequestImport(tokensToIssue []*token.TokenToIssue) (*token.TokenTransaction, error)\n\n\t// RequestExpectation allows indirect import based on the expectation.\n\t// It creates a token transaction with the outputs as specified in the expectation.\n\tRequestExpectation(request *token.ExpectationRequest) (*token.TokenTransaction, error)\n}\n```\nAn Issuer creates token import requests.\n\n```go\ntype Manager struct {\n\tLedgerManager ledger.LedgerManager\n}\n```\nManager implements  token/server/TMSManager interface TODO: it will be updated after lscc-baased tms configuration is available\n\n```go\nfunc (manager *Manager) GetIssuer(channel string, privateCredential, publicCredential []byte) (Issuer, error)\n```\nFor now it returns a plain issuer. After lscc-based tms configuration is available, it will be updated to return an issuer configured for the specific channel\n\n```go\nfunc (manager *Manager) GetTransactor(channel string, privateCredential, publicCredential []byte) (Transactor, error)\n```\nGetTransactor returns a Transactor bound to the passed channel and whose credential is the tuple (privateCredential, publicCredential).\n\n```go\ntype Marshaler interface {\n\tMarshalCommandResponse(command []byte, responsePayload interface{}) (*token.SignedCommandResponse, error)\n}\n```\nA Marshaler is responsible for marshaling and signging command responses.\n\n```go\ntype PeerLedgerManager struct {\n}\n```\nPeerLedgerManager implements the LedgerManager interface by using the peer infrastructure\n\n```go\nfunc (*PeerLedgerManager) GetLedgerReader(channel string) (ledger.LedgerReader, error)\n```\n\n```go\ntype PolicyBasedAccessControl struct {\n\tACLProvider  ACLProvider\n\tACLResources *ACLResources\n}\n```\nPolicyBasedAccessControl implements token command access control functions.\n\n```go\nfunc (ac *PolicyBasedAccessControl) Check(sc *token.SignedCommand, c *token.Command) error\n```\n\n```go\ntype PolicyChecker interface {\n\tCheck(sc *token.SignedCommand, c *token.Command) error\n}\n```\nA PolicyChecker is responsible for performing policy based access control checks related to token commands.\n\n```go\ntype Prover struct {\n\tCapabilityChecker CapabilityChecker\n\tMarshaler         Marshaler\n\tPolicyChecker     PolicyChecker\n\tTMSManager        TMSManager\n}\n```\nA Provider is responslble for processing token commands.\n\n```go\nfunc NewProver(policyChecker PolicyChecker, signingIdentity SignerIdentity) (*Prover, error)\n```\nNewProver creates a Prover\n\n```go\nfunc (s *Prover) ListUnspentTokens(ctxt context.Context, header *token.Header, listRequest *token.ListRequest) (*token.CommandResponse_UnspentTokens, error)\n```\n\n```go\nfunc (s *Prover) MarshalErrorResponse(command []byte, e error) (*token.SignedCommandResponse, error)\n```\n\n```go\nfunc (s *Prover) ProcessCommand(ctx context.Context, sc *token.SignedCommand) (*token.SignedCommandResponse, error)\n```\n\n```go\nfunc (s *Prover) RequestApprove(ctx context.Context, header *token.Header, request *token.ApproveRequest) (*token.CommandResponse_TokenTransaction, error)\n```\n\n```go\nfunc (s *Prover) RequestExpectation(ctx context.Context, header *token.Header, request *token.ExpectationRequest) (*token.CommandResponse_TokenTransaction, error)\n```\nRequestExpectation gets an issuer or transactor and creates a token transaction response for import, transfer or redemption.\n\n```go\nfunc (s *Prover) RequestImport(ctx context.Context, header *token.Header, requestImport *token.ImportRequest) (*token.CommandResponse_TokenTransaction, error)\n```\n\n```go\nfunc (s *Prover) RequestRedeem(ctx context.Context, header *token.Header, request *token.RedeemRequest) (*token.CommandResponse_TokenTransaction, error)\n```\n\n```go\nfunc (s *Prover) RequestTransfer(ctx context.Context, header *token.Header, request *token.TransferRequest) (*token.CommandResponse_TokenTransaction, error)\n```\n\n```go\nfunc (s *Prover) RequestTransferFrom(ctx context.Context, header *token.Header, request *token.TransferRequest) (*token.CommandResponse_TokenTransaction, error)\n```\n\n```go\nfunc (s *Prover) ValidateHeader(header *token.Header) error\n```\n\n```go\ntype ResponseMarshaler struct {\n\tSigner  Signer\n\tCreator []byte\n\tTime    TimeFunc\n}\n```\nResponseMarshaler produces token.SignedCommandResponse\n\n```go\nfunc NewResponseMarshaler(signerID SignerIdentity) (*ResponseMarshaler, error)\n```\n\n```go\nfunc (s *ResponseMarshaler) MarshalCommandResponse(command []byte, responsePayload interface{}) (*token.SignedCommandResponse, error)\n```\n\n```go\ntype Signer interface {\n\t// Sign signs the given payload and returns a signature\n\tSign([]byte) ([]byte, error)\n}\n```\n\n```go\ntype SignerIdentity interface {\n\tSigner\n\n\t// Serialize returns a byte representation of this identity which is used to verify\n\t// messages signed by this SignerIdentity\n\tSerialize() ([]byte, error)\n}\n```\nSignerIdentity signs messages and serializes its public identity to bytes\n\n```go\ntype TMSManager interface {\n\t// GetIssuer returns an Issuer bound to the passed channel and whose credential\n\t// is the tuple (privateCredential, publicCredential).\n\tGetIssuer(channel string, privateCredential, publicCredential []byte) (Issuer, error)\n\n\t// GetTransactor returns a Transactor bound to the passed channel and whose credential\n\t// is the tuple (privateCredential, publicCredential).\n\tGetTransactor(channel string, privateCredential, publicCredential []byte) (Transactor, error)\n}\n```\n\n```go\ntype TimeFunc func() time.Time\n```\n\n```go\ntype TokenCapabilityChecker struct {\n\tPeerOps peer.Operations\n}\n```\nTokenCapabilityChecker implements CapabilityChecker interface\n\n```go\nfunc (c *TokenCapabilityChecker) FabToken(channelId string) (bool, error)\n```\n\n```go\ntype Transactor interface {\n\t// RequestTransfer Create data associated to the transfer of a token assuming\n\t// an application-level identity. The inTokens bytes are the identifiers\n\t// of the outputs, the details of which need to be looked up from the ledger.\n\tRequestTransfer(request *token.TransferRequest) (*token.TokenTransaction, error)\n\n\t// RequestRedeem allows the redemption of the tokens in the input tokenIds\n\t// It queries the ledger to read detail for each token id.\n\t// It creates a token transaction with an output for redeemed tokens and\n\t// possibly another output to transfer the remaining tokens, if any, to the creator\n\tRequestRedeem(request *token.RedeemRequest) (*token.TokenTransaction, error)\n\n\t// ListTokens returns a slice of unspent tokens owned by this transactor\n\tListTokens() (*token.UnspentTokens, error)\n\n\t// RequestApprove creates a token transaction that includes the data necessary\n\t// for approve\n\tRequestApprove(request *token.ApproveRequest) (*token.TokenTransaction, error)\n\n\t// RequestTransferFrom creates a token transaction that includes the data necessary\n\t// for transferring the tokens of a third party that previsouly delegated the transfer\n\t// via an approve request\n\tRequestTransferFrom(request *token.TransferRequest) (*token.TokenTransaction, error)\n\n\t// RequestExpectation allows indirect transfer based on the expectation.\n\t// It creates a token transaction with the outputs as specified in the expectation.\n\tRequestExpectation(request *token.ExpectationRequest) (*token.TokenTransaction, error)\n\n\t// Done releases any resources held by this transactor\n\tDone()\n}\n```\nTransactor allows to operate on issued tokens\n\n","path":"github.com/eric-erki/https-hyperledger.org/token/server","name":"server","synopsis":"","isRedistributable":true}
