diff --git a/token/invocation/examples_test.go b/token/invocation/examples_test.go index f948041..ce1743f 100644 --- a/token/invocation/examples_test.go +++ b/token/invocation/examples_test.go @@ -15,7 +15,6 @@ import ( "github.com/ipld/go-ipld-prime/fluent/qp" "github.com/ipld/go-ipld-prime/node/basicnode" "github.com/libp2p/go-libp2p/core/crypto" - "github.com/ucan-wg/go-ucan/did" "github.com/ucan-wg/go-ucan/pkg/command" "github.com/ucan-wg/go-ucan/token/invocation" diff --git a/token/invocation/invocation.go b/token/invocation/invocation.go index 0e0a306..ff6275f 100644 --- a/token/invocation/invocation.go +++ b/token/invocation/invocation.go @@ -65,14 +65,20 @@ type Token struct { // the previous contents of their target field. func New(iss, sub did.DID, cmd command.Command, prf []cid.Cid, opts ...Option) (*Token, error) { iat := time.Now() + metadata := meta.NewMeta() tkn := Token{ issuer: iss, subject: sub, command: cmd, proof: prf, +<<<<<<< HEAD meta: meta.NewMeta(), nonce: nil, +======= + meta: metadata, + nonce: nonce, +>>>>>>> f44cf8a (feat(invocation): produce example output similar to spec) invokedAt: &iat, } @@ -82,6 +88,7 @@ func New(iss, sub did.DID, cmd command.Command, prf []cid.Cid, opts ...Option) ( } } +<<<<<<< HEAD if len(tkn.nonce) == 0 { tkn.nonce, err = generateNonce() if err != nil { @@ -91,6 +98,10 @@ func New(iss, sub did.DID, cmd command.Command, prf []cid.Cid, opts ...Option) ( if err := tkn.validate(); err != nil { return nil, err +======= + if len(tkn.meta.Keys) == 0 { + tkn.meta = nil +>>>>>>> f44cf8a (feat(invocation): produce example output similar to spec) } return &tkn, nil diff --git a/token/invocation/options.go b/token/invocation/options.go index f2f870a..fc6ca34 100644 --- a/token/invocation/options.go +++ b/token/invocation/options.go @@ -130,6 +130,15 @@ func WithoutInvokedAt() Option { } } +// WithoutInvokedAt clears the Token's invokedAt field. +func WithoutInvokedAt() Option { + return func(t *Token) error { + t.invokedAt = nil + + return nil + } +} + // WithCause sets the Token's cause field to the provided cid.Cid. func WithCause(cause *cid.Cid) Option { return func(t *Token) error {