Ë
    �ÏÏetH  ã                   ó¨  — d Z ddlZddlZddlZddlmZmZmZmZm	Z	m
Z
mZmZmZ ddlmZ ddlmZmZmZmZ  ej*                  e«      Z	 	 	 	 d*dededed	eeegef      d
eeegef      defd„Z G d„ d«      Z G d„ de«      Z G d„ dej:                  «      Z edd¬«      Z G d„ dej@                  ejB                  e¬«      Z"de#defd„Z$d+dedee%   dede#fd„Z&de#defd„Z'd+dedee%   dede#fd„Z(d ejR                  defd!„Z*d"edejR                  fd#„Z+d$ejR                  defd%„Z,d"edejR                  fd&„Z- ed'd(¬«      Z. G d)„ d(e"«      Z/y),zÜJSON (de)serialization framework.

The framework presented here is somewhat based on `Go's "json" package`_
(especially the ``omitempty`` functionality).

.. _`Go's "json" package`: http://golang.org/pkg/encoding/json/

é    N)	ÚAnyÚCallableÚDictÚIterableÚListÚMappingÚOptionalÚTypeÚTypeVar)Úcrypto)Úb64ÚerrorsÚ
interfacesÚutilÚ	json_nameÚdefaultÚ	omitemptyÚdecoderÚencoderÚreturnc                 ó"   — t        | ||||¬«      S )a4  Convenient function to declare a :class:`Field` with proper type annotations.

    This function allows to write the following code:

    import josepy
    class JSON(josepy.JSONObjectWithFields):
        typ: str = josepy.field('type')

        def other_type(self) -> str:
            return self.typ

    ©r   r   r   r   r   )Ú_TypedFieldr   s        ú2/usr/lib/python3/dist-packages/josepy/json_util.pyÚfieldr      s   € ô& Ø W¸	È7Ð\côð ó    c                   ó(  — e Zd ZdZdZ	 	 	 	 ddedededee	egef      dee	egef      d	dfd
„Z
eded	efd„«       Zded	efd„Zded	d fd„Zde	egef   d	d fd„Zde	egef   d	d fd„Zded	efd„Zded	efd„Zeded	efd„«       Zeded	efd„«       Zy)ÚFieldaø  JSON object field.

    :class:`Field` is meant to be used together with
    :class:`JSONObjectWithFields`.

    ``encoder`` (``decoder``) is a callable that accepts a single
    parameter, i.e. a value to be encoded (decoded), and returns the
    serialized (deserialized) value. In case of errors it should raise
    :class:`~josepy.errors.SerializationError`
    (:class:`~josepy.errors.DeserializationError`).

    Note, that ``decoder`` should perform partial serialization only.

    :ivar str json_name: Name of the field when encoded to JSON.
    :ivar default: Default value (used when not present in JSON object).
    :ivar bool omitempty: If ``True`` and the field value is empty, then
        it will not be included in the serialized JSON object, and
        ``default`` will be used for deserialization. Otherwise, if ``False``,
        field is considered as required, value will always be included in the
        serialized JSON objected, and it must also be present when
        deserializing.

    )r   r   r   ÚfdecÚfencNr   r   r   r   r   r   c                 óŽ   — || _         || _        || _        |€| j                  n|| _        |€| j
                  | _        y || _        y ©N)r   r   r   Údefault_decoderr   Údefault_encoderr    )Úselfr   r   r   r   r   s         r   Ú__init__zField.__init__R   sC   € ð #ˆŒØˆŒØ"ˆŒà,3¨O�D×(Ò(ÀˆŒ	Ø,3¨O�D×(Ñ(ˆ�	Àˆ�	r   Úvaluec                 ó.   — t        |t        «       xr | S )zÒIs the provided value considered "empty" for this field?

        This is useful for subclasses that might want to override the
        definition of being empty, e.g. for some more exotic data types.

        )Ú
