
    (ph
                         S SK r S SKrS SKrS SKrS SKJr  S SKJrJr   " S S\ R                  5      r
 " S S\
5      rg)    N)
exceptions)
GetRequestGetResponsec                   p    \ rS rSr\R
                  S\4S j5       r\R
                  S\S\	4S j5       r
Srg)WebAuthnHandler
   returnc                     [        S5      e)z0Check whether this WebAuthn handler is availablez'is_available method must be implementedNotImplementedErrorselfs    Q/var/www/html/venv/lib/python3.13/site-packages/google/oauth2/webauthn_handler.pyis_availableWebAuthnHandler.is_available   s     ""KLL    get_requestc                     [        S5      e)zWebAuthn get (assertion)zget method must be implementedr   )r   r   s     r   getWebAuthnHandler.get   s     ""BCCr    N)__name__
__module____qualname____firstlineno__abcabstractmethodboolr   r   r   r   __static_attributes__r   r   r   r   r   
   sP    Md M M 	Dz Dk D Dr   r   c                   `    \ rS rSrSrSrS\4S jrS\S\	4S jr
S\S	\S\4S
 jrS\4S jrSrg)PluginHandler   a  Offloads WebAuthn get reqeust to a pluggable command-line tool.

Offloads WebAuthn get to a plugin which takes the form of a
command-line tool. The command-line tool is configurable via the
PluginHandler._ENV_VAR environment variable.

The WebAuthn plugin should implement the following interface:

Communication occurs over stdin/stdout, and messages are both sent and
received in the form:

[4 bytes - payload size (little-endian)][variable bytes - json payload]
GOOGLE_AUTH_WEBAUTHN_PLUGINr	   c                 F     U R                  5         g! [         a     gf = f)NTF)_find_plugin	Exceptionr   s    r   r   PluginHandler.is_available'   s,    	   		s    
  r   c                     UR                  5       nU R                  5       nU R                  X25      n[        R                  " U5      $ )N)to_jsonr%   _call_pluginr   	from_json)r   r   request_jsoncmdresponse_jsons        r   r   PluginHandler.get/   s?    "**,!))#<$$]33r   r-   
input_jsonc                    [        U5      n[        R                  " SU5      nXBR                  5       -   n[        R
                  " U/USSS9nUR                  S S n[        R                  " SU5      S   nUR                  SS  n	U[        U	5      :w  a/  [        R                  " SR                  U[        U	5      5      5      eU	R                  5       $ )Nz<IT)inputcapture_outputcheck   r   z0Plugin response length {} does not match data {})lenstructpackencode
subprocessrunstdoutunpackr   MalformedErrorformatdecode)
r   r-   r0   input_lengthlength_bytes_lerequestprocess_resultresponse_len_leresponse_lenresponses
             r   r*   PluginHandler._call_plugin5   s    : ++dL9!$5$5$77 $ET

 )//3}}T?;A>!((,3x=(++BII #h- 
   r   c                     [         R                  R                  [        R                  5      nUc3  [
        R                  " SR                  [        R                  5      5      eU$ )Nz{} env var is not set)osenvironr   r!   _ENV_VARr   InvalidResourcer?   )r   
plugin_cmds     r   r%   PluginHandler._find_pluginL   sO    ZZ^^M$:$:;
,,'..}/E/EF  r   r   N)r   r   r   r   __doc__rL   r   r   r   r   r   strr*   r%   r   r   r   r   r!   r!      sS     -Hd 4z 4k 4! ! ! !.c r   r!   )r   rJ   r7   r:   google.authr   google.oauth2.webauthn_typesr   r   ABCr   r!   r   r   r   <module>rU      s5    
 	   " @	Dcgg 	D<O <r   