§
    BP„jŽ  ã                   ó¦   — d Z ddlZddlZddlZddlZddlmZ dZdZ ej	        d¦  «        dd„¦   «         Z
 ej	        d	¦  «        dd
„¦   «         ZdS )z4Helper methods for creating & verifying XSRF tokens.é    N)Ú_helpersó   :i  é   Ú c                 ó’  — t          j        t          j        | d¬¦  «        ¦  «        }|                     t          j        t          |¦  «        d¬¦  «        ¦  «         |                     t          ¦  «         |                     t          j        |d¬¦  «        ¦  «         |                     t          ¦  «         t          j        t          |pt          t          j        ¦   «         ¦  «        ¦  «        d¬¦  «        }|                     |¦  «         | 	                    ¦   «         }t          j        |t          z   |z   ¦  «        }|S )aá  Generates a URL-safe token for the given user, action, time tuple.

    Args:
        key: secret key to use.
        user_id: the user ID of the authenticated user.
        action_id: a string identifier of the action they requested
                   authorization for.
        when: the time in seconds since the epoch at which the user was
              authorized for this action. If not set the current time is used.

    Returns:
        A string XSRF protection token.
    zutf-8)Úencoding)ÚhmacÚnewr   Ú	_to_bytesÚupdateÚstrÚ	DELIMITERÚintÚtimeÚdigestÚbase64Úurlsafe_b64encode)ÚkeyÚuser_idÚ	action_idÚwhenÚdigesterr   Útokens          úb/root/disk_3tb/conda_envs/Huy-visual/lib/python3.11/site-packages/oauth2client/contrib/xsrfutil.pyÚgenerate_tokenr       s  € õ Œx�Ô*¨3¸ÐAÑAÔAÑBÔB€HØ‡O‚O•HÔ&¥s¨7¡|¤|¸gÐFÑFÔFÑGÔGÐGØ‡O‚O•IÑÔÐØ‡O‚O•HÔ& y¸7ÐCÑCÔCÑDÔDÐDØ‡O‚O•IÑÔÐÝÔ�c $Ð":­#­d¬i©k¬kÑ*:Ô*:Ñ;Ô;ÀgÐNÑNÔN€DØ‡O‚O�DÑÔÐØ�_Š_ÑÔ€FåÔ$ V­iÑ%7¸$Ñ%>Ñ?Ô?€EØ€Ló    é   c                 ó  — |sdS 	 t          j        |¦  «        }t          |                     t          ¦  «        d         ¦  «        }n## t
          t          t          j        f$ r Y dS w xY w|€t          j	        ¦   «         }||z
  t          k    rdS t          | |||¬¦  «        }t          |¦  «        t          |¦  «        k    rdS d}t          t          |¦  «        t          |¦  «        ¦  «        D ]\  }	}
||	|
z  z  }Œ| S )aR  Validates that the given token authorizes the user for the action.

    Tokens are invalid if the time of issue is too old or if the token
    does not match what generateToken outputs (i.e. the token was forged).

    Args:
        key: secret key to use.
        token: a string of the token generated by generateToken.
        user_id: the user ID of the authenticated user.
        action_id: a string identifier of the action they requested
                   authorization for.

    Returns:
        A boolean - True if the user is authorized for the action, False
        otherwise.
    FéÿÿÿÿN)r   r   r   )r   Úurlsafe_b64decoder   Úsplitr   Ú	TypeErrorÚ
ValueErrorÚbinasciiÚErrorr   ÚDEFAULT_TIMEOUT_SECSr   ÚlenÚzipÚ	bytearray)r   r   r   r   Úcurrent_timeÚdecodedÚ
token_timeÚexpected_tokenÚ	differentÚxÚys              r   Úvalidate_tokenr1   <   s!  € ð$ ð ØˆuðÝÔ*¨5Ñ1Ô1ˆÝ˜Ÿš¥yÑ1Ô1°"Ô5Ñ6Ô6ˆ
ˆ
øÝ•z¥8¤>Ð2ð ð ð ØˆuˆuðøøøàÐÝ”y‘{”{ˆà�jÑ Õ#7Ò7Ð7Øˆuõ $ C¨¸IØ)3ð5ñ 5ô 5€Nå
ˆ5�z„z•S˜Ñ(Ô(Ò(Ð(Øˆuð €IÝ•I˜eÑ$Ô$¥i°Ñ&?Ô&?Ñ@Ô@ð ð ‰ˆˆ1Ø�Q˜‘UÑˆ	ˆ	Øˆ=Ðs   †AA ÁA(Á'A()r   N)Ú__doc__r   r$   r	   r   Úoauth2clientr   r   r&   Ú
positionalr   r1   © r   r   ú<module>r6      s¸   ðð ;Ð :à €€€Ø €€€Ø €€€Ø €€€à !Ð !Ð !Ð !Ð !Ð !ð €	ð Ð ð €Ô�QÑÔðð ð ñ Ôðð6 €Ô�QÑÔð(ð (ð (ñ Ôð(ð (ð (r   