Documentation ¶
Index ¶
- Constants
- Variables
- func AppendPrefix(prefix string, key []byte) []byte
- func AppendSignerId(signerId string, k []byte) []byte
- func GetSignerIDByApiKey(lcApiKey string) string
- func NewLcClient(lcApiKey, lcLedger, host, port, lcCertPath string, skipTlsVerify, noTls bool, ...) (*sdk.LcClient, error)
- func NewLcClientByContext(context store.CurrentContext, lcApiKey string, lcLedger string, ...) (*sdk.LcClient, error)
- type Artifact
- type ArtifactResponse
- type Error
- type LcArtifact
- func ItemToLcArtifact(item *schema.ItemExt) (*LcArtifact, error)
- func LcVerifyEnv(hash, lcLedger, signerID string) (a *LcArtifact, err error)
- func PublicCNLCVerify(hash, lcLedger, signerID, lcHost, lcPort, lcCert string, ...) (a *LcArtifact, err error)
- func VerifiableItemExtToLcArtifact(item *schema.VerifiableItemExt) (*LcArtifact, error)
- func ZItemToLcArtifact(ie *schema.ZItemExt) (*LcArtifact, error)
- type LcSignOption
- type LcUser
- func (u *LcUser) CheckConnectionPublicKey(enforceSignatureVerify bool) error
- func (u *LcUser) LoadArtifact(hash, signerID string, uid string, tx uint64, gRPCMetadata map[string][]string) (lc *LcArtifact, verified bool, err error)
- func (u *LcUser) LoadArtifacts(signerID string, hashes []string, gRPCMetadata map[string][]string) (artifacts []*LcArtifact, verified []bool, errs []error, err error)
- func (u LcUser) RequireFeatOrErr(feat string) error
- func (u LcUser) Sign(artifact Artifact, options ...LcSignOption) (uint64, error)
- func (u LcUser) SignMulti(artifacts []*Artifact, options [][]LcSignOption) (uint64, error)
- type Metadata
- type PackageDetails
- type SignOption
- type User
Constants ¶
const ( HttpPort = "80" HttpsPort = "443" DefaultHost = "cas.codenotary.com" )
Variables ¶
var ErrNotFound = fmt.Errorf("artifact is not found")
ErrNotVerified is returned when an artifact is not found on CNLC
var ErrNotVerified = fmt.Errorf("artifact is not verified")
ErrNotVerified is returned when an artifact is not verified on CNLC
Functions ¶
func AppendPrefix ¶
func AppendSignerId ¶
func GetSignerIDByApiKey ¶
func NewLcClient ¶
Types ¶
type Artifact ¶
type Artifact struct { Kind string Name string Hash string Size uint64 ContentType string IncludedIn []PackageDetails Deps []PackageDetails Metadata }
Artifact represents the set of all relevant information gathered from a digital asset.
func (Artifact) ToLcArtifact ¶
func (a Artifact) ToLcArtifact() *LcArtifact
type ArtifactResponse ¶
type ArtifactResponse struct { // root fields Kind string `json:"kind" yaml:"kind" cas:"Kind"` Name string `json:"name" yaml:"name" cas:"Name"` Hash string `json:"hash" yaml:"hash" cas:"Hash"` Size uint64 `json:"size" yaml:"size" cas:"Size"` ContentType string `json:"contentType" yaml:"contentType" cas:"ContentType"` URL string `json:"url" yaml:"url" cas:"URL"` // custom metadata Metadata Metadata `json:"metadata" yaml:"metadata" cas:"Metadata"` // ArtifactResponse specific Status string `json:"status,omitempty" yaml:"status,omitempty"` }
ArtifactResponse holds artifact values returned by the platform.
func (ArtifactResponse) Artifact ¶
func (a ArtifactResponse) Artifact() *Artifact
Artifact returns an new *Artifact from a
func (ArtifactResponse) String ¶
func (a ArtifactResponse) String() string
type Error ¶
type Error struct { Description string `json:"description"` Status int `json:"status"` Message string `json:"message"` Path string `json:"path"` Timestamp string `json:"timestamp"` Error string `json:"error"` FieldErrors []string `json:"fieldErrors"` }
Error represents a CodeNotary platform's API returned error.
type LcArtifact ¶
type LcArtifact struct { // root fields Uid string `json:"uid" yaml:"uid" cas:"UID"` Kind string `json:"kind" yaml:"kind" cas:"Kind"` Name string `json:"name" yaml:"name" cas:"Name"` Hash string `json:"hash" yaml:"hash" cas:"Hash"` Size uint64 `json:"size" yaml:"size" cas:"Size"` Timestamp time.Time `json:"timestamp,omitempty" yaml:"timestamp" cas:"Timestamp"` ContentType string `json:"contentType" yaml:"contentType" cas:"ContentType"` // custom metadata Metadata Metadata `json:"metadata" yaml:"metadata" cas:"Metadata"` Signer string `json:"signer" yaml:"signer" cas:"SignerID"` Revoked *time.Time `json:"revoked,omitempty" yaml:"revoked" cas:"Apikey revoked"` Status meta.Status `json:"status" yaml:"status" cas:"Status"` Ledger string `json:"ledger,omitempty" yaml:"ledger"` IncludedIn []PackageDetails `json:"included_in,omitempty" yaml:"included_in,omitempty" cas:"Included in"` Deps []PackageDetails `json:"bom,omitempty" yaml:"bom,omitempty" cas:"Dependencies"` PublicKey string }
func ItemToLcArtifact ¶
func ItemToLcArtifact(item *schema.ItemExt) (*LcArtifact, error)
func LcVerifyEnv ¶
func LcVerifyEnv(hash, lcLedger, signerID string) (a *LcArtifact, err error)
PublicCNLCVerify allow connection and verification on CNLC ledger with a single call using environment variables. LcLedger parameter is used when a cross-ledger key is provided in order to specify the ledger on which future operations will be directed. Empty string is accepted. signerID parameter is used to filter result on a specific signer ID. If empty value is provided is used the current logged signerID value.
func PublicCNLCVerify ¶
func PublicCNLCVerify(hash, lcLedger, signerID, lcHost, lcPort, lcCert string, lcSkipTlsVerify, lcNoTls bool) (a *LcArtifact, err error)
PublicCNLCVerify allow connection and verification on CNLC ledger with a single call. LcLedger parameter is used when a cross-ledger key is provided in order to specify the ledger on which future operations will be directed. Empty string is accepted signerID parameter is used to filter result on a specific signer ID. If empty value is provided is used the current logged signerID value.
func VerifiableItemExtToLcArtifact ¶
func VerifiableItemExtToLcArtifact(item *schema.VerifiableItemExt) (*LcArtifact, error)
func ZItemToLcArtifact ¶
func ZItemToLcArtifact(ie *schema.ZItemExt) (*LcArtifact, error)
func (*LcArtifact) Date ¶
func (lca *LcArtifact) Date() string
Date returns a RFC3339 formatted string of verification time (v.Timestamp), if any, otherwise an empty string.
type LcSignOption ¶
type LcSignOption func(*lcSignOpts) error
SignOption is a functional option for signing operations
func LcSignWithBom ¶
func LcSignWithBom(bom []*schema.VCNDependency) LcSignOption
func LcSignWithStatus ¶
func LcSignWithStatus(status meta.Status) LcSignOption
SignWithStatus returns the functional option for the given status.
type LcUser ¶
type LcUser struct { Client *sdk.LcClient PrivateKey *ed25519.PrivateKey }
User represent a CodeNotary platform user.
func GetOrCreateLcUser ¶
func GetOrCreateLcUser(lcApiKey, lcLedger, host, port, lcCert string, skipTlsVerifySet, skipTlsVerify, noTlsSet, noTls bool, signingPubKey *ecdsa.PublicKey, publicAuth bool) (*LcUser, error)
GetOrCreateLcUser returns a new User instance configured with provided parameters or an error. Before creating a new user it looks for a context one LcLedger parameter is used when a cross-ledger key is provided in order to specify the ledger on which future operations will be directed. Empty string is accepted
func NewLcUserVolatile ¶
NewLcUserVolatile returns a new User instance without a backing cfg file.
func (*LcUser) CheckConnectionPublicKey ¶
CheckConnectionPublicKey the aim of this method is to guarantee that the connection between cas and a CAS server are verified by the first login auto trusted signature. This method fetches an immudb state, checks if the public key provided to the immudb client match server signature and saves locally such key. In addition it checks if a previously trusted (local) key is the same to the current one used by client. This guarantee that the connection is established on a previously trusted server. If enforceSignatureVerify is TRUE it requires an explicit fingerprint confirmation. NOTE: if CAS_SIGNING_PUB_KEY_FILE or CAS_SIGNING_PUB_KEY environment flag or arguments are provided this method is not called.
func (*LcUser) LoadArtifact ¶
func (u *LcUser) LoadArtifact( hash, signerID string, uid string, tx uint64, gRPCMetadata map[string][]string, ) (lc *LcArtifact, verified bool, err error)
LoadArtifact fetches and returns an *lcArtifact for the given hash and current u, if any.
func (*LcUser) LoadArtifacts ¶
func (u *LcUser) LoadArtifacts( signerID string, hashes []string, gRPCMetadata map[string][]string, ) (artifacts []*LcArtifact, verified []bool, errs []error, err error)
LoadArtifacts fetches and returns multiple *lcArtifact for the given hashes and current u, if any.
func (LcUser) RequireFeatOrErr ¶
type Metadata ¶
type Metadata map[string]interface{}
Metadata holds custom artifact attributes
func (Metadata) Get ¶
Get returns the value for the given key, if any, otherwise returns defaultValue
type PackageDetails ¶
type PackageDetails struct { Name string `json:"name" yaml:"name" cas:"name"` Version string `json:"version,omitempty" yaml:"version,omitempty" cas:"version"` Hash string `json:"hash" yaml:"hash" cas:"hash"` Status meta.Status `json:"status" yaml:"status" cas:"status"` License string `json:"license,omitempty" yaml:"license"` }
type SignOption ¶
type SignOption func(*signOpts) error
SignOption is a functional option for signing operations
func SignWithStatus ¶
func SignWithStatus(status meta.Status) SignOption
SignWithStatus returns the functional option for the given status.
type User ¶
type User struct {
// contains filtered or unexported fields
}
User represent a CodeNotary platform user.
func (*User) ClearAuth ¶
func (u *User) ClearAuth()
ClearAuth deletes the stored authentication token.
func (User) Config ¶
Config returns the User configuration object (see store.User), if any. It returns nil if the User is not properly initialized.