isinstanceÚbool©Úclsr'   s     r   Ú_emptyzField._emptya   s   € ô ˜e¤TÓ*Ð*Ò8°5¨yÐ8r   c                 ó@   — | j                  |«      xr | j                  S )zOmit the value in output?)r-   r   ©r%   r'   s     r   Úomitz
Field.omitk   s   € à�{‰{˜5Ó!Ò4 d§n¡nÐ4r   Úkwargsc                 óœ   — | j                   | j                  | j                  | j                  | j                  dœ|¥} t        | «      di |¤ŽS )Nr   © )r   r   r   r   r    Útype)r%   r1   Úcurrents      r   Ú_update_paramszField._update_paramso   sL   € àŸ™Ø—|‘|ØŸ™Ø—y‘yØ—y‘yñ
ð ð
ˆð Œt�D‹zÑ$˜GÑ$Ð$r   r   c                 ó&   — | j                  |¬«      S )z6Descriptor to change the decoder on JSON object field.)r   ©r6   )r%   r   s     r   r   zField.decoderz   ó   € à×"Ñ"¨4Ð"Ó0Ð0r   r    c                 ó&   — | j                  |¬«      S )z6Descriptor to change the encoder on JSON object field.)r   r8   )r%   r    s     r   r   zField.encoder~   r9   r   c                 ó$   — | j                  |«      S )z4Decode a value, optionally with context JSON object.)r   r/   s     r   ÚdecodezField.decode‚   ó   € à�y‰y˜ÓÐr   c                 ó$   — | j                  |«      S )z4Encode a value, optionally with context JSON object.)r    r/   s     r   ÚencodezField.encode†   r=   r   c           
      ó&  ‡ — t        |t        «      rt        ˆ fd„|D «       «      S t        |t        «      rUt	        j
                  |j                  «       D ��ci c]&  \  }}‰ j                  |«      ‰ j                  |«      “Œ( c}}«      S |S c c}}w )zÃDefault decoder.

        Recursively deserialize into immutable types (
        :class:`josepy.util.frozendict` instead of
        :func:`dict`, :func:`tuple` instead of :func:`list`).

        c              3   ó@   •K  — | ]  }‰j                  |«      –— Œ y ­wr"   )r#   )Ú.0Úsubvaluer,   s     €r   ú	<genexpr>z(Field.default_decoder.<locals>.<genexpr>•   s   øè ø€ ÒM¸8˜×,Ñ,¨X×6ÑMùs   ƒ)r)   ÚlistÚtupleÚdictr   Ú
frozendictÚitemsr#   )r,   r'   Úkeys   `  r   r#   zField.default_decoderŠ   s„   ø€ ô �eœTÔ"ÜÓMÀuÔMÓMÐMÜ˜œtÔ$Ü—?‘?ð ',§k¡k£m÷á"˜˜Uð ×'Ñ'¨Ó,¨c×.AÑ.AÀ%Ó.HÑHóóð ð ˆLùós   Á+B
c                 ó   — |S )zDefault (passthrough) encoder.r3   r+   s     r   r$   zField.default_encoder    s	   € ð
 ˆr   ©NFNN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú	__slots__Ústrr   r*   r	   r   r&   Úclassmethodr-   r0   r6   r   r   r<   r?   r#   r$   r3   r   r   r   r   7   sq  „ ñð0 F€Ið
 ØØ26Ø26ñIàðIð ðIð ð	Ið
 ˜( C 5¨# :Ñ.Ñ/ðIð ˜( C 5¨# :Ñ.Ñ/ðIð 
óIð ð9˜3ð 9 4ò 9ó ð9ð5˜#ð 5 $ó 5ð	% sð 	%¨wó 	%ð1˜H c U¨C ZÑ0ð 1°Wó 1ð1˜H c U¨C ZÑ0ð 1°Wó 1ð ˜Cð   Có  ð ˜Cð   Có  ð ð Cð ¨Cò ó ðð* ð Cð ¨Cò ó ñr   r   c                   ó   — e Zd ZdZy)r   a  Specialized class to mark a JSON object field with typed annotations.

    This class is kept private because fields are supposed to be declared
    using the :function:`field` in this situation.

    In the future the :class:`Field` may be removed in favor of this one.N)rM   rN   rO   rP   r3   r   r   r   r   ¨   s   „ òMr   r   c                   ób   — e Zd ZU dZi Zeeef   ed<   e	e   ed<   dede
