§
    ÎÐj)  ã                   óL   — d Z ddlZddlZddlZddlmZ d„ Zd„ Zd„ Zddœd	„Z	dS )
z@Shared launch options for web authentication, MCP OAuth and TLS.é    N)Úurlsplitc                 óä  ‡ — ddl m} 	 t          ‰ ¦  «        }|j        dvsR|j        rK|j        €D|j        €=|j        dvs4t          d„ ‰ D ¦   «         ¦  «        st          ˆ fd„dD ¦   «         ¦  «        rt          ¦   «         ‚ |‰ ¦  «        }d|j
        cxk    rd	k    sn t          ¦   «         ‚t          |¦  «                             d
¦  «        S # t          $ r}t          d¦  «        |‚d }~ww xY w)Nr   )Ú
AnyHttpUrl>   ÚhttpÚhttps>   Ú ú/c              3   ód   K  — | ]+}|                      ¦   «         pt          |¦  «        d k     V — Œ,dS )é    N)ÚisspaceÚord)Ú.0Úchars     úFC:\Users\johnn\OneDrive\Documents\AI\shared\authentication\__init__.pyú	<genexpr>z#parse_public_url.<locals>.<genexpr>   s9   è è € ÐJÐJ¸D�t—|’|‘~”~Ð7­¨T©¬°RªÐJÐJÐJÐJÐJÐJó    c              3   ó    •K  — | ]}|‰v V — Œ	d S )N© )r   r   Úvalues     €r   r   z#parse_public_url.<locals>.<genexpr>   s'   øè è € ÐGÐG¨�t˜u�}ÐGÐGÐGÐGÐGÐGr   )Ú?ú#ú\Ú*é   iÿÿ  r	   zw--public-url must be an HTTP(S) origin, e.g. https://wangp.example.com, without a path, query, fragment or credentials.)Úpydanticr   r   ÚschemeÚhostnameÚusernameÚpasswordÚpathÚanyÚ
ValueErrorÚportÚstrÚrstrip)r   r   ÚparsedÚurlÚerrors   `    r   Úparse_public_urlr)   	   s@  ø€ Ø#Ð#Ð#Ð#Ð#Ð#ð_Ý˜%‘”ˆØŒMÐ!2Ð2Ð2¸&¼/Ð2ÈVÌ_ÐMhØ”?Ð.°&´+ÀYÐ2NÐ2NÝÐJÐJÀEÐJÑJÔJÑJÔJð 3OåÐGÐGÐGÐGÐ1FÐGÑGÔGÑGÔGð 3Oõ ‘,”,ÐØˆj˜ÑÔˆØ�C”HÐ%Ð%Ò%Ð% Ò%Ð%Ð%Ð%Ý‘,”,ÐÝ�3‰xŒx�Š˜sÑ#Ô#Ð#øÝð _ð _ð _Ýð  Sñ  Tô  Tð  Z_ð  	_øøøøð_øøøs   ‰CC Ã
C/ÃC*Ã*C/c                 ó˜  — | j         }|                      ¦   «         }|                      ddd¬¦  «         |                      dddd¬	¦  «          |d
d d¬¦  «          |dt          d dd¬¦  «          |ddd¬¦  «          |dd d¬¦  «          |dd d¬¦  «          |dt          d d¬¦  «          |dd d¬¦  «          |dd d¬¦  «         d S )Nú--authÚ
store_truez6Require a password for all Gradio and Deepy web access)ÚactionÚhelpz	--no-authÚstore_falseÚauthz$Disable web authentication (default))r-   Údestr.   z--auth-passwordzWWeb passphrase (requires --auth; otherwise WANGP_AUTH_PASSWORD or a generated password))Údefaultr.   z--public-urlÚORIGINzsRestrict browser requests to this exact origin and handle proxies that rewrite Host, e.g. https://wangp.example.com)Útyper2   Úmetavarr.   ú
--mcp-authz+Require OAuth authorization for network MCPz--mcp-auth-passwordzqSeparate MCP approval passphrase (requires --mcp-auth; otherwise WANGP_MCP_AUTH_PASSWORD or a generated password)z--mcp-auth-urlzSPublic MCP server origin, e.g. https://wangp.example.com:7866 (requires --mcp-auth)z--https-portzAServe HTTPS on this port and redirect the main HTTP port to HTTPS)r4   r2   r.   z--ssl-certfilez3TLS certificate PEM file (otherwise WANGP_SSL_CERT)z--ssl-keyfilez2TLS private key PEM file (otherwise WANGP_SSL_KEY))Úadd_argumentÚadd_mutually_exclusive_groupr)   Úint)ÚparserÚaddr0   s      r   Úadd_argumentsr<      sc  € Ø
Ô
€CØ×.Ò.Ñ0Ô0€DØ×Ò�h |Ð:rÐÑsÔsÐsØ×Ò�k¨-¸fÐKqÐÑrÔrÐrØ€CÐ 4ð  /Hð  Iñ  Iô  Ið  IØ€CˆÕ-°tÀXð  UJð  Kñ  Kô  Kð  KØ€Cˆ˜\Ð0]Ð^Ñ^Ô^Ð^Ø€CÐ tð  3fð  gñ  gô  gð  gØ€CÐ $ð  .Cð  Dñ  Dô  Dð  DØ€Cˆ�S¨$Ð5xÐyÑyÔyÐyØ€CÐ $Ð-bÐcÑcÔcÐcØ€Cˆ Ð,`ÐaÑaÔaÐaÐaÐar   c                 ó†   — t          j        d¬¦  «        }t          |¦  «         |                     | j        | ¬¦  «         | S )NF)Úadd_help)Ú	namespace)ÚargparseÚArgumentParserr<   Úparse_known_argsÚcli_arg)Úargsr:   s     r   Úforwarded_optionsrE   *   sE   € õ Ô$¨eÐ4Ñ4Ô4€FÝ�&ÑÔÐØ
×Ò˜DœL°DÐÑ9Ô9Ð9Ø€Kr   F)Úmcpc                ó²  — |r| j         n| j        }|r| j        n| j        }|rdnd}|�|st	          |› d|› d�¦  «        ‚|sd S |�|nt          j        |rdnd¦  «        }|€,t          j        d¦  «        }t          |rdnd	› d
|› �¦  «         | 
                    ¦   «         r&t          |                     d¦  «        ¦  «        dk    rt	          d¦  «        ‚|S )Nr6   r+   z-password requires ú.ÚWANGP_MCP_AUTH_PASSWORDÚWANGP_AUTH_PASSWORDé   zMCP approvalz	WanGP webz password: zutf-8i   z>The passphrase must be non-empty and at most 1024 UTF-8 bytes.)Úmcp_authr0   Úmcp_auth_passwordÚauth_passwordr"   ÚosÚgetenvÚsecretsÚtoken_urlsafeÚprintÚstripÚlenÚencode)rD   rF   ÚenabledÚsuppliedÚflagr   s         r   r   r   3   s  € Ø"Ð1ˆdŒmˆm¨¬	€GØ),ÐDˆtÔ%Ð%°$Ô2D€HØÐ,ˆ<ˆ< H€DØÐ GÐÝ˜DÐ<Ð<°TÐ<Ð<Ð<Ñ=Ô=Ð=Øð ØˆtØ Ð,ˆHˆHµ"´)ÐY\Ð<wÐ<UÐ<UÐbwÑ2xÔ2x€EØ€}ÝÔ% bÑ)Ô)ˆÝ 3Ð7��¨KÐKÐKÀEÐKÐKÑLÔLÐLØ�;Š;‰=Œ=ð [�C §¢¨WÑ 5Ô 5Ñ6Ô6¸Ò=Ð=ÝÐYÑZÔZÐZØ€Lr   )
Ú__doc__r@   rO   rQ   Úurllib.parser   r)   r<   rE   r   r   r   r   ú<module>r\      s“   ðà FÐ FØ €€€Ø 	€	€	€	Ø €€€Ø !Ð !Ð !Ð !Ð !Ð !ð_ð _ð _ð$bð bð bðð ð ð  ð ð ð ð ð ð ð r   