MCPcopy
hub / github.com/authlib/authlib / deserialize

Method deserialize

authlib/jose/rfc7516/jwe.py:662–683  ·  view source on GitHub ↗

Extract a JWE Serialization. It supports both compact and JSON serialization. :param obj: JWE compact serialization as bytes or JWE JSON serialization as dict or str :param key: Private key used to decrypt payload (optionally can be a tuple of kid an

(self, obj, key, decode=None, sender_key=None)

Source from the content-addressed store, hash-verified

660 return {"header": header, "payload": payload}
661
662 def deserialize(self, obj, key, decode=None, sender_key=None):
663 """Extract a JWE Serialization.
664
665 It supports both compact and JSON serialization.
666
667 :param obj: JWE compact serialization as bytes or
668 JWE JSON serialization as dict or str
669 :param key: Private key used to decrypt payload
670 (optionally can be a tuple of kid and essentially key)
671 :param decode: Function to decode payload data
672 :param sender_key: Sender's public key in case
673 JWEAlgorithmWithTagAwareKeyAgreement is used
674 :return: dict with `header` and `payload` keys
675 """
676 if isinstance(obj, dict):
677 return self.deserialize_json(obj, key, decode, sender_key)
678
679 obj = to_bytes(obj)
680 if obj.startswith(b"{") and obj.endswith(b"}"):
681 return self.deserialize_json(obj, key, decode, sender_key)
682
683 return self.deserialize_compact(obj, key, decode, sender_key)
684
685 @staticmethod
686 def parse_json(obj):

Calls 3

deserialize_jsonMethod · 0.95
deserialize_compactMethod · 0.95
to_bytesFunction · 0.90