fix(invocation): iat incorrectly named InvokedAt instead of IssuedAt

This commit is contained in:
Steve Moyer
2025-03-11 12:41:24 -04:00
parent 5eb7b1a8e4
commit 7b44f480ee
3 changed files with 11 additions and 11 deletions

View File

@@ -51,7 +51,7 @@ type Token struct {
// The timestamp at which the Invocation becomes invalid // The timestamp at which the Invocation becomes invalid
expiration *time.Time expiration *time.Time
// The timestamp at which the Invocation was created // The timestamp at which the Invocation was created
invokedAt *time.Time issuedAt *time.Time
// An optional CID of the Receipt that enqueued the Task // An optional CID of the Receipt that enqueued the Task
cause *cid.Cid cause *cid.Cid
@@ -85,7 +85,7 @@ func New(iss did.DID, cmd command.Command, sub did.DID, prf []cid.Cid, opts ...O
proof: prf, proof: prf,
meta: meta.NewMeta(), meta: meta.NewMeta(),
nonce: nil, nonce: nil,
invokedAt: &iat, issuedAt: &iat,
} }
for _, opt := range opts { for _, opt := range opts {
@@ -192,10 +192,10 @@ func (t *Token) Expiration() *time.Time {
return t.expiration return t.expiration
} }
// InvokedAt returns the time.Time at which the invocation token was // IssuedAt returns the time.Time at which the invocation token was
// created. // created.
func (t *Token) InvokedAt() *time.Time { func (t *Token) IssuedAt() *time.Time {
return t.invokedAt return t.issuedAt
} }
// Cause returns the Token's (optional) cause field which may specify // Cause returns the Token's (optional) cause field which may specify
@@ -231,7 +231,7 @@ func (t *Token) String() string {
res.WriteString(fmt.Sprintf("Nonce: %s\n", base64.StdEncoding.EncodeToString(t.Nonce()))) res.WriteString(fmt.Sprintf("Nonce: %s\n", base64.StdEncoding.EncodeToString(t.Nonce())))
res.WriteString(fmt.Sprintf("Meta: %s\n", t.Meta())) res.WriteString(fmt.Sprintf("Meta: %s\n", t.Meta()))
res.WriteString(fmt.Sprintf("Expiration: %v\n", t.Expiration())) res.WriteString(fmt.Sprintf("Expiration: %v\n", t.Expiration()))
res.WriteString(fmt.Sprintf("Invoked At: %v\n", t.InvokedAt())) res.WriteString(fmt.Sprintf("Invoked At: %v\n", t.IssuedAt()))
res.WriteString(fmt.Sprintf("Cause: %v", t.Cause())) res.WriteString(fmt.Sprintf("Cause: %v", t.Cause()))
return res.String() return res.String()
@@ -313,7 +313,7 @@ func tokenFromModel(m tokenPayloadModel) (*Token, error) {
return nil, fmt.Errorf("parse expiration: %w", err) return nil, fmt.Errorf("parse expiration: %w", err)
} }
tkn.invokedAt, err = parse.OptionalTimestamp(m.Iat) tkn.issuedAt, err = parse.OptionalTimestamp(m.Iat)
if err != nil { if err != nil {
return nil, fmt.Errorf("parse invokedAt: %w", err) return nil, fmt.Errorf("parse invokedAt: %w", err)
} }

View File

@@ -217,8 +217,8 @@ func (t *Token) toIPLD(privKey crypto.PrivKey) (datamodel.Node, error) {
} }
var iat *int64 var iat *int64
if t.invokedAt != nil { if t.issuedAt != nil {
i := t.invokedAt.Unix() i := t.issuedAt.Unix()
iat = &i iat = &i
} }

View File

@@ -131,7 +131,7 @@ func WithExpirationIn(after time.Duration) Option {
// Token without this field being set, use the WithoutInvokedAt Option. // 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.issuedAt = &iat
return nil return nil
} }
@@ -146,7 +146,7 @@ func WithInvokedAtIn(after time.Duration) Option {
// WithoutInvokedAt clears the Token's invokedAt field. // WithoutInvokedAt clears the Token's invokedAt field.
func WithoutInvokedAt() Option { func WithoutInvokedAt() Option {
return func(t *Token) error { return func(t *Token) error {
t.invokedAt = nil t.issuedAt = nil
return nil return nil
} }