Skip to content

Commit

Permalink
fix: Do not mutate headers inplace
Browse files Browse the repository at this point in the history
  • Loading branch information
Viicos committed Jul 18, 2023
1 parent 0e8845e commit 20541c1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/joserfc/jwt.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,16 @@ def encode(
:param registry: a ``JWSRegistry`` or ``JWERegistry`` to use
"""
# add ``typ`` in header
header["typ"] = "JWT"
_header = {"typ": "JWT", **header}
payload = convert_claims(claims)
if "enc" in header:
if "enc" in _header:
if registry is not None:
assert isinstance(registry, JWERegistry)
return encrypt_compact(header, payload, key, algorithms, registry)
return encrypt_compact(_header, payload, key, algorithms, registry)
else:
if registry is not None:
assert isinstance(registry, JWSRegistry)
return serialize_compact(header, payload, key, algorithms, registry)
return serialize_compact(_header, payload, key, algorithms, registry)


def decode(
Expand Down

0 comments on commit 20541c1

Please sign in to comment.