e   deeef   dd fd„Zy	)
ÚJSONObjectWithFieldsMetaa»  Metaclass for :class:`JSONObjectWithFields` and its subclasses.

    It makes sure that, for any class ``cls`` with ``__metaclass__``
    set to ``JSONObjectWithFieldsMeta``:

    1. All fields (attributes of type :class:`Field`) in the class
       definition are moved to the ``cls._fields`` dictionary, where
       keys are field attribute names and values are fields themselves.

    2. ``cls.__slots__`` is extended by all field attribute names
       (i.e. not :attr:`Field.json_name`). Original ``cls.__slots__``
       are stored in ``cls._orig_slots``.

    In a consequence, for a field attribute name ``some_field``,
    ``cls.some_field`` will be a slot descriptor and not an instance
    of :class:`Field`. For example::

      some_field = Field('someField', default=())

      class Foo:
          __metaclass__ = JSONObjectWithFieldsMeta
          __slots__ = ('baz',)
          some_field = some_field

      assert Foo.__slots__ == ('some_field', 'baz')
      assert Foo._orig_slots == ()
      assert Foo.some_field is not Field

      assert Foo._fields.keys() == ['some_field']
      assert Foo._fields['some_field'] is some_field

    As an implementation note, this metaclass inherits from
    :class:`abc.ABCMeta` (and not the usual :class:`type`) to mitigate
    the metaclass conflict (:class:`ImmutableMap` and
    :class:`JSONDeSerializable`, parents of :class:`JSONObjectWithFields`,
    use :class:`abc.ABCMeta` as its metaclass).

    Ú_fieldsÚ_orig_slotsÚnameÚbasesÚ	namespacer   c                 ó.  — i }|D ]  }|j                  t        |di «      «       Œ  |j                  «       j                  «       D ]`  \  }}t	        |t
        «      sŒt	        |t        «      r&||j                  di «      vrt        d|› d|› d�«      ‚|j                  |«      ||<   Œb |j                  dd«      |d<   t        t        |d   «      t        |j                  «       «      z   «      |d<   ||d<   t        j                  j                  | |||«      S )	NrW   Ú__annotations__zField `z` in JSONObject `z` has no type annotation.rQ   r3   rX   )ÚupdateÚgetattrÚcopyrI   r)   r   r   ÚgetÚ
ValueErrorÚpoprF   rE   ÚkeysÚabcÚABCMetaÚ__new__)ÚmcsrY   rZ   r[   ÚfieldsÚbaserJ   r'   s           r   rg   z JSONObjectWithFieldsMeta.__new__Ü   s  € ð $&ˆàò 	8ˆDØ�M‰Mœ' $¨	°2Ó6Õ7ð	8ð $Ÿ.™.Ó*×0Ñ0Ó2ò 		1‰JˆC�Ü˜%¤Õ'Ü˜e¤[Ô1ð  )§-¡-Ð0AÀ2Ó"FÑFÜ(Ø% c UÐ*;¸D¸6ÐAZÐ[óð ð (Ÿm™m¨CÓ0��s’ð		1ð $-§=¡=°¸bÓ#Aˆ	�-Ñ Ü!&¤t¨I°mÑ,DÓ'EÌÈVÏ[É[Ë]ÓH[Ñ'[Ó!\ˆ	�+ÑØ%ˆ	�)Ñä�{‰{×"Ñ" 3¨¨e°YÓ?Ð?r   N)rM   rN   rO   rP   rW   r   rR   r   r]   r   r   r   rg   r3   r   r   rV   rV   ±   s]   … ñ%ðN !#€GˆT�#�u�*ÑÓ"Ø˜#‘Óð@Øð@Ø# C™yð@Ø59¸#¸s¸(±^ð@à	#ô@r   rV   ÚGenericJSONObjectWithFieldsÚJSONObjectWithFields)Úboundc                   óþ   ‡ — e Zd ZdZedeeef   fd„«       Zdeddfˆ fd„Z	dedefd„Z
deeef   fd	„Zdeeef   fd
„Zedeeef   ddfd„«       Zedeeef   defd„«       Zedee   deeef   defd„«       Zˆ xZS )rl   aÒ  JSON object with fields.

    Example::

      class Foo(JSONObjectWithFields):
          bar = Field('Bar')
          empty = Field('Empty', omitempty=True)

          @bar.encoder
          def bar(value):
              return value + 'bar'

          @bar.decoder
          def bar(value):
              if not value.endswith('bar'):
                  raise errors.DeserializationError('No bar suffix!')
              return value[:-3]

      assert Foo(bar='baz').to_partial_json() == {'Bar': 'bazbar'}
      assert Foo.from_json({'Bar': 'bazbar'}) == Foo(bar='baz')
      assert (Foo.from_json({'Bar': 'bazbar', 'Empty': '!'})
              == Foo(bar='baz', empty='!'))
      assert Foo(bar='baz').bar == 'baz'

    r   c                 ó~   — | j                   j                  «       D ��ci c]  \  }}||j                  “Œ c}}S c c}}w )zGet default fields values.)rW   rI   r   )r,   Úslotr   s      r   Ú	_defaultszJSONObjectWithFields._defaults  s2   € ð 8;·{±{×7HÑ7HÓ7J×K©¨¨e��e—m‘mÑ#ÓKÐKùÓKs   ž9r1   Nc                 óH   •— t        ‰| �  di i | j                  «       ¥|¥¤Ž y ©Nr3   )Úsuperr&   rq   )r%   r1   Ú	__class__s     €r   r&   zJSONObjectWithFields.__init__  s%   ø€ Ü‰ÑÑ:Ð9˜dŸn™nÓ.Ð9°&Ð9Ó:r   rY   c                 óº   — 	 | j                   |   }|j                  t        | |«      «      S # t        $ r% t        j                  dj	                  |«      «      ‚w xY w)zßEncode a single field.

        :param str name: Name of the field to be encoded.

        :raises errors.SerializationError: if field cannot be serialized
        :raises errors.Error: if field could not be found

        zField not found: {0})rW   ÚKeyErrorr   ÚErrorÚformatr?   r_   )r%   rY   r   s      r   r?   zJSONObjectWithFields.encode  s\   € ð	DØ—L‘L Ñ&ˆEð �|‰|œG D¨$Ó/Ó0Ð0øô ò 	DÜ—,‘,Ð5×<Ñ<¸TÓBÓCÐCð	Dús	   ‚, ¬.Ac           	      ó„  — i }t        «       }| j                  j                  «       D ]U  \  }}t        | |«      }|j	                  |«      r|j                  ||f«       Œ7	 |j                  |«      ||j                  <   ŒW |S # t        j                  $ r+}t        j                  dj                  |||«      «      ‚d}~ww xY w)zSerialize fields to JSON.zCould not encode {0} ({1}): {2}N)ÚsetrW   rI   r_   r0   Úaddr?   r   r   ÚSerializationErrorry   )r%   ÚjobjÚomittedrp   r   r'   Úerrors          r   Úfields_to_partial_jsonz+JSONObjectWithFields.fields_to_partial_json/  s¶   € àˆÜ“%ˆØŸ<™<×-Ñ-Ó/ò 	‰KˆD�%Ü˜D $Ó'ˆEà�z‰z˜%Ô Ø—‘˜T 5˜MÕ*ðØ,1¯L©L¸Ó,?�D˜Ÿ™Ò)ð	ð ˆøô	 ×0Ñ0ò Ü ×3Ñ3Ø9×@Ñ@ÀÀuÈeÓTóð ûðús   ÁBÂB?Â&B:Â:B?c                 ó"   — | j                  «       S r"   )r�   )r%   s    r   Úto_partial_jsonz$JSONObjectWithFields.to_partial_jsonA  s   € Ø×*Ñ*Ó,Ð,r   r~   c                 ó4  — t        «       }| j                  j                  «       D ]<  \  }}|j                  rŒ|j                  |vsŒ"|j                  |j                  «       Œ> |r3t        j                  dj                  dj                  |«      «      «      ‚y )Nz&The following fields are required: {0}ú,)
r{   rW   rI   r   r   r|   r   ÚDeserializationErrorry   Újoin)r,   r~   ÚmissingÚ_r   s        r   Ú_check_requiredz$JSONObjectWithFields._check_requiredD  s   € ä“%ˆØŸ™×)Ñ)Ó+ò 	-‰HˆAˆuØ—?“? u§¡¸dÒ'BØ—‘˜EŸO™OÕ,ð	-ñ Ü×-Ñ-Ø8×?Ñ?ÀÇÁÈÓ@QÓRóð ð r   c           	      óŽ  — | j                  |«       i }| j                  j                  «       D ]S  \  }}|j                  |vr|j                  r|j
                  ||<   Œ0||j                     }	 |j                  |«      ||<   ŒU |S # t        j                  $ r+}t        j                  dj                  |||«      «      ‚d}~ww xY w)zDeserialize fields from JSON.z#Could not decode {0!r} ({1!r}): {2}N)
rŠ   rW   rI   r   r   r   r<   r   r†   ry   )r,   r~   ri   rp   r   r'   r€   s          r   Úfields_from_jsonz%JSONObjectWithFields.fields_from_jsonP  sÀ   € ð 	×Ñ˜DÔ!ØˆØŸ;™;×,Ñ,Ó.ò 
	‰KˆD�%Ø�‰ dÑ*¨u¯ªØ$Ÿ}™}��t’à˜UŸ_™_Ñ-�ðØ#(§<¡<°Ó#6�F˜4’Lð
	ð ˆøô	 ×2Ñ2ò Ü ×5Ñ5Ø=×DÑDÀTÈ5ÐRWÓXóð ûðús   Á.BÂCÂ&B?Â?Cr,   c                 ó0   —  | di | j                  |«      ¤ŽS rs   )rŒ   )r,   r~   s     r   Ú	from_jsonzJSONObjectWithFields.from_jsonb  s   € ñ Ñ0�S×)Ñ)¨$Ó/Ñ0Ð0r   )rM   rN   rO   rP   rS   r   rR   r   rq   r&   r?   r�   rƒ   r   rŠ   rŒ   r
   rk   rŽ   Ú__classcell__)ru   s   @r   rl   rl   ú   s  ø„ ñð4 ðL˜$˜s C˜x™.ò Ló ðLð; ð ;¨õ ;ð1˜3ð 1 3ó 1ð ¨¨S°#¨X©ó ð$-  c¨3 h¡ó -ð ð	 7¨3°¨8Ñ#4ð 	¸ò 	ó ð	ð ð G¨C°¨HÑ$5ð ¸#ò ó ðð" ð1ØÐ-Ñ.ð1Ø6=¸cÀ3¸hÑ6Gð1à	$ò1ó ô1r   )Ú	metaclassÚdatac                 óJ   — t        j                  | «      j                  d«      S )zJEncode JOSE Base-64 field.

    :param bytes data:
    :rtype: `str`

    Úascii)r   Ú	b64encoder<   )r‘   s    r   Úencode_b64joser•   i  s   € ô �=‰=˜Ó×%Ñ% gÓ.Ð.r   ÚsizeÚminimumc                 ó:  — 	 t        j                  | j                  «       «      }|�D|st        |«      |k7  s|r2t        |«      |k  r$t        j                  dj                  |«      «      ‚|S # t        j                  $ r}t        j                  |«      ‚d}~ww xY w)a  Decode JOSE Base-64 field.

    :param unicode data:
    :param int size: Required length (after decoding).
    :param bool minimum: If ``True``, then `size` will be treated as
        minimum required length, as opposed to exact equality.

    :rtype: bytes

    Nz&Expected at least or exactly {0} bytes)	r   Ú	b64decoder?   Úbinasciirx   r   r†   Úlenry   )r‘   r–   r—   Údecodedr€   s        r   Údecode_b64joser�   t  sˆ   € ð1Ü—-‘- §¡£Ó.ˆð ÐÙœ˜W›¨Ò-±7¼sÀ7»|ÈdÒ?Rä×)Ñ)Ð*R×*YÑ*YÐZ^Ó*_Ó`Ð`à€Nøô �>‰>ò 1Ü×)Ñ)¨%Ó0Ð0ûð1ús   ‚#A- Á-BÂ BÂBr'   c                 óH   — t        j                  | «      j                  «       S )z;Hexlify.

    :param bytes value:
    :rtype: unicode

    )rš   Úhexlifyr<   )r'   s    r   Úencode_hex16r    Œ  s   € ô ×Ñ˜EÓ"×)Ñ)Ó+Ð+r   c                 ó&  — | j                  «       }|�:|st        |«      |dz  k7  s|r%t        |«      |dz  k  rt        j                  «       ‚	 t	        j
                  |«      S # t        j                  $ r}t        j                  |«      ‚d}~ww xY w)a  Decode hexlified field.

    :param unicode value:
    :param int size: Required length (after decoding).
    :param bool minimum: If ``True``, then `size` will be treated as
        minimum required length, as opposed to exact equality.

    :rtype: bytes

    Né   )r?   r›   r   r†   rš   Ú	unhexlifyrx   )r'   r–   r—   Úvalue_br€   s        r   Údecode_hex16r¥   –  s…   € ð �l‰l‹n€GØÐÙœ˜W›¨°©Ò1±wÄ3ÀwÃ<ÐRVÐYZÑRZÒCZä×)Ñ)Ó+Ð+ð1Ü×!Ñ! 'Ó*Ð*øÜ�>‰>ò 1Ü×)Ñ)¨%Ó0Ð0ûð1ús   ÁA# Á#BÁ6BÂBÚcertc                 óÎ   — t        | j                  t        j                  «      rt	        d«      ‚t        t        j                  t        j                  | j                  «      «      S )z…Encode certificate as JOSE Base-64 DER.

    :type cert: `OpenSSL.crypto.X509` wrapped in `.ComparableX509`
    :rtype: unicode

    z.Error input is actually a certificate request.)r)   Úwrappedr   ÚX509Reqrb   r•   Údump_certificateÚFILETYPE_ASN1)r¦   s    r   Úencode_certr¬   ¬  sD   € ô �$—,‘,¤§¡Ô/ÜÐIÓJÐJäœ&×1Ñ1´&×2FÑ2FÈÏÉÓUÓVÐVr   Úb64derc                 óä   — 	 t        j                  t        j                  t        j                  t        | «      «      «      S # t        j                  $ r}t        j                  |«      ‚d}~ww xY w)z�Decode JOSE Base-64 DER-encoded certificate.

    :param unicode b64der:
    :rtype: `OpenSSL.crypto.X509` wrapped in `.ComparableX509`

    N)	r   ÚComparableX509r   Úload_certificater«   r�   rx   r   r†   ©r­   r€   s     r   Údecode_certr²   ¹  s\   € ð1Ü×"Ñ"Ü×#Ñ#¤F×$8Ñ$8¼.ÈÓ:PÓQó
ð 	
øô �<‰<ò 1Ü×)Ñ)¨%Ó0Ð0ûð1úó   ‚?A ÁA/ÁA*Á*A/Úcsrc                 óÎ   — t        | j                  t        j                  «      rt	        d«      ‚t        t        j                  t        j                  | j                  «      «      S )zEncode CSR as JOSE Base-64 DER.

    :type csr: `OpenSSL.crypto.X509Req` wrapped in `.ComparableX509`
    :rtype: unicode

    z&Error input is actually a certificate.)r)   r¨   r   ÚX509rb   r•   Údump_certificate_requestr«   )r´   s    r   Ú
encode_csrr¸   È  sG   € ô �#—+‘+œvŸ{™{Ô+ÜÐAÓBÐBäœ&×9Ñ9¼&×:NÑ:NÐPS×P[ÑP[Ó\Ó]Ð]r   c                 óä   — 	 t        j                  t        j                  t        j                  t        | «      «      «      S # t        j                  $ r}t        j                  |«      ‚d}~ww xY w)zˆDecode JOSE Base-64 DER-encoded CSR.

    :param unicode b64der:
    :rtype: `OpenSSL.crypto.X509Req` wrapped in `.ComparableX509`

    N)	r   r¯   r   Úload_certificate_requestr«   r�   rx   r   r†   r±   s     r   Ú
decode_csrr»   Õ  s]   € ð1Ü×"Ñ"Ü×+Ñ+¬F×,@Ñ,@Ä.ÐQWÓBXÓYó
ð 	
øô �<‰<ò 1Ü×)Ñ)¨%Ó0Ð0ûð1úr³   Ú GenericTypedJSONObjectWithFieldsÚTypedJSONObjectWithFieldsc            	       óä   — e Zd ZU dZeZeed<   	 dZeed<   	 eZ	e
eef   ed<   	 e	 ddee   dee   dee   fd	„«       Zed
eeef   ded    fd„«       Zde
eef   fd„Zed
eeef   dd fd„«       Zy)r½   zJSON object with type.Útypr4   Útype_field_nameÚTYPESNÚtype_clsr   c                 óD   — |€|j                   n|}|| j                  |<   |S )z(Register class for JSON deserialization.)r¿   rÁ   )r,   rÂ   r¿   s      r   Úregisterz"TypedJSONObjectWithFields.registerù  s%   € ð
 "˜kˆh�lŠl¨sˆØ!ˆ�	‰	�#‰Øˆr   r~   c                 óè  — | | j                   j                  «       v r>| j                  |vr.t        j                  dj                  | j                  «      «      ‚| S t        |t        «      s$t        j                  dj                  |«      «      ‚	 || j                     }	 | j                   |   S # t        $ r t        j                  d«      ‚w xY w# t        $ r t        j                  ||«      ‚w xY w)z&Get the registered class for ``jobj``.zMissing type field ({0})z{0} is not a dictionary objectzmissing type field)
rÁ   ÚvaluesrÀ   r   r†   ry   r)   rG   rw   ÚUnrecognizedTypeError)r,   r~   r¿   s      r   Úget_type_clsz&TypedJSONObjectWithFields.get_type_cls  sî   € ð �#—)‘)×"Ñ"Ó$Ñ$Ø×"Ñ"¨$Ñ.Ü×1Ñ1Ø.×5Ñ5°c×6IÑ6IÓJóð ð ˆJä˜$¤Ô%Ü×-Ñ-Ð.N×.UÑ.UÐVZÓ.[Ó\Ð\ð	DØ�s×*Ñ*Ñ+ˆCð	:Ø—9‘9˜S‘>Ð!øô	 ò 	DÜ×-Ñ-Ð.BÓCÐCð	Dûô
 ò 	:Ü×.Ñ.¨s°DÓ9Ð9ð	:ús   ÂB/ Â C Â/CÃ C1c                 óX   — | j                  «       }| j                  || j                  <   |S )a  Get JSON serializable object.

        :returns: Serializable JSON object representing ACME typed object.
            :meth:`validate` will almost certainly not work, due to reasons
            explained in :class:`josepy.interfaces.IJSONSerializable`.
        :rtype: dict

        )r�   r¿   rÀ   )r%   r~   s     r   rƒ   z)TypedJSONObjectWithFields.to_partial_json  s+   € ð ×*Ñ*Ó,ˆØ%)§X¡XˆˆT×!Ñ!Ñ"Øˆr   c                 óR   — | j                  |«      } |di |j                  |«      ¤ŽS )z¯Deserialize ACME object from valid JSON object.

        :raises josepy.errors.UnrecognizedTypeError: if type
            of the ACME object has not been registered.

        r3   )rÈ   rŒ   )r,   r~   rÂ   s      r   rŽ   z#TypedJSONObjectWithFields.from_json(  s-   € ð ×#Ñ# DÓ)ˆÙÑ:˜(×3Ñ3°DÓ9Ñ:Ð:r   r"   )rM   rN   rO   rP   ÚNotImplementedr¿   rR   r]   rÀ   rÁ   r   r
   rS   r¼   r	   rÄ   r   r   rÈ   rƒ   rŽ   r3   r   r   r½   r½   é  sæ   … Ù à€CˆÓØ7à!€O�SÓ!ðð ,€Eˆ4��T�	‰?Ó+Ø3ààTXñØÐ<Ñ=ðØDLÈSÁMðà	Ð.Ñ	/òó ðð ð: ¨¨S¨Ñ 1ð :°dÐ;VÑ6Wò :ó ð:ð0  c¨3 h¡ó ð ð	;˜W S¨# XÑ.ð 	;Ð3Nò 	;ó ñ	;r   rL   )NF)0rP   re   rš   ÚloggingÚtypingr   r   r   r   r   r   r	   r
   r   ÚOpenSSLr   Újosepyr   r   r   r   Ú	getLoggerrM   ÚloggerrR   r*   r   r   r   rf   rV   rk   ÚImmutableMapÚJSONDeSerializablerl   Úbytesr•   Úintr�   r    r¥   r¯   r¬   r²   r¸   r»   r¼   r½   r3   r   r   ú<module>rÖ      s  ðñó Û Û ÷
÷ 
õ 
õ ç 0Ó 0à	ˆ×	Ñ	˜8Ó	$€ð
 ØØ.2Ø.2ñØðàðð ðð �h ˜u c˜zÑ*Ñ+ð	ð
 �h ˜u c˜zÑ*Ñ+ðð 	ó÷0nñ nôbM�%ô MôC@˜sŸ{™{ô C@ñL &Ð&CÐKaÔbÐ ôl1Ø×Ñ�z×4Ñ4Ð@Xõl1ð^/˜ð / 3ó /ñ˜ð  H¨S¡Mð À4ð ÐTYó ð0,˜ð , #ó ,ñ1˜ð 1 8¨C¡=ð 1À$ð 1ÐSXó 1ð,
W�d×)Ñ)ð 
W¨có 
Wð1˜ð 1 × 3Ñ 3ó 1ð
^�D×'Ñ'ð 
^¨Có 
^ð1�sð 1˜t×2Ñ2ó 1ñ $+Ø&Ð.Iô$Ð  ô
I;Ð 4õ I;r   