diff --git a/token/delegation/delegation_test.go b/token/delegation/delegation_test.go index 906f293..4059030 100644 --- a/token/delegation/delegation_test.go +++ b/token/delegation/delegation_test.go @@ -173,7 +173,7 @@ func TestEncryptedMeta(t *testing.T) { t.Parallel() tkn, err := delegation.New(privKey, aud, cmd, pol, - delegation.WithEncryptedMeta(tt.key, tt.value, encryptionKey), + delegation.WithEncryptedMetaString(tt.key, tt.value, encryptionKey), ) require.NoError(t, err) @@ -208,7 +208,7 @@ func TestEncryptedMeta(t *testing.T) { } var opts []delegation.Option for k, v := range values { - opts = append(opts, delegation.WithEncryptedMeta(k, v, encryptionKey)) + opts = append(opts, delegation.WithEncryptedMetaString(k, v, encryptionKey)) } // Create token with multiple encrypted values diff --git a/token/delegation/options.go b/token/delegation/options.go index ee2eac2..4df14e7 100644 --- a/token/delegation/options.go +++ b/token/delegation/options.go @@ -44,10 +44,17 @@ func WithMeta(key string, val any) Option { } } -// WithEncryptedMeta adds a key/value pair in the "meta" field. -// The value is encrypted with the given aesKey. -// Accepted types for the value are: string, []byte. -func WithEncryptedMeta(key string, val any, encryptionKey []byte) Option { +// WithEncryptedMetaString adds a key/value pair in the "meta" field. +// The string value is encrypted with the given aesKey. +func WithEncryptedMetaString(key, val string, encryptionKey []byte) Option { + return func(t *Token) error { + return t.meta.AddEncrypted(key, val, encryptionKey) + } +} + +// WithEncryptedMetaBytes adds a key/value pair in the "meta" field. +// The []byte value is encrypted with the given aesKey. +func WithEncryptedMetaBytes(key string, val, encryptionKey []byte) Option { return func(t *Token) error { return t.meta.AddEncrypted(key, val, encryptionKey) } diff --git a/token/invocation/options.go b/token/invocation/options.go index e2246dc..349af2c 100644 --- a/token/invocation/options.go +++ b/token/invocation/options.go @@ -44,10 +44,17 @@ func WithMeta(key string, val any) Option { } } -// WithEncryptedMeta adds a key/value pair in the "meta" field. -// The value is encrypted with the given aesKey. -// Accepted types for the value are: string, []byte. -func WithEncryptedMeta(key string, val any, encryptionKey []byte) Option { +// WithEncryptedMetaString adds a key/value pair in the "meta" field. +// The string value is encrypted with the given aesKey. +func WithEncryptedMetaString(key, val string, encryptionKey []byte) Option { + return func(t *Token) error { + return t.meta.AddEncrypted(key, val, encryptionKey) + } +} + +// WithEncryptedMetaBytes adds a key/value pair in the "meta" field. +// The []byte value is encrypted with the given aesKey. +func WithEncryptedMetaBytes(key string, val, encryptionKey []byte) Option { return func(t *Token) error { return t.meta.AddEncrypted(key, val, encryptionKey) }