xbp 0.9.1

XBP is a zero-config build pack that can also interact with proxies, kafka, sockets, synthetic monitors.
Documentation
�

�d�h���SSKrSSKrSSKrSSKJr SSKrSSKr\"5 SSKr\R"5S:Xa\R"S5r
O\R"S5r
\R"S5rSr\(d\
"S5e\
b#\"\
S	5r\R!5rSSS5 O\
"S
5eSrSrS
rSrg!,(df   N=f)�N)�load_dotenv�Windows�XBP_PEM_PATH_WIN64�XBP_PEM_PATH�XBP_GITHUB_APP_CLIENT_IDzjwt_expiration_time.txtz<GitHub App Client ID is not set in the environment variable.�rbz5PEM file path is not set in the environment variable.c���[RR[5(aA[	[S5n[UR
5R55sSSS5 $g!,(df   g=f)N�rr)�os�path�exists�jwt_expiration_file�open�int�read�strip)�fs �6C:\Users\floris\Documents\GitHub\xbp\github_jwt_key.py�load_last_expiration_timer sO��	�w�w�~�~�)�*�*�
�%�s�
+�q��q�v�v�x�~�~�'�(�,�
+��,�
+��s�'A+�+
A9c��[[S5nUR[U55 SSS5 g!,(df   g=f)N�w)rr�write�str)�expiration_timers  r�save_expiration_timer(s,��	
�!�3�	'�1�	����O�$�%�
(�	'�	'�s	�5�
Ac���[5n[[R"55nX:a?[S5 [	SS5nUR5R
5sSSS5 $UUS-[S.n[R"U[SS9n[US-5 [	SS5nURU5 SSS5 [S	5 U$!,(df   Nv=f!,(df   N,=f)
Nz-JWT is still valid, using the existing token.zjwt.txtr
iX)�iat�exp�iss�RS256)�	algorithmrz&JWT has expired. Generating a new one.)
rr�time�printrrr�	client_id�jwt�encode�signing_keyrr)�last_expiration_time�current_time�jwt_file�payload�encoded_jwts     r�generate_jwtr--s���4�6���t�y�y�{�#�L��*�
�=�>�
�)�S�
!�X��=�=�?�(�(�*�"�
!���c�!��
�G��*�*�W�k�W�E�K����+�,�
�i��	�����{�#�
�
�
2�3���1"�
!��(
�	�s�C�.C&�
C#�&
C4c���SUSUS3n[SU5 [SU5 SU3SS.n[R"X4S	9nURS
:Xa7[SUR5 [SUR5 [S
5eURS:wa@[SUR35 [SUR35 UR
5 UR5n[SU5 SU;a![S[R"USS9-5eUSnSUS3nSU3SS.n[R"X4S	9nURS:wa@[SUR35 [SUR35 UR
5 UR5n[S[R"USS95 URS5nU(d[S5e[SU5 U$)Nzhttps://api.github.com/repos/�/z
/installationu🚀 ~ url:u🚀 ~ encoded_jwt:zBearer zapplication/vnd.github.v3+json)�
Authorization�Accept)�headersi�u🚀 ~ response.status_code:u🚀 ~ response.text:zRepository not found��zError: zResponse content: u🚀 ~ response_content:�idzFThe response from GitHub API does not contain 'id'. Response content: �)�indentz)https://api.github.com/app/installations/z/access_tokens��u🚀 ~ response:�tokenz4Installation access token not found in the response.u*🚀 ~ installation_access_token:)r#�requests�get�status_code�text�
ValueError�raise_for_status�json�KeyError�dumps�post)	r,�github_username�github_repository_name�urlr2�response�response_content�installation_id�installation_access_tokens	         r�generate_installation_tokenrJPs���)�/�):�!�<R�;S�S`�
a�C�	�
&��,�	�
.��<�#�;�-�0�2��G�
�|�|�C�1�H����s�"�
�,�h�.B�.B�C�
�%�x�}�}�5��/�0�0����s�"�
���,�,�-�.�/�
�"�8�=�=�/�2�3��!�!�#� �}�}���	�
$�&6�7��#�#��T��j�j�)�!�4�
5�
�	
�
'�t�,�O�5�o�5F�n�
U�C�#�;�-�0�2��G�
�}�}�S�2�H����s�"�
���,�,�-�.�/�
�"�8�=�=�/�2�3��!�!�#��}�}���	�
+�T�Z�Z�8H�QR�-S�T� 0� 4� 4�W� =��$��O�P�P�	�
<�>W�X�$�$�)rr"r%�dotenvrr9r?�platform�system�getenv�pemr$rr=r�pem_filerr'rrr-rJ�rKr�<module>rSs���	��
�����
���?�?��	�!�
�)�)�(�
)�C�
�)�)�N�
#�C��I�I�0�1�	�/���
�S�
T�T��?�	
�c�4��H��m�m�o��
���L�
M�M�
�&�
 �F:%�o
��s�B>�>
C