From 3faf9d598ca554ce28d28f8ec32c3093cc624fe2 Mon Sep 17 00:00:00 2001 From: Steve Moyer Date: Tue, 11 Mar 2025 13:04:00 -0400 Subject: [PATCH] fix(invocation): also update docs and examples --- token/invocation/examples_test.go | 2 +- token/invocation/invocation.go | 8 ++++---- token/invocation/ipld_test.go | 2 +- token/invocation/options.go | 12 ++++++------ 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/token/invocation/examples_test.go b/token/invocation/examples_test.go index e505a7d..c4f896b 100644 --- a/token/invocation/examples_test.go +++ b/token/invocation/examples_test.go @@ -34,7 +34,7 @@ func ExampleNew() { invocation.WithMeta("env", "development"), invocation.WithMeta("tags", meta["tags"]), invocation.WithExpirationIn(time.Minute), - invocation.WithoutInvokedAt()) + invocation.WithoutIssuedAt()) if err != nil { fmt.Println("failed to create invocation:", err.Error()) diff --git a/token/invocation/invocation.go b/token/invocation/invocation.go index 1bcef10..2796120 100644 --- a/token/invocation/invocation.go +++ b/token/invocation/invocation.go @@ -66,9 +66,9 @@ type Token struct { // WithNonce or WithEmptyNonce options to specify provide your own nonce // or to leave the nonce empty respectively. // -// If no invokedAt is provided, the current time is used. Use the -// WithInvokedAt or WithInvokedAtIn Options to specify a different time -// or the WithoutInvokedAt Option to clear the Token's invokedAt field. +// If no IssuedAt is provided, the current time is used. Use the +// IssuedAt or WithIssuedAtIn Options to specify a different time +// or the WithoutIssuedAt Option to clear the Token's IssuedAt field. // // With the exception of the WithMeta option, all others will overwrite // the previous contents of their target field. @@ -315,7 +315,7 @@ func tokenFromModel(m tokenPayloadModel) (*Token, error) { tkn.issuedAt, err = parse.OptionalTimestamp(m.Iat) if err != nil { - return nil, fmt.Errorf("parse invokedAt: %w", err) + return nil, fmt.Errorf("parse IssuedAt: %w", err) } tkn.cause = m.Cause diff --git a/token/invocation/ipld_test.go b/token/invocation/ipld_test.go index 4e822e3..3e2f81a 100644 --- a/token/invocation/ipld_test.go +++ b/token/invocation/ipld_test.go @@ -23,7 +23,7 @@ func TestSealUnsealRoundtrip(t *testing.T) { invocation.WithMeta("env", "development"), invocation.WithMeta("tags", meta["tags"]), invocation.WithExpirationIn(time.Minute), - invocation.WithoutInvokedAt(), + invocation.WithoutIssuedAt(), ) require.NoError(t, err) diff --git a/token/invocation/options.go b/token/invocation/options.go index 1dce7aa..55d1a29 100644 --- a/token/invocation/options.go +++ b/token/invocation/options.go @@ -123,12 +123,12 @@ func WithExpirationIn(after time.Duration) Option { return WithExpiration(time.Now().Add(after)) } -// WithInvokedAt sets the Token's invokedAt field to the provided +// WithIssuedAt sets the Token's IssuedAt field to the provided // 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. +// Token without this field being set, use the WithoutIssuedAt Option. func WithIssuedAt(iat time.Time) Option { return func(t *Token) error { t.issuedAt = &iat @@ -137,13 +137,13 @@ func WithIssuedAt(iat time.Time) Option { } } -// WithInvokedAtIn sets the Token's invokedAt field to Now() plus the +// WithIssuedAtIn sets the Token's IssuedAt field to Now() plus the // given duration. -func WithInvokedAtIn(after time.Duration) Option { - return WithInvokedAt(time.Now().Add(after)) +func WithIssuedAtIn(after time.Duration) Option { + return WithIssuedAt(time.Now().Add(after)) } -// WithoutInvokedAt clears the Token's invokedAt field. +// WithoutIssuedAt clears the Token's IssuedAt field. func WithoutIssuedAt() Option { return func(t *Token) error { t.issuedAt = nil