Documentation ¶
Index ¶
- Variables
- func AppendAttachment(attachHash string, key []byte) []byte
- func AppendLabel(label string, key []byte) []byte
- func AppendPrefix(prefix string, key []byte) []byte
- func AppendSignerId(signerId string, k []byte) []byte
- func GetSignerIDByApiKey(lcApiKey string) string
- func GetUserFromContext(context store.CurrentContext, lcApiKey string, lcLedger string, ...) (interface{}, error)
- func LatestCLIVersion() (string, string, error)
- 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)
- func TrackPublisher(user *User, event string) (err error)
- func TrackSign(user *User, hash string, filename string, status meta.Status) (err error)
- func TrackVerify(user *User, hash string, filename string) (err error)
- type AlertConfig
- type AlertResponse
- type Artifact
- type ArtifactResponse
- type Attachment
- type BlockchainOrganisation
- type BlockchainVerification
- func BlockChainInspect(hash string) ([]BlockchainVerification, error)
- func Verify(hash string) (*BlockchainVerification, error)
- func VerifyMatchingSignerID(hash string, signerID string) (*BlockchainVerification, error)
- func VerifyMatchingSignerIDWithFallback(hash string, signerID string) (*BlockchainVerification, error)
- func VerifyMatchingSignerIDs(hash string, signerIDs []string) (*BlockchainVerification, error)
- func (v *BlockchainVerification) Date() string
- func (v *BlockchainVerification) MarshalJSON() ([]byte, error)
- func (v *BlockchainVerification) MarshalYAML() (interface{}, error)
- func (v *BlockchainVerification) MetaHash() string
- func (v *BlockchainVerification) SignerID() string
- func (v *BlockchainVerification) Trusted() bool
- func (v *BlockchainVerification) Unknown() bool
- func (v *BlockchainVerification) UnmarshalJSON(b []byte) error
- func (v *BlockchainVerification) UnmarshalYAML(unmarshal func(interface{}) error) error
- 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) DownloadAttachment(attach *Attachment, ar *LcArtifact, tx uint64, lcAttachForce bool) (err error)
- func (u *LcUser) GetArtifactAttachmentListByLabel(hash string, signerID, label string) ([]Attachment, string, 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) (bool, uint64, error)
- func (u LcUser) SignMulti(artifacts []*Artifact, options [][]LcSignOption) ([]bool, []uint64, []error, error)
- type Metadata
- type PackageDetails
- type PagedArtifactResponse
- type SignOption
- type User
- func (u *User) Authenticate(password string, otp string) (err error)
- func (u *User) ClearAuth()
- func (u User) Config() *store.User
- func (u *User) CreateAlert(name string, email string, a Artifact, v BlockchainVerification, m Metadata) (alertConfig *AlertConfig, err error)
- func (u User) Email() string
- func (u *User) GetAlert(uuid string) (*AlertResponse, error)
- func (u User) IsAuthenticated() (bool, error)
- func (u User) IsExist() (bool, error)
- func (u User) ListArtifacts(page uint) (*PagedArtifactResponse, error)
- func (u *User) LoadArtifact(hash string) (*ArtifactResponse, error)
- func (u *User) PingAlert(config AlertConfig) error
- func (u User) RemainingSignOps() (uint64, error)
- func (u User) Secret() (reader, id string, offline bool, err error)
- func (u User) Sign(artifact Artifact, options ...SignOption) (*BlockchainVerification, error)
- func (u User) SignerID() (id string, err error)
- func (u *User) TriggerAlert(config AlertConfig) error
- func (u User) UploadSecret(secret io.Reader, passphrase string) (err error)
- func (u User) User() *store.User
- func (u *User) UserByCfg(cfg *store.User)
Constants ¶
This section is empty.
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
var WrongPassphraseErr = goErr.New("incorrect notarization password")
Functions ¶
func AppendAttachment ¶ added in v0.9.5
func AppendLabel ¶ added in v0.9.7
func AppendPrefix ¶ added in v0.9.0
func AppendSignerId ¶ added in v0.9.0
func GetSignerIDByApiKey ¶ added in v0.9.4
func GetUserFromContext ¶ added in v0.9.0
func GetUserFromContext(context store.CurrentContext, lcApiKey string, lcLedger string, signingPubKey *ecdsa.PublicKey) (interface{}, error)
GetUserFromContext returns a new the correct user based on the context
func LatestCLIVersion ¶ added in v0.6.0
LatestCLIVersion returns the version string and message of the latest `vcn` CLI release.
func NewLcClient ¶ added in v0.9.0
func NewLcClientByContext ¶ added in v0.9.1
func TrackPublisher ¶
TrackPublisher is deprecated and will be removed
Types ¶
type AlertConfig ¶ added in v0.8.0
type AlertConfig struct { AlertUUID string `json:"alertUuid" yaml:"alertUUID"` Metadata Metadata `json:"metadata,omitempty" yaml:"metadata"` }
AlertConfig represents a platform alert configuration.
type AlertResponse ¶ added in v0.8.0
type AlertResponse struct { ArtifactHash string `json:"artifactHash,omitempty"` ArtifactMetaHash string `json:"artifactMetaHash,omitempty"` Email string `json:"email,omitempty"` Enabled bool `json:"enabled"` Metadata Metadata `json:"metadata,omitempty"` Name string `json:"name"` UnAcknowledged bool `json:"unAcknowledgedNotification"` UUID string `json:"uuid,omitempty"` }
AlertResponse holds alert values returned by the platform.
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.
type ArtifactResponse ¶
type ArtifactResponse struct { // root fields Kind string `json:"kind" yaml:"kind" vcn:"Kind"` Name string `json:"name" yaml:"name" vcn:"Name"` Hash string `json:"hash" yaml:"hash" vcn:"Hash"` Size uint64 `json:"size" yaml:"size" vcn:"Size"` ContentType string `json:"contentType" yaml:"contentType" vcn:"ContentType"` URL string `json:"url" yaml:"url" vcn:"URL"` // custom metadata Metadata Metadata `json:"metadata" yaml:"metadata" vcn:"Metadata"` // ArtifactResponse specific Level int64 `json:"level,omitempty" yaml:"level,omitempty"` Status string `json:"status,omitempty" yaml:"status,omitempty"` Visibility string `json:"visibility" yaml:"visibility" vcn:"Visibility"` CreatedAt string `json:"createdAt" yaml:"createdAt"` VerificationCount uint64 `json:"verificationCount" yaml:"verificationCount"` SignerCount uint64 `json:"signerCount" yaml:"signerCount"` Signer string `json:"signer" yaml:"signer" vcn:"Signer"` Company string `json:"company" yaml:"company" vcn:"Company"` Website string `json:"website" yaml:"website" vcn:"Website"` }
ArtifactResponse holds artifact values returned by the platform.
func LoadArtifact ¶ added in v0.6.0
func LoadArtifact(user *User, hash string, metahash string) (*ArtifactResponse, error)
LoadArtifact fetches and returns an artifact matching the given hash and optionally a given metahash. Returned values depends on user permissions on the artifact, if user is nil then only publicly disclosable values are returned.
func (ArtifactResponse) Artifact ¶
func (a ArtifactResponse) Artifact() *Artifact
Artifact returns an new *Artifact from a
func (ArtifactResponse) String ¶
func (a ArtifactResponse) String() string
type Attachment ¶ added in v0.9.5
type Attachment struct { Filename string `json:"filename" yaml:"filename" vcn:"filename"` Hash string `json:"hash" yaml:"hash" vcn:"hash"` Mime string `json:"mime" yaml:"mime" vcn:"mime"` Label string `json:"label" yaml:"label" vcn:"label"` }
Attachment holds Attachment attributes
type BlockchainOrganisation ¶
type BlockchainOrganisation struct { Owner common.Address `json:"owner"` Members []common.Address `json:"members"` Hash string `json:"hash"` Timestamp time.Time `json:"timestamp"` }
BlockchainOrganisation represents the organization data stored onto the blockchain.
func GetBlockChainOrganisation ¶ added in v0.6.0
func GetBlockChainOrganisation(name string) (*BlockchainOrganisation, error)
GetBlockChainOrganisation returns a BlockchainOrganisation for the organization name, if any. It returns a nil value and an error if the organization is not found.
func (*BlockchainOrganisation) MembersIDs ¶ added in v0.6.0
func (o *BlockchainOrganisation) MembersIDs() []string
MembersIDs returns org members' IDs (SignerIDs) as slice of strings for o, if any, otherwise a zero-len slice
func (*BlockchainOrganisation) OwnerID ¶ added in v0.6.0
func (o *BlockchainOrganisation) OwnerID() string
OwnerID returns org owner's public address as string for o, if any, otherwise an empty string
type BlockchainVerification ¶
type BlockchainVerification struct { Owner common.Address `json:"owner" yaml:"owner"` Level meta.Level `json:"level" yaml:"level"` Status meta.Status `json:"status" yaml:"status"` Timestamp time.Time `json:"timestamp" yaml:"timestamp"` }
BlockchainVerification represents the notarized data onto the blockchain.
func BlockChainInspect ¶ added in v0.5.1
func BlockChainInspect(hash string) ([]BlockchainVerification, error)
BlockChainInspect returns an array of BlockchainVerification containing all verifications found for the given hash
func Verify ¶ added in v0.6.0
func Verify(hash string) (*BlockchainVerification, error)
Verify returns the most recent *BlockchainVerification with highest level available for the given hash.
func VerifyMatchingSignerID ¶ added in v0.6.0
func VerifyMatchingSignerID(hash string, signerID string) (*BlockchainVerification, error)
VerifyMatchingSignerID returns *BlockchainVerification for hash matching a given SignerID.
func VerifyMatchingSignerIDWithFallback ¶ added in v0.6.2
func VerifyMatchingSignerIDWithFallback(hash string, signerID string) (*BlockchainVerification, error)
VerifyMatchingSignerIDWithFallback returns *BlockchainVerification for the hash matching a given SignerID, if any, otherwise it returns the same result of Verify().
func VerifyMatchingSignerIDs ¶ added in v0.6.0
func VerifyMatchingSignerIDs(hash string, signerIDs []string) (*BlockchainVerification, error)
VerifyMatchingSignerIDs returns *BlockchainVerification for hash matching at least one of signerIDs.
func (*BlockchainVerification) Date ¶
func (v *BlockchainVerification) Date() string
Date returns a RFC3339 formatted string of verification time (v.Timestamp), if any, otherwise an empty string.
func (*BlockchainVerification) MarshalJSON ¶
func (v *BlockchainVerification) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface.
func (*BlockchainVerification) MarshalYAML ¶
func (v *BlockchainVerification) MarshalYAML() (interface{}, error)
MarshalYAML implements the yaml.Marshaler interface.
func (*BlockchainVerification) MetaHash ¶
func (v *BlockchainVerification) MetaHash() string
MetaHash returns the SHA256 digest of BlockchainVerification's data. The returned value uniquely identify a single notarization.
func (*BlockchainVerification) SignerID ¶ added in v0.6.0
func (v *BlockchainVerification) SignerID() string
SignerID returns the public address derived from owner's public key (v.Owner), if any, otherwise an empty string.
func (*BlockchainVerification) Trusted ¶
func (v *BlockchainVerification) Trusted() bool
Trusted returns true if v.Status is meta.StatusTrusted
func (*BlockchainVerification) Unknown ¶
func (v *BlockchainVerification) Unknown() bool
Unknown returns true if v is nil or v.Status is meta.StatusUnknown
func (*BlockchainVerification) UnmarshalJSON ¶ added in v0.5.1
func (v *BlockchainVerification) UnmarshalJSON(b []byte) error
UnmarshalJSON implements the json.Unmarshaler interface.
func (*BlockchainVerification) UnmarshalYAML ¶ added in v0.7.0
func (v *BlockchainVerification) UnmarshalYAML(unmarshal func(interface{}) error) error
UnmarshalYAML implements the yaml.Unmarshaler interface.
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 ¶ added in v0.9.0
type LcArtifact struct { // root fields Uid string `json:"uid" yaml:"uid" vcn:"UID"` Kind string `json:"kind" yaml:"kind" vcn:"Kind"` Name string `json:"name" yaml:"name" vcn:"Name"` Hash string `json:"hash" yaml:"hash" vcn:"Hash"` Size uint64 `json:"size" yaml:"size" vcn:"Size"` Timestamp time.Time `json:"timestamp,omitempty" yaml:"timestamp" vcn:"Timestamp"` ContentType string `json:"contentType" yaml:"contentType" vcn:"ContentType"` // custom metadata Metadata Metadata `json:"metadata" yaml:"metadata" vcn:"Metadata"` Attachments []Attachment `json:"attachments" yaml:"attachments" vcn:"Attachments"` Signer string `json:"signer" yaml:"signer" vcn:"SignerID"` Revoked *time.Time `json:"revoked,omitempty" yaml:"revoked" vcn:"Apikey revoked"` Status meta.Status `json:"status" yaml:"status" vcn:"Status"` Ledger string `json:"ledger,omitempty" yaml:"ledger"` IncludedIn []PackageDetails `json:"included_in,omitempty" yaml:"included_in,omitempty" vcn:"Included in"` Deps []PackageDetails `json:"bom,omitempty" yaml:"bom,omitempty" vcn:"Dependencies"` }
func ItemToLcArtifact ¶ added in v0.9.0
func ItemToLcArtifact(item *schema.ItemExt) (*LcArtifact, error)
func LcVerifyEnv ¶ added in v0.9.5
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 ¶ added in v0.9.5
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 ¶ added in v0.9.1
func VerifiableItemExtToLcArtifact(item *schema.VerifiableItemExt) (*LcArtifact, error)
func ZItemToLcArtifact ¶ added in v0.9.0
func ZItemToLcArtifact(ie *schema.ZItemExt) (*LcArtifact, error)
func (*LcArtifact) Date ¶ added in v0.9.5
func (lca *LcArtifact) Date() string
Date returns a RFC3339 formatted string of verification time (v.Timestamp), if any, otherwise an empty string.
type LcSignOption ¶ added in v0.9.0
type LcSignOption func(*lcSignOpts) error
SignOption is a functional option for signing operations
func LcSignWithAttachments ¶ added in v0.9.5
func LcSignWithAttachments(attach []string) LcSignOption
LcSignWithAttachments returns the functional option for the given status.
func LcSignWithBom ¶ added in v0.9.8
func LcSignWithBom(bom string) LcSignOption
func LcSignWithStatus ¶ added in v0.9.0
func LcSignWithStatus(status meta.Status) LcSignOption
SignWithStatus returns the functional option for the given status.
func LcSignWithVisibility ¶ added in v0.9.0
func LcSignWithVisibility(visibility meta.Visibility) LcSignOption
SignWithVisibility returns the functional option for the given visibility.
type LcUser ¶ added in v0.9.0
User represent a CodeNotary platform user.
func NewLcUser ¶ added in v0.9.0
func NewLcUser(lcApiKey, lcLedger, host, port, lcCert string, skipTlsVerify bool, noTls bool, signingPubKey *ecdsa.PublicKey) (*LcUser, error)
NewLcUser returns a new User instance configured with provided parameters. 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 ¶ added in v0.9.0
NewLcUserVolatile returns a new User instance without a backing cfg file.
func (*LcUser) CheckConnectionPublicKey ¶ added in v0.9.10
CheckConnectionPublicKey the aim of this method is to guarantee that the connection between vcn and a CNC 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 VCN_SIGNING_PUB_KEY_FILE or VCN_SIGNING_PUB_KEY environment flag or arguments are provided this method is not called.
func (*LcUser) DownloadAttachment ¶ added in v0.9.5
func (u *LcUser) DownloadAttachment(attach *Attachment, ar *LcArtifact, tx uint64, lcAttachForce bool) (err error)
DownloadAttachment download locally all the attachments linked to the assets
func (*LcUser) GetArtifactAttachmentListByLabel ¶ added in v0.9.7
func (u *LcUser) GetArtifactAttachmentListByLabel(hash string, signerID, label string) ([]Attachment, string, error)
GetArtifactAttachmentListByLabel returns the attachment list of an artifact and the most recent uid by a provided label and signerID When there are multiple attachments with same file name it adds an enumerator postfix.
func (*LcUser) LoadArtifact ¶ added in v0.9.0
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 ¶ added in v0.9.10
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 ¶ added in v0.9.8
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 ¶ added in v0.9.9
type PackageDetails struct { Name string `json:"name" yaml:"name" vcn:"name"` Version string `json:"version,omitempty" yaml:"version,omitempty" vcn:"version"` Hash string `json:"hash" yaml:"hash" vcn:"hash"` Status meta.Status `json:"status" yaml:"status" vcn:"status"` License string `json:"license,omitempty" yaml:"license"` }
type PagedArtifactResponse ¶
type PagedArtifactResponse struct { Content []ArtifactResponse `json:"content"` TotalElements uint64 `json:"totalElements"` Pageable struct { PageSize uint64 `json:"pageSize"` PageNumber uint64 `json:"pageNumber"` } `json:"pageable"` }
PagedArtifactResponse holds a page of ArtifactResponse(s) returned by the platform.
type SignOption ¶ added in v0.7.0
type SignOption func(*signOpts) error
SignOption is a functional option for signing operations
func SignWithKey ¶ added in v0.7.0
func SignWithKey(keyin, passphrase string) SignOption
SignWithKey returns the functional option for the given keyin and passphrase.
func SignWithStatus ¶ added in v0.7.0
func SignWithStatus(status meta.Status) SignOption
SignWithStatus returns the functional option for the given status.
func SignWithVisibility ¶ added in v0.7.0
func SignWithVisibility(visibility meta.Visibility) SignOption
SignWithVisibility returns the functional option for the given visibility.
type User ¶
type User struct {
// contains filtered or unexported fields
}
User represent a CodeNotary platform user.
func (*User) Authenticate ¶
Authenticate the User against the CodeNotary platform. If successful the auth token in stored within the User's config and used for subsequent API call.
func (*User) ClearAuth ¶
func (u *User) ClearAuth()
ClearAuth deletes the stored authentication token.
func (User) Config ¶ added in v0.6.0
Config returns the User configuration object (see store.User), if any. It returns nil if the User is not properly initialized.
func (*User) CreateAlert ¶ added in v0.8.0
func (u *User) CreateAlert(name string, email string, a Artifact, v BlockchainVerification, m Metadata) (alertConfig *AlertConfig, err error)
CreateAlert creates a platform alert and returns its UUID.
func (*User) GetAlert ¶ added in v0.8.0
func (u *User) GetAlert(uuid string) (*AlertResponse, error)
GetAlert returns an AlertResponse for a given alert uuid.
func (User) IsAuthenticated ¶
IsAuthenticated returns true if the stored auth token is still valid.
func (User) ListArtifacts ¶ added in v0.5.2
func (u User) ListArtifacts(page uint) (*PagedArtifactResponse, error)
ListArtifacts fetches and returns a paged list of user's artifacts.
func (*User) LoadArtifact ¶
func (u *User) LoadArtifact(hash string) (*ArtifactResponse, error)
LoadArtifact fetches and returns an *ArtifactResponse for the given hash and current u, if any.
func (*User) PingAlert ¶ added in v0.8.0
func (u *User) PingAlert(config AlertConfig) error
PingAlert sends a ping for the given alert _config_. Once the first ping goes through, the platform starts a server-side watcher and will trigger a notification after some amount of time if no further pings for the alert are received.
func (User) RemainingSignOps ¶
RemainingSignOps returns the number of remaining notarizations in the User's account subscription.
func (User) Secret ¶ added in v0.7.0
Secret fetches the User's secret and returns an io.Reader for reading it.
func (User) Sign ¶
func (u User) Sign(artifact Artifact, options ...SignOption) (*BlockchainVerification, error)
Sign is invoked by the User to notarize an artifact using the given functional options, if successful a BlockchainVerification is returned. By default, the artifact is notarized using status = meta.StatusTrusted, visibility meta.VisibilityPrivate. At least the key (secret) must be provided using SignWithKey().
func (User) SignerID ¶ added in v0.7.0
SignerID retrives the User's SignerID (the public address derived from the secret) from the platform.
func (*User) TriggerAlert ¶ added in v0.8.0
func (u *User) TriggerAlert(config AlertConfig) error
TriggerAlert triggers a notification immediately for the given alert _config_.
func (User) UploadSecret ¶ added in v0.7.0
UploadSecret uploads the User's secret to the platform.