
    (phH                        S r SSKrSSKrSSKrSSKJr  SSKJr  SSKJr  Sr	Sr
\" / SQ5      r\" / S	Q5      r " S
 S5      rS rS rSAS jrSAS jrSAS jrSAS jrSAS jrSAS jrSBS jrSBS jrSAS jrSAS jrSCS jrS rS rSAS jrS rSAS jr S r! " S S \RD                  5      r# " S! S"\RD                  5      r$ " S# S$\RJ                  5      r& " S% S&\RN                  5      r( " S' S(\RN                  5      r) " S) S*\RD                  5      r* " S+ S,\RV                  5      r, " S- S.\RZ                  5      r. " S/ S0\RZ                  5      r/ " S1 S2\RZ                  5      r0 " S3 S4\RN                  5      r1 " S5 S6\RZ                  5      r2 " S7 S8\RN                  5      r3 " S9 S:\Rh                  5      r5 " S; S<\Rh                  5      r6\2\$\#\$\/\&\(\)\*\0\.\5\6S=.r7S> r8S? r9S@ r:g)DzFirebase auth utils.    N)parse)
exceptions)_utilsFIREBASE_AUTH_EMULATOR_HOSTi  )acramrat_hashaud	auth_timeazpcnfc_hashexpiatissjtinbfnoncesubfirebase)VERIFY_EMAILEMAIL_SIGNINPASSWORD_RESETc                   :    \ rS rSrSrS rS rS r\S 5       r	Sr
g)	PageIterator#   a  An iterator that allows iterating over a sequence of items, one at a time.

