HEX
Server: Apache/2.4.58 (Ubuntu)
System: Linux ns3133907 6.8.0-86-generic #87-Ubuntu SMP PREEMPT_DYNAMIC Mon Sep 22 18:03:36 UTC 2025 x86_64
User: cssnetorguk (1024)
PHP: 8.2.28
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/pymacaroons/__pycache__/macaroon.cpython-312.pyc
�

�%�Ya���ddlmZddlZddlmZddlmZddlmZddl	m
Z
ddlmZm
Z
mZddlmZmZd	Zd
ZGd�de�Zy)
�)�unicode_literalsN)�standard_b64encode)�HashSignaturesBinder)�BinarySerializer)�MacaroonInitException)�convert_to_bytes�convert_to_string�create_initial_signature)�FirstPartyCaveatDelegate�ThirdPartyCaveatDelegate��c�0�eZdZdddddefd�Zedd��Zed��Zejd��Zed��Z
ed��Zed��Zejd	��Zed
��Z
e
jd��Z
ed��Zd
�Zdd�Zd�Zd�Zd�Zd�Zd�Zd�Zy)�MacaroonNc��|tkDrt}||_|xsg|_|xsd|_|xsd|_|xsd|_t
�|_t�|_	|r%tt|�|j�|_yy)N�)
�MACAROON_V2�_version�caveats�location�
identifier�	signaturer�first_party_caveat_delegater�third_party_caveat_delegater
r�identifier_bytes)�selfrr�keyrr�versions       �6/usr/lib/python3/dist-packages/pymacaroons/macaroon.py�__init__zMacaroon.__init__s���[� �!�G���
��}�"��� ��B��
�$�*����"��b���+C�+E��(�+C�+E��(��5� ��%�t�'<�'<��D�N��c�Z�|xs
t�}|r|j|�Std��)Nz Must supply serialized macaroon.)r�deserializer)�cls�
serialized�
serializers   rr#zMacaroon.deserialize+s4���5�#3�#5�
���)�)�*�5�5�'�2��
r!c�,�t|j�S�N)r	�	_location�rs rrzMacaroon.location5s�� ����0�0r!c�$�t|�|_yr()rr)�r�string_or_bytess  rrzMacaroon.location9s��)�/�:��r!c��|jSr()rr*s rrzMacaroon.version=s���}�}�r!c�j�|jtk(rt|j�S|jSr()r�MACAROON_V1r	�_identifierr*s rrzMacaroon.identifierAs+���<�<�;�&�$�T�%5�%5�6�6����r!c��|jSr()r1r*s rrzMacaroon.identifier_bytesGs�����r!c�$�t|�|_yr()rr1r,s  rrzMacaroon.identifierKs��+�O�<��r!c�,�t|j�Sr()r	�
_signaturer*s rrzMacaroon.signatureOs�� ����1�1r!c�$�t|�|_yr()rr5r,s  rrzMacaroon.signatureSs��*�?�;��r!c��|jSr()r5r*s r�signature_byteszMacaroon.signature_bytesWs�����r!c�,�tj|�Sr()�copy�deepcopyr*s rr:z
Macaroon.copy[s���}�}�T�"�"r!c�@�|xs
t�}|j|�Sr()r�	serialize)rr&s  rr=zMacaroon.serialize^s!���5�#3�#5�
��#�#�D�)�)r!c
��dj|j��}	|dj|j��z
}|jD]�}	|djt	|j���z
}|js�9|js�Ft	t|j��}|d	j|�
�z
}|dj|j��z
}��|d
j|j��z
}|S#t$r5|djt	t|j����z
}Y��wxYw#t$r5|djt	t|j����z
}Y��
wxYw)Nzlocation {loc}
)�loczidentifier {id}
)�idzidentifier64 {id}
z
cid {cid}
)�cidzcid64 {cid}
z
vid {vid}
)�vidzcl {cl}
)�clzsignature {sig})�sig)�formatrr�UnicodeEncodeErrorr	rrr�	caveat_id�caveat_id_bytes�verification_key_idr)r�combined�caveatrBs    r�inspectzMacaroon.inspectbs���%�,�,����,�?��	��+�2�2�d�o�o�2�F�F�H�
�l�l�
	C�F�
��M�0�0�)�&�*:�*:�;�1�=�=���)�)�f�o�o�'�&�v�'A�'A�B����M�0�0�S�0�9�9���K�.�.�&�/�/�.�B�B��
	C�	�%�,�,����,�@�@�����'"�	��-�4�4�8I�&�t�'<�'<�=�9�4��
�H�	��&�
��O�2�2�7H�&�v�'=�'=�>�8�2����
�s#�D�
(E�:E�E�:F�Fc�b�|jD�cgc]}|j�s�|��c}Scc}wr()r�first_party�rrKs  r�first_party_caveatszMacaroon.first_party_caveats{�%��%)�\�\�J�6�V�5G�5G�5I��J�J��J��,�,c�b�|jD�cgc]}|j�s�|��c}Scc}wr()r�third_partyrOs  r�third_party_caveatszMacaroon.third_party_caveats~rQrRc�V�|j�}t|�j|�S)a$ Return a new discharge macaroon bound to the receiving macaroon's
        current signature so that it can be used in a request.

        This must be done before a discharge macaroon is sent to a server.

        :param discharge_macaroon:
        :return: bound discharge macaroon
        )r:r�bind)r�discharge_macaroon�	protecteds   r�prepare_for_requestzMacaroon.prepare_for_request�s(��'�+�+�-�	�#�D�)�.�.�y�9�9r!c�>�|jj||fi|��Sr()r�add_first_party_caveat)r�	predicate�kwargss   rr\zMacaroon.add_first_party_caveat�s*��F�t�/�/�F�F��)�
�%�
�	
r!c�B�|jj||||fi|��Sr()r�add_third_party_caveat)rrr�key_idr^s     rr`zMacaroon.add_third_party_caveat�s.��F�t�/�/�F�F��(�C��
�+1�
�	
r!r()�__name__�
__module__�__qualname__r0r �classmethodr#�propertyr�setterrrrrr8r:r=rLrPrUrZr\r`�r!rrrs��� ����$�
�*�����1��1��_�_�;��;������ �� �
� �� ����=��=��2��2����<��<�����#�*��2K�K�
:�
�

r!r)�
__future__rr:�base64r�pymacaroons.bindersr�)pymacaroons.serializers.binary_serializerr�pymacaroons.exceptionsr�pymacaroons.utilsrr	r
�pymacaroons.caveat_delegatesrrr0r�objectrrhr!r�<module>rqs@��'��%�4�F�8���
8�����A
�v�A
r!