Documentation ¶
Index ¶
Constants ¶
const ( AlicePrivateKey = "" /* 184-byte string literal not displayed */ AlicePublicKey = "" /* 132-byte string literal not displayed */ AlicePublicKeyEscaped = `` /* 132-byte string literal not displayed */ BobPrivateKey = "" /* 184-byte string literal not displayed */ BobPublicKey = "" /* 132-byte string literal not displayed */ BobPublicKeyEscaped = `` /* 132-byte string literal not displayed */ CarolPrivateKey = "" /* 184-byte string literal not displayed */ CarolPublicKey = "" /* 132-byte string literal not displayed */ CarolPublicKeyEscaped = `` /* 132-byte string literal not displayed */ )
These are the test key pairs of Alice and Bob.
const AuctionJSONStepsRules = `` /* 628-byte string literal not displayed */
AuctionJSONStepsRules is a set of steps validation rules for the auction process.
const ChatJSONStepsRules = `` /* 337-byte string literal not displayed */
ChatJSONStepsRules is a set of steps validation rules for the chat process.
Variables ¶
var ( AuctionJSONRules = CreateValidatorJSON("auction", AuctionJSONPKI, AuctionJSONStepsRules) ChatJSONRules = CreateValidatorJSON("chat", ChatJSONPKI, ChatJSONStepsRules) TestJSONRules = fmt.Sprintf(`{%s,%s}`, AuctionJSONRules, ChatJSONRules) )
Sample test validation rules exported by this package.
var ( // Plugin missing the required Validate func. PluginMissingValidate = []byte(` package main import ( "context" "github.com/stratumn/go-core/store" "github.com/stratumn/go-core/types" ) func NotValidate(_ context.Context, _ store.SegmentReader, _ *types.Link) error { return nil } func main() {} `) // Plugin containing an invalid Validate func (signature doesn't match). PluginInvalidValidate = []byte(` package main import ( "github.com/stratumn/go-core/store" "github.com/stratumn/go-core/types" ) func Validate(_ store.SegmentReader, _ *types.Link) error { return nil } func main() {} `) // Plugin that returns a validation failure. PluginValidationError = []byte(` package main import ( "context" "errors" "github.com/stratumn/go-core/store" "github.com/stratumn/go-core/types" ) func Validate(_ context.Context, _ store.SegmentReader, _ *types.Link) error { return errors.New("invalid link") } func main() {} `) // Plugin that returns a validation success. PluginValidationSuccess = []byte(` package main import ( "context" "errors" "github.com/stratumn/go-core/store" "github.com/stratumn/go-core/types" ) func Validate(_ context.Context, _ store.SegmentReader, l *types.Link) error { if l.Link.Meta.Process == nil { return errors.New("link is missing process") } return nil } func main() {} `) )
Sample validation plugins.
var AuctionJSONPKI = fmt.Sprintf(` { "alice.vandenbudenmayer@stratumn.com": { "keys": ["%s"], "roles": ["employee"] }, "Bob Wagner": { "keys": ["%s"], "roles": ["manager", "it"] } } `, AlicePublicKeyEscaped, BobPublicKeyEscaped)
AuctionJSONPKI is a sample PKI for the auction process.
var ChatJSONPKI = fmt.Sprintf(` { "Bob Wagner": { "keys": ["%s"], "roles": ["manager", "it"] } } `, BobPublicKeyEscaped)
ChatJSONPKI is a sample PKI for the chat process.
Functions ¶
func CompilePlugin ¶
CompilePlugin compiles the given plugin and stores it in a temporary folder. The name of the file will be its hex-encoded hash. It returns the path to the directory and the compiled file hash.
func CreateValidatorJSON ¶
CreateValidatorJSON formats a PKI and steps rules into a valid JSON configuration.
func UnmarshalPKI ¶
func UnmarshalPKI(data []byte) (*validators.PKI, error)
UnmarshalPKI unmarshals a JSON-formatted PKI.
func UnmarshalStepsRules ¶
func UnmarshalStepsRules(data []byte) (map[string]*validation.StepRules, error)
UnmarshalStepsRules unmarshals JSON-formatted steps validation rules.
Types ¶
This section is empty.