This implementation loads a page of items into memory, and iterates on them. When the whole
page has been traversed, it loads another page. This class never keeps more than one page
of entries in memory.
c                 B    U(       d  [        S5      eXl        S U l        g )NzCurrent page must not be None.)
ValueError_current_page_iter)selfcurrent_pages     M/var/www/html/venv/lib/python3.13/site-packages/firebase_admin/_auth_utils.py__init__PageIterator.__init__+   s    =>>)
    c                 p   U R                   c  [        U R                  5      U l          [        U R                   5      $ ! [         am    U R
                  R                  (       aP  U R
                  R                  5       U l        [        U R                  5      U l         [        U R                   5      s $ e f = fN)r    iteritemsnextStopIterationr   has_next_pageget_next_pager!   s    r#   __next__PageIterator.__next__2   s    ::djj)DJ		

## 	!!//%)%7%7%E%E%G"!$**-
DJJ''	s   > A3B53B5c                     U $ r(    r/   s    r#   __iter__PageIterator.__iter__A   s    r&   c                     [         er(   )NotImplementedErrorr/   s    r#   r*   PageIterator.itemsD   s    !!r&   )r   r    N)__name__
__module____qualname____firstlineno____doc__r$   r0   r4   propertyr*   __static_attributes__r3   r&   r#   r   r   #   s*     " "r&   r   c                      [         R                  " [        S5      n U (       a%  SU ;   a  [        SR	                  [        U 5      5      eU $ )N z//z6Invalid {0}: "{1}". It must follow format "host:port".)osgetenvEMULATOR_HOST_ENV_VARr   format)emulator_hosts    r#   get_emulator_hostrG   I   sE    II3R8M.DKK%}67 	7 r&   c                      [        5       S:g  $ )NrA   )rG   r3   r&   r#   is_emulatedrI   R   s    "$$r&   c                     U c  U(       d  g [        U [        5      (       a  U (       a  [        U 5      S:  a  [        SR	                  U 5      5      eU $ )N   zXInvalid uid: "{0}". The uid must be a non-empty string with no more than 128 characters.)
isinstancestrlenr   rE   )uidrequireds     r#   validate_uidrQ   V   sG    
{8c3sc#hn &+' 	' Jr&   c                 $   U c  U(       d  g [        U [        5      (       a  U (       d  [        SR                  U 5      5      eU R	                  S5      n[        U5      S:w  d  US   (       a
  US   (       d  [        SR                  U 5      5      eU $ )Nz7Invalid email: "{0}". Email must be a non-empty string.@   r      z&Malformed email address string: "{0}".)rL   rM   r   rE   splitrN   )emailrP   partss      r#   validate_emailrY   _   sy    }XeS!!ELLUSU 	UKKE
5zQeAheAhAHHOPPLr&   c                     U c  U(       d  g[        U [        5      (       a  U (       d  [        SR                  U 5      5      eU R	                  S5      (       a  [
        R                  " SU 5      (       d  [        SR                  U 5      5      eU $ )zValidates the specified phone number.

Phone number vlidation is very lax here. Backend will enforce E.164 spec compliance, and
normalize accordingly. Here we check if the number starts with + sign, and contains at
least one alphanumeric character.
NzEInvalid phone number: "{0}". Phone number must be a non-empty string.+z[a-zA-Z0-9]zVInvalid phone number: "{0}". Phone number must be a valid, E.164 compliant identifier.)rL   rM   r   rE   
startswithresearch)phonerP   s     r#   validate_phoner`   j   s{     }XeS!! ##)6%=2 	2C  		-(G(G 117@ 	@Lr&   c                 z    U c  U(       d  g [        U [        5      (       a  [        U 5      S:  a  [        S5      eU $ )N   zNInvalid password string. Password must be a string at least 6 characters long.)rL   rM   rN   r   )passwordrP   s     r#   validate_passwordrd   {   s<    h$$H(9\^ 	^Or&   c                     U c  U(       d  g [        U [        5      (       a  U (       d  [        SR                  U5      5      eU $ )Nz&{0} must be a non-empty byte sequence.)rL   bytesr   rE   )valuelabelrP   s      r#   validate_bytesri      s7    }XeU##5AHHOPPLr&   c                     U c  U(       d  g [        U [        5      (       a  U (       d  [        SR                  U 5      5      eU $ )NzEInvalid display name: "{0}". Display name must be a non-empty string.rL   rM   r   rE   )display_namerP   s     r#   validate_display_namerm      @    HlC((f\*, 	, r&   c                     U c  U(       d  g [        U [        5      (       a  U (       d  [        SR                  U 5      5      eU $ )NzCInvalid provider ID: "{0}". Provider ID must be a non-empty string.rk   )provider_idrP   s     r#   validate_provider_idrq      s@    8k3''{f[)+ 	+ r&   c                     U c  U(       d  g [        U [        5      (       a  U (       d  [        SR                  U 5      5      eU $ )NzEInvalid provider UID: "{0}". Provider UID must be a non-empty string.rk   )provider_uidrP   s     r#   validate_provider_uidrt      rn   r&   c                 \   U c  U(       d  g[        U [        5      (       a  U (       d  [        SR                  U 5      5      e [        R
                  " U 5      nUR                  (       d  [        SR                  U 5      5      eU $ ! [         a    [        SR                  U 5      5      ef = f)z*Parses and validates the given URL string.Nz?Invalid photo URL: "{0}". Photo URL must be a non-empty string.zMalformed photo URL: "{0}".)rL   rM   r   rE   r   urlparsenetloc	Exception)	photo_urlrP   parseds      r#   validate_photo_urlr{      s    i%%YfY') 	)J	*}}:AA)LMM J6==iHIIJs   AB %B+c                 B   U c  U(       d  g[        U [        5      (       a  [        S5      e [        U 5      nX0:w  a  [        SR	                  U5      5      eUS::  a  [        SR	                  U5      5      eU$ ! [
         a    [        SR	                  U 5      5      ef = f)zJValidates the given timestamp value. Timestamps must be positive integers.Nz%Boolean value specified as timestamp./{0} must be a numeric value and a whole number.r   z*{0} timestamp must be a positive interger.z&Invalid type for timestamp value: {0}.)rL   boolr   intrE   	TypeError)	timestamprh   rP   timestamp_ints       r#   validate_timestampr      s    )T""@AA	I %NUUV[\]]AIPPQVWXX  UAHHSTTUs   A9 9%Bc                    U b  [        U [        5      (       a  [        SR                  U 5      5      e [	        U 5      nX@:w  a  [        SR                  U5      5      eUb  XB:  a  [        SR                  X5      5      eUb  XC:  a  [        SR                  X5      5      eU$ ! [
         a    [        SR                  U 5      5      ef = f)aa  Validates that the given value represents an integer.

There are several ways to represent an integer in Python (e.g. 2, 2L, 2.0). This method allows
for all such representations except for booleans. Booleans also behave like integers, but
always translate to 1 and 0. Passing a boolean to an API that expects integers is most likely
a developer error.
z$Invalid type for integer value: {0}.r}   z!{0} must not be smaller than {1}.z {0} must not be larger than {1}.)rL   r~   r   rE   r   r   )rg   rh   lowhighval_ints        r#   validate_intr      s     }
5$//?FFuMNNe* NUUV[\]]?w}@GGSTT?FFuSTT  O?FFuMNNOs   B$ $%C	c                 d    [        U [        5      (       d  [        SR                  X5      5      eU $ )z+Validates that the given value is a string.Invalid type for {0}: {1}.rk   rg   rh   s     r#   validate_stringr      s+    eS!!5<<UJKKLr&   c                 d    [        U [        5      (       d  [        SR                  X5      5      eU $ )z,Validates that the given value is a boolean.r   )rL   r~   r   rE   r   s     r#   validate_booleanr      s+    eT""5<<UJKKLr&   c                    U c  U(       d  g[        U 5      n[        U5      [        :  a  [        SR	                  [        5      5      e [
        R                  " U5      n[        U[        5      (       d  [        S5      e[        R                  [        UR                  5       5      5      n[        U5      S:  a4  SR                  [        U5      5      n[        SR	                  U5      5      e[        U5      S:X  a(  [        SR	                  UR!                  5       5      5      eU$ ! [         a    [        S5      ef = f)	zValidates the specified custom claims.

Custom claims must be specified as a JSON string. The string must not exceed 1000
characters, and the parsed JSON payload must not contain reserved JWT claims.
Nz5Custom claims payload must not exceed {0} characters.z-Failed to parse custom claims string as JSON.z1Custom claims must be parseable as a JSON object.rU   , z/Claims "{0}" are reserved, and must not be set.z-Claim "{0}" is reserved, and must not be set.)rM   rN   MAX_CLAIMS_PAYLOAD_SIZEr   rE   jsonloadsrx   rL   dictRESERVED_CLAIMSintersectionsetkeysjoinsortedpop)custom_claimsrP   
claims_strrz   invalid_claimsjoineds         r#   validate_custom_claimsr      s    X]#J
:00CJJ')* 	*JJ' fd##LMM$11#fkkm2DEN
>Q6.12JQQRXYZZ
>a;BB>CUCUCWXZ 	Z  JHIIJs   	D' 'D=c                 v    U [         ;  a.  [        SR                  U SR                  [         5      5      5      eU $ )NzOInvalid action type provided action_type: {0}.             Valid values are {1}r   )VALID_EMAIL_ACTION_TYPESr   rE   r   )action_types    r#   validate_action_typer     s;    22 ""(&dii@X6Y"Z\ 	\r&   c                 f    U (       d  U(       a  [        S5      e/ $ U  H  n[        US5        M     U $ )Nz5Invalid provider IDs. Provider ids should be providedT)r   rq   )provider_idsrP   rp   s      r#   validate_provider_idsr     s3    TUU	#[$/ $r&   c                    / nU R                  5        Ha  u  p#[        U[        5      (       a6  [        U5      nU H#  nUR	                  SR                  X%5      5        M%     MP  UR	                  U5        Mc     [        U5      $ )z6Creates an update mask list from the given dictionary.z{0}.{1})r*   rL   r   build_update_maskappendrE   r   )paramsmaskkeyrg   
child_maskchilds         r#   r   r     sk    Dlln
eT""*51J#I,,S89 $ KK % $<r&   c                   "    \ rS rSrSrSrS rSrg)UidAlreadyExistsErrori$  z.The user with the provided uid already exists.z-The user with the provided uid already existsc                 D    [         R                  R                  XX#5        g r(   r   AlreadyExistsErrorr$   r!   messagecausehttp_responses       r#   r$   UidAlreadyExistsError.__init__)      %%..teSr&   r3   Nr9   r:   r;   r<   r=   default_messager$   r?   r3   r&   r#   r   r   $  s    8EOTr&   r   c                   "    \ rS rSrSrSrS rSrg)EmailAlreadyExistsErrori-  z0The user with the provided email already exists.z/The user with the provided email already existsc                 D    [         R                  R                  XX#5        g r(   r   r   s       r#   r$    EmailAlreadyExistsError.__init__2  r   r&   r3   Nr   r3   r&   r#   r   r   -  s    :GOTr&   r   c                   "    \ rS rSrSrSrS rSrg)InsufficientPermissionErrori6  zEThe credential used to initialize the SDK lacks required permissions.zThe credential used to initialize the SDK has insufficient permissions to perform the requested operation. See https://firebase.google.com/docs/admin/setup for details on how to initialize the Admin SDK with appropriate permissionsc                 D    [         R                  R                  XX#5        g r(   )r   PermissionDeniedErrorr$   r   s       r#   r$   $InsufficientPermissionError.__init__>  s    ((11$Vr&   r3   Nr   r3   r&   r#   r   r   6  s    OYO
Wr&   r   c                   "    \ rS rSrSrSrS rSrg)InvalidDynamicLinkDomainErroriB  z<Dynamic link domain in ActionCodeSettings is not authorized.zEDynamic link domain specified in ActionCodeSettings is not authorizedc                 D    [         R                  R                  XX#5        g r(   r   InvalidArgumentErrorr$   r   s       r#   r$   &InvalidDynamicLinkDomainError.__init__G      ''00Ur&   r3   Nr   r3   r&   r#   r   r   B  s    F]OVr&   r   c                   &    \ rS rSrSrSrSS jrSrg)InvalidIdTokenErroriK  z7The provided ID token is not a valid Firebase ID token.z The provided ID token is invalidNc                 D    [         R                  R                  XX#5        g r(   r   r   s       r#   r$   InvalidIdTokenError.__init__P  r   r&   r3   NNr   r3   r&   r#   r   r   K  s    A8OVr&   r   c                   "    \ rS rSrSrSrS rSrg)PhoneNumberAlreadyExistsErroriT  z7The user with the provided phone number already exists.z6The user with the provided phone number already existsc                 D    [         R                  R                  XX#5        g r(   r   r   s       r#   r$   &PhoneNumberAlreadyExistsError.__init__Y  r   r&   r3   Nr   r3   r&   r#   r   r   T  s    ANOTr&   r   c                   "    \ rS rSrSrSS jrSrg)UnexpectedResponseErrori]  zCBackend service responded with an unexpected or malformed response.Nc                 D    [         R                  R                  XX#5        g r(   )r   UnknownErrorr$   r   s       r#   r$    UnexpectedResponseError.__init__`  s    ((Mr&   r3   r   r9   r:   r;   r<   r=   r$   r?   r3   r&   r#   r   r   ]  s    MNr&   r   c                   &    \ rS rSrSrSrSS jrSrg)UserNotFoundErrorid  z2No user record found for the specified identifier.z-No user record found for the given identifierNc                 D    [         R                  R                  XX#5        g r(   r   NotFoundErrorr$   r   s       r#   r$   UserNotFoundError.__init__i        ))$Nr&   r3   r   r   r3   r&   r#   r   r   d  s    <EOOr&   r   c                   &    \ rS rSrSrSrSS jrSrg)EmailNotFoundErrorim  z-No user record found for the specified email.z(No user record found for the given emailNc                 D    [         R                  R                  XX#5        g r(   r   r   s       r#   r$   EmailNotFoundError.__init__r  r   r&   r3   r   r   r3   r&   r#   r   r   m      7@OOr&   r   c                   &    \ rS rSrSrSrSS jrSrg)TenantNotFoundErroriv  z-No tenant found for the specified identifier.z(No tenant found for the given identifierNc                 D    [         R                  R                  XX#5        g r(   r   r   s       r#   r$   TenantNotFoundError.__init__{  r   r&   r3   r   r   r3   r&   r#   r   r   v  r   r&   r   c                       \ rS rSrSrS rSrg)TenantIdMismatchErrori  z4Missing or invalid tenant ID field in the given JWT.c                 B    [         R                  R                  X5        g r(   r   )r!   r   s     r#   r$   TenantIdMismatchError.__init__  s    ''00?r&   r3   Nr   r3   r&   r#   r   r     s    >@r&   r   c                   &    \ rS rSrSrSrSS jrSrg)ConfigurationNotFoundErrori  z4No auth provider found for the specified identifier.z/No auth provider found for the given identifierNc                 D    [         R                  R                  XX#5        g r(   r   r   s       r#   r$   #ConfigurationNotFoundError.__init__  r   r&   r3   r   r   r3   r&   r#   r   r     s    >GOOr&   r   c                   &    \ rS rSrSrSrSS jrSrg)UserDisabledErrori  z8An operation failed due to a user record being disabled.zThe user record is disabledNc                 D    [         R                  R                  XX#5        g r(   r   r   s       r#   r$   UserDisabledError.__init__  r   r&   r3   r   r   r3   r&   r#   r   r     s    B3OVr&   r   c                   "    \ rS rSrSrSS jrSrg)TooManyAttemptsTryLaterErrori  z*Rate limited because of too many attempts.Nc                 D    [         R                  R                  XX#5        g r(   r   ResourceExhaustedErrorr$   r   s       r#   r$   %TooManyAttemptsTryLaterError.__init__      ))224%Wr&   r3   r   r   r3   r&   r#   r   r     s    4Xr&   r   c                   "    \ rS rSrSrSS jrSrg)ResetPasswordExceedLimitErrori  z,Reset password emails exceeded their limits.Nc                 D    [         R                  R                  XX#5        g r(   r   r   s       r#   r$   &ResetPasswordExceedLimitError.__init__  r   r&   r3   r   r   r3   r&   r#   r   r     s    6Xr&   r   )CONFIGURATION_NOT_FOUNDDUPLICATE_EMAILDUPLICATE_LOCAL_IDEMAIL_EXISTSEMAIL_NOT_FOUNDINSUFFICIENT_PERMISSIONINVALID_DYNAMIC_LINK_DOMAININVALID_ID_TOKENPHONE_NUMBER_EXISTSTENANT_NOT_FOUNDUSER_NOT_FOUNDTOO_MANY_ATTEMPTS_TRY_LATERRESET_PASSWORD_EXCEED_LIMITc                    U R                   c  [        R                  " U 5      $ [        U R                   5      u  pU(       dG  SR	                  U R                   R
                  R                  5       5      n[        R                  " XS9$ [        R                  U5      n[        XU5      nU(       d  [        R                  " XS9$ U" X0U R                   S9$ )zWConverts a requests error received from the Firebase Auth service into a FirebaseError.zUnexpected error response: {0})r   )r   r   )
responser   handle_requests_error_parse_error_bodyrE   contentdecode_CODE_TO_EXC_TYPEget_build_error_message)errorcodecustom_messagemsgexc_types        r#   handle_auth_backend_errorr    s    ~~++E22,U^^<D.55enn6L6L6S6S6UV++E?? $$T*H
t~
>C++E??CENNCCr&   c                 `   0 n U R                  5       n[        U[        5      (       a  UR                  S0 5      n[        U[        5      (       a  UR                  S5      OSnSnU(       a1  UR                  S5      nUS:w  a  X5S-   S R                  5       nUSU nX44$ ! [         a     Nqf = f)zGParses the given error response to extract Auth error code and message.r  r   N:rU   )r   rL   r   r  r   findstrip)r  
error_dictparsed_bodyr  r  	separators         r#   r  r    s    Jmmok4(($"5J
 )3:t(D(D:>>)$$DNIIcN	?!a-.1779N
#D  s   7B   
B-,B-c                     U(       a  [        US5      (       a  UR                  OSnU(       a  SR                  U5      OSnSR                  X0U5      $ )Nr   z Error while calling Auth servicez {0}rA   z{0} ({1}).{2})hasattrr   rE   )r  r  r  r   exts        r#   r  r    sJ    WX'899 ..@b +9&--
'rC!!/==r&   )F)Tr   );r=   r   rB   r]   urllibr   firebase_adminr   r   rD   r   r   r   r   r   rG   rI   rQ   rY   r`   rd   ri   rm   rq   rt   r{   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r  r3   r&   r#   <module>r,     s     	 	  % ! 6     QR #" #"L%	"J "0:TJ99 TTj;; T	W*"B"B 	WVJ$C$C VV*99 VTJ$A$A TNj55 NO
00 OO11 OO*22 O@J;; @O!9!9 OV
77 VX:#D#D XXJ$E$E X  :./+):#@+8+'#?#@ "D$ ,>r&   