docs(invocation): edit (and finish) Go docs for exported types
This commit is contained in:
@@ -57,7 +57,8 @@ type Token struct {
|
|||||||
// or to leave the nonce empty respectively.
|
// or to leave the nonce empty respectively.
|
||||||
//
|
//
|
||||||
// If no invokedAt is provided, the current time is used. Use the
|
// If no invokedAt is provided, the current time is used. Use the
|
||||||
// WithInvokedAt or WithInvokedAtIn options to specify a different time.
|
// WithInvokedAt or WithInvokedAtIn Options to specify a different time
|
||||||
|
// or the WithoutInvokedAt Option to clear the Token's invokedAt field.
|
||||||
//
|
//
|
||||||
// With the exception of the WithMeta option, all other will overwrite
|
// With the exception of the WithMeta option, all other will overwrite
|
||||||
// the previous contents of their target field.
|
// the previous contents of their target field.
|
||||||
@@ -113,10 +114,14 @@ func (t *Token) Command() command.Command {
|
|||||||
return t.command
|
return t.command
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Arguments returns the arguments to be used when the command is
|
||||||
|
// invoked.
|
||||||
func (t *Token) Arguments() map[string]datamodel.Node {
|
func (t *Token) Arguments() map[string]datamodel.Node {
|
||||||
return t.arguments
|
return t.arguments
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Proof() returns the ordered list of cid.Cids which referenced the
|
||||||
|
// delegation Tokens that authorize this invocation.
|
||||||
func (t *Token) Proof() []cid.Cid {
|
func (t *Token) Proof() []cid.Cid {
|
||||||
return t.proof
|
return t.proof
|
||||||
}
|
}
|
||||||
@@ -136,11 +141,14 @@ func (t *Token) Expiration() *time.Time {
|
|||||||
return t.expiration
|
return t.expiration
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// InvokedAt returns the time.Time at which the invocation token was
|
||||||
|
// created.
|
||||||
func (t *Token) InvokedAt() *time.Time {
|
func (t *Token) InvokedAt() *time.Time {
|
||||||
return t.invokedAt
|
return t.invokedAt
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cause returns the (optional)
|
// Cause returns the Token's (optional) cause field which may specify
|
||||||
|
// which describes the Receipt that requested the invocation.
|
||||||
func (t *Token) Cause() *cid.Cid {
|
func (t *Token) Cause() *cid.Cid {
|
||||||
return t.cause
|
return t.cause
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Option is a type that allows optional fields to be set during the
|
// Option is a type that allows optional fields to be set during the
|
||||||
// creation of a Token.
|
// creation of a invocation Token.
|
||||||
type Option func(*Token) error
|
type Option func(*Token) error
|
||||||
|
|
||||||
// WithArgument adds a key/value pair to the Token's Arguments field.
|
// WithArgument adds a key/value pair to the Token's Arguments field.
|
||||||
@@ -62,7 +62,9 @@ func WithMeta(key string, val any) Option {
|
|||||||
// WithNonce sets the Token's nonce with the given value.
|
// WithNonce sets the Token's nonce with the given value.
|
||||||
//
|
//
|
||||||
// If this option is not used, a random 12-byte nonce is generated for
|
// If this option is not used, a random 12-byte nonce is generated for
|
||||||
// this require.
|
// this required field. If you truly want to create an invocation Token
|
||||||
|
// without a nonce, use the WithEmptyNonce Option which will set the
|
||||||
|
// nonce to an empty byte array.
|
||||||
func WithNonce(nonce []byte) Option {
|
func WithNonce(nonce []byte) Option {
|
||||||
return func(t *Token) error {
|
return func(t *Token) error {
|
||||||
t.nonce = nonce
|
t.nonce = nonce
|
||||||
@@ -95,12 +97,16 @@ func WithExpiration(exp time.Time) Option {
|
|||||||
|
|
||||||
// WithExpirationIn set's the Token's optional "expiration" field to
|
// WithExpirationIn set's the Token's optional "expiration" field to
|
||||||
// Now() plus the given duration.
|
// Now() plus the given duration.
|
||||||
func WithExpirationIn(exp time.Duration) Option {
|
func WithExpirationIn(after time.Duration) Option {
|
||||||
return WithExpiration(time.Now().Add(exp))
|
return WithExpiration(time.Now().Add(after))
|
||||||
}
|
}
|
||||||
|
|
||||||
// WithInvokedAt sets the Token's invokedAt field to the provided
|
// WithInvokedAt sets the Token's invokedAt field to the provided
|
||||||
// time.Time.
|
// time.Time.
|
||||||
|
//
|
||||||
|
// If this Option is not provided, the invocation Token's iat field will
|
||||||
|
// be set to the value of time.Now(). If you want to create an invocation
|
||||||
|
// Token without this field being set, use the WithoutInvokedAt Option.
|
||||||
func WithInvokedAt(iat time.Time) Option {
|
func WithInvokedAt(iat time.Time) Option {
|
||||||
return func(t *Token) error {
|
return func(t *Token) error {
|
||||||
t.invokedAt = &iat
|
t.invokedAt = &iat
|
||||||
|
|||||||
Reference in New Issue
Block a user