diff --git a/jws/headers.go b/jws/headers.go index d550eb9a6..e566da635 100644 --- a/jws/headers.go +++ b/jws/headers.go @@ -1,11 +1,10 @@ package jws import ( - "context" "fmt" ) -func (h *stdHeaders) Copy(_ context.Context, dst Headers) error { +func (h *stdHeaders) Copy(dst Headers) error { for _, k := range h.Keys() { var v interface{} if err := h.Get(k, &v); err != nil { @@ -21,17 +20,17 @@ func (h *stdHeaders) Copy(_ context.Context, dst Headers) error { // mergeHeaders merges two headers, and works even if the first Header // object is nil. This is not exported because ATM it felt like this // function is not frequently used, and MergeHeaders seemed a clunky name -func mergeHeaders(ctx context.Context, h1, h2 Headers) (Headers, error) { +func mergeHeaders(h1, h2 Headers) (Headers, error) { h3 := NewHeaders() if h1 != nil { - if err := h1.Copy(ctx, h3); err != nil { + if err := h1.Copy(h3); err != nil { return nil, fmt.Errorf(`failed to copy headers from first Header: %w`, err) } } if h2 != nil { - if err := h2.Copy(ctx, h3); err != nil { + if err := h2.Copy(h3); err != nil { return nil, fmt.Errorf(`failed to copy headers from second Header: %w`, err) } } @@ -39,6 +38,6 @@ func mergeHeaders(ctx context.Context, h1, h2 Headers) (Headers, error) { return h3, nil } -func (h *stdHeaders) Merge(ctx context.Context, h2 Headers) (Headers, error) { - return mergeHeaders(ctx, h, h2) +func (h *stdHeaders) Merge(h2 Headers) (Headers, error) { + return mergeHeaders(h, h2) } diff --git a/jws/headers_gen.go b/jws/headers_gen.go index 6cf67d567..89c5bf60f 100644 --- a/jws/headers_gen.go +++ b/jws/headers_gen.go @@ -4,7 +4,6 @@ package jws import ( "bytes" - "context" "fmt" "sort" "sync" @@ -51,8 +50,8 @@ type Headers interface { X509CertThumbprint() string X509CertThumbprintS256() string X509URL() string - Copy(context.Context, Headers) error - Merge(context.Context, Headers) (Headers, error) + Copy(Headers) error + Merge(Headers) (Headers, error) // Get is used to extract the value of any field, including non-standard fields, out of the header. // // The first argument is the name of the field. The second argument is a pointer diff --git a/jws/message.go b/jws/message.go index 2a5bc6898..a1b06a7b4 100644 --- a/jws/message.go +++ b/jws/message.go @@ -2,7 +2,6 @@ package jws import ( "bytes" - "context" "fmt" "github.com/lestrrat-go/jwx/v3/internal/base64" @@ -102,10 +101,7 @@ func (s *Signature) UnmarshalJSON(data []byte) error { // The second return value s the full three-segment signature // (e.g. "eyXXXX.XXXXX.XXXX") func (s *Signature) Sign(payload []byte, signer Signer, key interface{}) ([]byte, []byte, error) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - - hdrs, err := mergeHeaders(ctx, s.headers, s.protected) + hdrs, err := mergeHeaders(s.headers, s.protected) if err != nil { return nil, nil, fmt.Errorf(`failed to merge headers: %w`, err) } diff --git a/tools/cmd/genjws/main.go b/tools/cmd/genjws/main.go index c06ef0b9c..08a42afdd 100644 --- a/tools/cmd/genjws/main.go +++ b/tools/cmd/genjws/main.go @@ -103,8 +103,8 @@ func generateHeaders(obj *codegen.Object) error { } } - o.L("Copy(context.Context, Headers) error") - o.L("Merge(context.Context, Headers) (Headers, error)") + o.L("Copy(Headers) error") + o.L("Merge(Headers) (Headers, error)") // These are used to access a single element by key name o.L("// Get is used to extract the value of any field, including non-standard fields, out of the header.")