https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/pymacaroons/serializers/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/pymacaroons/serializers/__pycache__/json_serializer.cpython-310.pyc
o

�%�YU�@sPddlZddlZddlmZGdd�de�Zdd�Zdd�Zd	d
�Zdd�Z	dS)
�N)�utilsc@s@eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dS)�JsonSerializerz8Serializer used to produce JSON macaroon format v1.
    cCs,ddlm}|j|jkr|�|�S|�|�S)z�Serialize the macaroon in JSON format indicated by the version field.

        @param macaroon the macaroon to serialize.
        @return JSON macaroon.
        r)�macaroon)�pymacaroonsr�version�MACAROON_V1�
_serialize_v1�
_serialize_v2)�self�mr�r�I/usr/lib/python3/dist-packages/pymacaroons/serializers/json_serializer.py�	serialize	s

zJsonSerializer.serializecCsHt�|j�|jd�}|jr|j|d<|jrdd�|jD�|d<t�|�S)z�Serialize the macaroon in JSON format v1.

        @param macaroon the macaroon to serialize.
        @return JSON macaroon.
        )�
identifier�	signature�locationcS�g|]}t|��qSr)�_caveat_v1_to_dict��.0�caveatrrr
�
<listcomp>!��z0JsonSerializer._serialize_v1.<locals>.<listcomp>�caveats)r�convert_to_stringrrrr�json�dumps�r
r�
serializedrrr
rs
�

�
zJsonSerializer._serialize_v1cCsZi}t|j|d�tt�|j�|d�|jr|j|d<|jr(dd�|jD�|d<t�|�S)z�Serialize the macaroon in JSON format v2.

        @param macaroon the macaroon to serialize.
        @return JSON macaroon in v2 format.
        �i�s�lcSrr)�_caveat_v2_to_dictrrrr
r4rz0JsonSerializer._serialize_v2.<locals>.<listcomp>�c)	�_add_json_binary_field�identifier_bytes�binascii�	unhexlify�signature_bytesrrrrrrrr
r	&s�

�
zJsonSerializer._serialize_v2cCs,t�|�}|�d�dur|�|�S|�|�S)z�Deserialize a JSON macaroon depending on the format.

        @param serialized the macaroon in JSON format.
        @return the macaroon object.
        rN)r�loads�get�_deserialize_v2�_deserialize_v1)r
r�deserializedrrr
�deserialize9s


zJsonSerializer.deserializecCs�ddlm}m}ddlm}g}|�dg�D]&}||d|�d�r(t�|d�nd|�d�r2|dnd|d	�}|�|�q||�d
�|d||d|d
�S)z�Deserialize a JSON macaroon in v1 format.

        @param serialized the macaroon in v1 JSON format.
        @return the macaroon object.
        r)�Macaroonr��Caveatr�cid�vidN�cl��	caveat_id�verification_key_idrrrrr�rrrrr)	�pymacaroons.macaroonr/r�pymacaroons.caveatr1r*r�
raw_b64decode�append)r
r-r/rr1rr#rrrr
r,Es&��zJsonSerializer._deserialize_v1c	Cs�ddlm}m}ddlm}g}|�dg�D]}|t|d�t|d�t|d�|d�}|�|�q|t|d�t|d�|t�	t|d	��|d
�S)z�Deserialize a JSON macaroon v2.

        @param serialized the macaroon in JSON format v2.
        @return the macaroon object.
        r)r/�MACAROON_V2r0r#r�vr!r5r r8)
r9r/r=r:r1r*�_read_json_binary_fieldr<r&�hexlify)r
r-r/r=r1rr#rrrr
r+es(���zJsonSerializer._deserialize_v2N)
�__name__�
__module__�__qualname__�__doc__rrr	r.r,r+rrrr
rs rcCsLi}t|j�dkr|j|d<|jrt�|j��d�|d<|jr$|j|d<|S)zT Return a caveat as a dictionary for export as the JSON
    macaroon v1 format.
    rr2�utf-8r3r4)�lenr6r7r�raw_urlsafe_b64encode�decoder�r#rrrr
r�s
��
rcCsHi}t|j�dkrt|j|d�|jrt|j|d�|jr"|j|d<|S)zT Return a caveat as a dictionary for export as the JSON
    macaroon v2 format.
    rrr>r!)rF�caveat_id_bytesr$r7rrIrrr
r"�s
r"cCsJz|�d�}|||<WdSty$t�|��d�}|||d<YdSw)z� Set the given field to the given val (a bytearray) in the serialized
    dictionary.

    If the value isn't valid utf-8, we base64 encode it and use field+"64"
    as the field name.
    rE�64N)rH�UnicodeDecodeErrorrrG)�br�field�valrrr
r$�s
�r$cCs@|�|�}|durt�|�S|�|d�}|durdSt�|�S)zJ Read the value of a JSON field that may be string or base64-encoded.
    NrK)r*r�convert_to_bytes�raw_urlsafe_b64decode)r-rNrOrrr
r?�s


r?)
r&rrr�objectrrr"r$r?rrrr
�<module>sz

https://t.me/RX1948 - 2025