
    afJ                     0   d dl Z d dlmZmZmZmZmZmZmZ d dl	m
Z
 d dlmZmZmZmZmZmZmZmZmZmZmZ d dlmZmZ dZe
 G d de j                              Ze
 G d	 d
e j                              Ze
 G d de j                              Ze                    e           e
 G d de j                              Z e
 G d de j                              Z! G d de j                  Z"e
 G d de"                      Z# G d de j                  Z$e
 G d de j                              Z%e
 G d de%                      Z&e
 G d de%                      Z'e
 G d de j                              Z(e
 G d d e j                              Z)dS )!    N)UnionDictAnyOptionalListTupleCallable)public)	ChallengeSessionDetailsCloseDetails
CallResultRegisterOptionsSubscribeOptionsRegistrationSubscriptionPublicationComponentConfigTransportDetails)MessageWelcome)IObjectSerializerISerializerIMessage
ITransportITransportHandlerISessionIAuthenticatorIKeyICryptosignKeyIEthereumKeyISecurityModuleIPayloadCodecc                      e Zd ZdZeeej        defd                                    Z	eeej        de
fd                                    Zeej        dedefd                        Zeej        dedee         fd                        Zd	S )
r   z
    Raw Python object serialization and deserialization. Object serializers are
    used by classes implementing WAMP serializers, that is instances of
    :class:`autobahn.wamp.interfaces.ISerializer`.
    returnc                     dS )z5
        Object serializer name (read-only).
        N selfs    J/var/www/html/env/lib/python3.11/site-packages/autobahn/wamp/interfaces.pyNAMEzIObjectSerializer.NAME>             c                     dS )z
        Flag (read-only) to indicate if serializer requires a binary clean
        transport or if UTF8 transparency is sufficient.
        Nr'   r(   s    r*   BINARYzIObjectSerializer.BINARYF   r,   r-   objc                     dS )z
        Serialize an object to a byte string.

        :param obj: Object (any serializable type) to serialize.

        :returns: Serialized bytes.
        Nr'   )r)   r0   s     r*   	serializezIObjectSerializer.serializeO   r,   r-   payloadc                     dS )z
        Deserialize objects from a byte string.

        :param payload: Objects to deserialize.

        :returns: List of deserialized (raw) objects.
        Nr'   )r)   r3   s     r*   unserializezIObjectSerializer.unserializeZ   r,   r-   N)__name__
__module____qualname____doc__r
   propertyabcabstractmethodstrr+   boolr/   r   bytesr2   r   r5   r'   r-   r*   r   r   6   s         c     X V
      X V S U     V 5 T#Y     V  r-   r   c            
          e Zd ZdZeeej        dee	df         fd                                    Z
eeej        defd                                    Zeeej        de	fd                                    Zeeej        defd                                    Zeej        dddeeef         fd	                        Zeej        ddedee         ded         fd                        Zd
S )r   z9
    WAMP message serialization and deserialization.
    r%   r   c                     dS )zM
        Mapping of WAMP message type codes to WAMP message classes.
        Nr'   r(   s    r*   MESSAGE_TYPE_MAPzISerializer.MESSAGE_TYPE_MAPl   r,   r-   c                     dS )z{
        The WAMP serialization format ID as used for WebSocket, e.g. ``"json"`` (or ``"json.batched"``) for JSON.
        Nr'   r(   s    r*   SERIALIZER_IDzISerializer.SERIALIZER_IDt   r,   r-   c                     dS )z^
        The WAMP serialization format ID as used for RawSocket, e.g. ``1`` for JSON.
        Nr'   r(   s    r*   RAWSOCKET_SERIALIZER_IDz#ISerializer.RAWSOCKET_SERIALIZER_ID|   r,   r-   c                     dS )z`
        The WAMP serialization format MIME type, e.g. ``"application/json"`` for JSON.
        Nr'   r(   s    r*   	MIME_TYPEzISerializer.MIME_TYPE   r,   r-   messagec                     dS )z
        Serializes a WAMP message to bytes for sending over a WAMP transport.

        :param message: The WAMP message to be serialized.

        :returns: A pair ``(payload, is_binary)``.
        Nr'   r)   rI   s     r*   r2   zISerializer.serialize   r,   r-   Nr3   	is_binaryc                     dS )a8  
        Deserialize bytes from a transport and parse into WAMP messages.

        :param payload: Byte string from wire.

        :param is_binary: Type of payload. True if payload is a binary string, else
            the payload is UTF-8 encoded Unicode text.

        :returns: List of WAMP messages.
        Nr'   )r)   r3   rL   s      r*   r5   zISerializer.unserialize   r,   r-   N)r6   r7   r8   r9   r
   r:   r;   r<   r   intrB   r=   rD   rF   rH   r   r?   r>   r2   r   r   r5   r'   r-   r*   r   r   f   s         $sJ"7     X V
 s     X V
      X V
 3     X V
  eTk0B     V 
 
5 
Xd^ 
tT^O_ 
 
 
  V
 
 
r-   r   c                      e Zd ZdZeeej        defd                                    Z	ee
ej        d	d                                    Zeej        dedefd                        Zeej        d                         ZdS )
r   z
    A WAMP message, e.g. one of the messages defined in the WAMP specification
    `here <https://wamp-proto.org/_static/gen/wamp_latest_ietf.html#rfc.section.6.5>`_.
    r%   c                     dS )z)
        WAMP message type code.
        Nr'   r(   s    r*   MESSAGE_TYPEzIMessage.MESSAGE_TYPE   r,   r-   c                     dS )z
        Factory method that parses a unserialized raw message (as returned byte
        :func:`autobahn.interfaces.ISerializer.unserialize`) into an instance
        of this class.

        :returns: The parsed WAMP message.
        Nr'   )wmsgs    r*   parsezIMessage.parse   r,   r-   
serializerc                     dS )aP  
        Serialize this object into a wire level bytes representation and cache
        the resulting bytes. If the cache already contains an entry for the given
        serializer, return the cached representation directly.

        :param serializer: The wire level serializer to use.

        :returns: The serialized bytes.
        Nr'   )r)   rV   s     r*   r2   zIMessage.serialize   r,   r-   c                     dS )zB
        Resets the serialization cache for this message.
        Nr'   r(   s    r*   uncachezIMessage.uncache   r,   r-   N)r%   r   )r6   r7   r8   r9   r
   r:   r;   r<   rO   rR   staticmethodrU   r   r?   r2   rY   r'   r-   r*   r   r      s         
 c     X V     \ V 	K 	E 	 	 	  V	    V  r-   r   c                   0   e Zd ZdZeej        defd                        Zeej        de	fd                        Z
eeej        dee         fd                                    Zeej        d                         Zeej        d                         Zd	S )
r   zi
    A WAMP transport is a bidirectional, full-duplex, reliable, ordered,
    message-based channel.
    rI   c                     dS )a  
        Send a WAMP message over the transport to the peer. If the transport is
        not open, this raises :class:`autobahn.wamp.exception.TransportLost`.
        Returns a deferred/future when the message has been processed and more
        messages may be sent. When send() is called while a previous deferred/future
        has not yet fired, the send will fail immediately.

        :param message: The WAMP message to send over the transport.
        Nr'   rK   s     r*   sendzITransport.send   r,   r-   r%   c                     dS )zv
        Check if the transport is open for messaging.

        :returns: ``True``, if the transport is open.
        Nr'   r(   s    r*   isOpenzITransport.isOpen   r,   r-   c                     dS )zR
        Return details about the transport (when the transport is open).
        Nr'   r(   s    r*   transport_detailszITransport.transport_details   r,   r-   c                     dS )z
        Close the transport regularly. The transport will perform any
        closing handshake if applicable. This should be used for any
        application initiated closing.
        Nr'   r(   s    r*   closezITransport.close   r,   r-   c                     dS )a  
        Abort the transport abruptly. The transport will be destroyed as
        fast as possible, and without playing nice to the peer. This should
        only be used in case of fatal errors, protocol violations or possible
        detected attacks.
        Nr'   r(   s    r*   abortzITransport.abort	  r,   r-   N)r6   r7   r8   r9   r
   r;   r<   r   r]   r>   r_   r:   r   r   ra   rc   re   r'   r-   r*   r   r      s        
 	H 	 	 	  V	      V 8,<#=     X V
    V    V  r-   r   c                       e Zd Zeej        defd                        Zeej        defd                        Z	eej        de
fd                        ZdS )r   	transportc                     dS )a	  
        Callback fired when transport is open. May run asynchronously. The transport
        is considered running and is_open() would return true, as soon as this callback
        has completed successfully.

        :param transport: The WAMP transport.
        Nr'   )r)   rg   s     r*   onOpenzITransportHandler.onOpen  r,   r-   rI   c                     dS )a_  
        Callback fired when a WAMP message was received. May run asynchronously. The callback
        should return or fire the returned deferred/future when it's done processing the message.
        In particular, an implementation of this callback must not access the message afterwards.

        :param message: The WAMP message received.
        Nr'   rK   s     r*   	onMessagezITransportHandler.onMessage"  r,   r-   wasCleanc                     dS )z
        Callback fired when the transport has been closed.

        :param wasClean: Indicates if the transport has been closed regularly.
        Nr'   )r)   rl   s     r*   onClosezITransportHandler.onClose-  r,   r-   N)r6   r7   r8   r
   r;   r<   r   ri   r   rk   r>   rn   r'   r-   r*   r   r     s         
     V      V      V  r-   r   c                   &    e Zd Zej        j        ZdS )_ABCN)r6   r7   r8   r;   ABCregisterabc_registerr'   r-   r*   rp   rp   8  s        7#LLLr-   rp   c                      e Zd ZdZeeej        defd                                    Z	eeej        de
e         fd                                    Zeeej        de
e         fd                                    Zeej        d                         Zeej        d                         Zeej        	 	 	 	 	 	 	 d2d	ed
e
ee                  de
e         de
e         de
eeef                  de
e         de
e         de
e         fd                        Zeej        dedefd                        Zeej        dede
e         fd                        Zeej        defd                        Zeej        d3de
e         de
e         fd                        Zeej        defd                        Zeej        d                         Z eej        d                         Z!eej        defd                        Z"eej        defd                        Z#eej        d e
d!         fd"                        Z$eej        de
d!         fd#                        Z%eej        d4d$e&d%e
e         fd&                        Z'eej        d'ede(ee)f         fd(                        Z*eej        	 	 	 d5d)e(e+ef         d'e
e         d*e
e,         d+e
e         d,e
e         de(e-ee-         f         fd-                        Z.eej        d.ede
e/         fd/                        Z0eej        	 	 d6d0e(e+ef         d.e
e         d*e
e1         d,e
e         de(e2ee2         f         f
d1                        Z3dS )7r   z&
    Interface for WAMP sessions.
    r%   c                     dS )z,
        Configuration for session.
        Nr'   r(   s    r*   configzISession.configB  r,   r-   c                     dS )z
        When the transport this session is attached to is currently open, this property
        can be read from. The property should be considered read-only. When the transport
        is gone, this property is set to None.
        Nr'   r(   s    r*   rg   zISession.transportJ  r,   r-   c                     dS )z
        Return details about the session, the same as initially provided to the
        :meth:`ISession.onJoin` callback on an implementation.
        Nr'   r(   s    r*   session_detailszISession.session_detailsT  r,   r-   c                     dS )a  
        This is called when we try to fire a callback, but get an
        exception from user code -- for example, a registered publish
        callback or a registered method. By default, this prints the
        current stack-trace and then error-message to stdout.

        ApplicationSession-derived objects may override this to
        provide logging if they prefer. The Twisted implemention does
        this. (See :class:`autobahn.twisted.wamp.ApplicationSession`)

        :param fail: The failure that occurred.
        :type fail: instance implementing txaio.IFailedFuture

        :param msg: an informative message from the library. It is
            suggested you log this immediately after the exception.
        :type msg: str
        Nr'   )r)   failmsgs      r*   onUserErrorzISession.onUserError]  r,   r-   c                     dS )zd
        Callback fired when the transport this session will run over has been established.
        Nr'   r(   s    r*   	onConnectzISession.onConnectr  r,   r-   Nrealmauthmethodsauthidauthrole	authextra	resumableresume_sessionresume_tokenc	                     dS )zp
        Attach the session to the given realm. A session is open as soon as it is attached to a realm.
        Nr'   )	r)   r   r   r   r   r   r   r   r   s	            r*   joinzISession.joiny  r,   r-   	challengec                     dS )z
        Callback fired when the peer demands authentication.

        May return a Deferred/Future.

        :param challenge: The authentication challenge.
        Nr'   )r)   r   s     r*   onChallengezISession.onChallenge  r,   r-   welcomec                     dS )a  
        Callback fired after the peer has successfully authenticated. If
        this returns anything other than None/False, the session is
        aborted and the return value is used as an error message.

        May return a Deferred/Future.

        .. note::
            Before we let user code see the session -- that is, before we fire "join"
            we give authentication instances a chance to abort the session. Usually
            this would be for "mutual authentication" scenarios. For example, WAMP-SCRAM
            uses this to confirm the server-signature.

        :param welcome: The WELCOME message received from the server

        :return: None, or an error message (using a fixed error URI
            ``wamp.error.cannot_authenticate``).
        Nr'   )r)   r   s     r*   	onWelcomezISession.onWelcome  r,   r-   detailsc                     dS )z
        Callback fired when WAMP session has been established.

        May return a Deferred/Future.

        :param details: Session information.
        Nr'   r)   r   s     r*   onJoinzISession.onJoin  r,   r-   reasonrI   c                     dS )a  
        Actively close this WAMP session.

        :param reason: An optional URI for the closing reason. If you
            want to permanently log out, this should be ``wamp.close.logout``.

        :param message: An optional (human-readable) closing message, intended for
            logging purposes.

        :return: may return a Future/Deferred that fires when we've disconnected
        Nr'   )r)   r   rI   s      r*   leavezISession.leave  r,   r-   c                     dS )zx
        Callback fired when WAMP session has is closed

        :param details: Close information for session.
        Nr'   r   s     r*   onLeavezISession.onLeave  r,   r-   c                     dS )z1
        Close the underlying transport.
        Nr'   r(   s    r*   
disconnectzISession.disconnect  r,   r-   c                     dS )zK
        Callback fired when underlying transport has been closed.
        Nr'   r(   s    r*   onDisconnectzISession.onDisconnect  r,   r-   c                     dS )zA
        Check if the underlying transport is connected.
        Nr'   r(   s    r*   is_connectedzISession.is_connected  r,   r-   c                     dS )zD
        Check if the session has currently joined a realm.
        Nr'   r(   s    r*   is_attachedzISession.is_attached  r,   r-   payload_codecr#   c                     dS )aD  
        Set a payload codec on the session. To remove a previously set payload codec,
        set the codec to ``None``.

        Payload codecs are used with WAMP payload transparency mode.

        :param payload_codec: The payload codec that should process application
            payload of the given encoding.
        Nr'   )r)   r   s     r*   set_payload_codeczISession.set_payload_codec  r,   r-   c                     dS )z
        Get the current payload codec (if any) for the session.

        Payload codecs are used with WAMP payload transparency mode.

        :returns: The current payload codec or ``None`` if no codec is active.
        Nr'   r(   s    r*   get_payload_codeczISession.get_payload_codec  r,   r-   	exceptionerrorc                     dS )aR  
        Defines an exception for a WAMP error in the context of this WAMP session.

        :param exception: The exception class to define an error mapping for.

        :param error: The URI (or URI pattern) the exception class should be mapped for.
            Iff the ``exception`` class is decorated, this must be ``None``.
        Nr'   )r)   r   r   s      r*   definezISession.define   r,   r-   	procedurec                     dS )a  
        Call a remote procedure.

        This will return a Deferred/Future, that when resolved, provides the actual result
        returned by the called remote procedure.

        - If the result is a single positional return value, it'll be returned "as-is".

        - If the result contains multiple positional return values or keyword return values,
          the result is wrapped in an instance of :class:`autobahn.wamp.types.CallResult`.

        - If the call fails, the returned Deferred/Future will be rejected with an instance
          of :class:`autobahn.wamp.exception.ApplicationError`.

        If ``kwargs`` contains an ``options`` keyword argument that is an instance of
        :class:`autobahn.wamp.types.CallOptions`, this will provide specific options for
        the call to perform.

        When the *Caller* and *Dealer* implementations support canceling of calls, the call may
        be canceled by canceling the returned Deferred/Future.

        :param procedure: The URI of the remote procedure to be called, e.g. ``"com.myapp.hello"``.

        :param args: Any positional arguments for the call.

        :param kwargs: Any keyword arguments for the call.

        :returns: A Deferred/Future for the call result.
        Nr'   )r)   r   argskwargss       r*   callzISession.call  r,   r-   endpointoptionsprefixcheck_typesc                     dS )a
	  
        Register a procedure for remote calling.

        When ``endpoint`` is a callable (function, method or object that implements ``__call__``),
        then ``procedure`` must be provided and an instance of
        :tx:`twisted.internet.defer.Deferred` (when running on **Twisted**) or an instance
        of :py:class:`asyncio.Future` (when running on **asyncio**) is returned.

        - If the registration *succeeds* the returned Deferred/Future will *resolve* to
          an object that implements :class:`autobahn.wamp.interfaces.IRegistration`.

        - If the registration *fails* the returned Deferred/Future will *reject* with an
          instance of :class:`autobahn.wamp.exception.ApplicationError`.

        When ``endpoint`` is an object, then each of the object's methods that is decorated
        with :func:`autobahn.wamp.register` is automatically registered and a (single)
        DeferredList or Future is returned that gathers all individual underlying Deferreds/Futures.

        :param endpoint: The endpoint called under the procedure.

        :param procedure: When ``endpoint`` is a callable, the URI (or URI pattern)
           of the procedure to register for. When ``endpoint`` is an object,
           the argument is ignored (and should be ``None``).

        :param options: Options for registering.

        :param prefix: if not None, this specifies a prefix to prepend
            to all URIs registered for this class. So if there was an
            @wamp.register('method_foo') on a method and
            prefix='com.something.' then a method
            'com.something.method_foo' would ultimately be registered.

        :param check_types: Enable automatic type checking against (Python 3.5+) type hints
            specified on the ``endpoint`` callable. Types are checked at run-time on each
            invocation of the ``endpoint`` callable. When a type mismatch occurs, the error
            is forwarded to the callee code in ``onUserError`` override method of
            :class:`autobahn.wamp.protocol.ApplicationSession`. An error
            of type :class:`autobahn.wamp.exception.TypeCheckError` is also raised and
            returned to the caller (via the router).

        :returns: A registration or a list of registrations (or errors)
        Nr'   )r)   r   r   r   r   r   s         r*   rr   zISession.register-  r,   r-   topicc                     dS )a  
        Publish an event to a topic.

        If ``kwargs`` contains an ``options`` keyword argument that is an instance of
        :class:`autobahn.wamp.types.PublishOptions`, this will provide
        specific options for the publish to perform.

        .. note::
           By default, publications are non-acknowledged and the publication can
           fail silently, e.g. because the session is not authorized to publish
           to the topic.

        When publication acknowledgement is requested via ``options.acknowledge == True``,
        this function returns a Deferred/Future:

        - If the publication succeeds the Deferred/Future will resolve to an object
          that implements :class:`autobahn.wamp.interfaces.IPublication`.

        - If the publication fails the Deferred/Future will reject with an instance
          of :class:`autobahn.wamp.exception.ApplicationError`.

        :param topic: The URI of the topic to publish to, e.g. ``"com.myapp.mytopic1"``.

        :param args: Arbitrary application payload for the event (positional arguments).

        :param kwargs: Arbitrary application payload for the event (keyword arguments).

        :returns: Acknowledgement for acknowledge publications - otherwise nothing.
        Nr'   )r)   r   r   r   s       r*   publishzISession.publish]  r,   r-   handlerc                     dS )a  
        Subscribe to a topic for receiving events.

        When ``handler`` is a callable (function, method or object that implements ``__call__``),
        then `topic` must be provided and an instance of
        :tx:`twisted.internet.defer.Deferred` (when running on **Twisted**) or an instance
        of :class:`asyncio.Future` (when running on **asyncio**) is returned.

        - If the subscription succeeds the Deferred/Future will resolve to an object
          that implements :class:`autobahn.wamp.interfaces.ISubscription`.

        - If the subscription fails the Deferred/Future will reject with an instance
          of :class:`autobahn.wamp.exception.ApplicationError`.

        When ``handler`` is an object, then each of the object's methods that is decorated
        with :func:`autobahn.wamp.subscribe` is automatically subscribed as event handlers,
        and a list of Deferreds/Futures is returned that each resolves or rejects as above.

        :param handler: The event handler to receive events.

        :param topic: When ``handler`` is a callable, the URI (or URI pattern)
           of the topic to subscribe to. When ``handler`` is an object, this
           value is ignored (and should be ``None``).

        :param options: Options for subscribing.

        :param check_types: Enable automatic type checking against (Python 3.5+) type hints
            specified on the ``endpoint`` callable. Types are checked at run-time on each
            invocation of the ``endpoint`` callable. When a type mismatch occurs, the error
            is forwarded to the subscriber code in ``onUserError`` override method of
            :class:`autobahn.wamp.protocol.ApplicationSession`.

        :returns: A single Deferred/Future or a list of such objects
        Nr'   )r)   r   r   r   r   s        r*   	subscribezISession.subscribe~  r,   r-   )NNNNNNNNNrN   )NNNN)NNN)4r6   r7   r8   r9   r
   r:   r;   r<   r   rv   r   r   rg   r   ry   r}   r   r=   r   r   r   r>   rO   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   	Exceptionr   r   r   r   r	   r   r   rr   r   r   r   r   r   r'   r-   r*   r   r   <  s<              X V
 8J/     X V .!9     X V    V&    V
  15%)'+37)--1+/ "49- c]  }	
 !c3h0 ! &c] $C=    V Y 3     V  Xc]     V( n     V  HSM 8C=     V |     V    V
    V
 d     V
 T     V
 	x/H 	 	 	  V	 8O#<     V  	 (3-     V c uS*_7M     V> RVTX/3, ,x}!5 ,(3- ,"?3,DLSM,&tn,8=lDQ]L^>^8_, , ,  V,\ S h{6K     V> NR\`$ $x}!5 $hsm $#$45$KSTX>$,\ 223$ $ $  V$ $ $r-   r   c                       e Zd ZdZej        dedefd            Zej        de	e
eef                  de	e         fd            ZdS )	r   z*
    Experimental authentication API.
    sessionr   c                     dS )z
        Formulate a challenge response for the given session and Challenge
        instance. This is sent to the server in the AUTHENTICATE
        message.
        Nr'   )r)   r   r   s      r*   on_challengezIAuthenticator.on_challenge  r,   r-   r   r%   c                     dS )ae  
        This hook is called when the onWelcome/on_welcome hook is invoked
        in the protocol, with the 'authextra' dict extracted from the
        Welcome message. Usually this is used to verify the final
        message from the server (e.g. for mutual authentication).

        :return: None if the session is successful or an error-message
        Nr'   )r)   r   s     r*   
on_welcomezIAuthenticator.on_welcome  r,   r-   N)r6   r7   r8   r9   r;   r<   r   r   r   r   r   r=   r   r   r'   r-   r*   r   r     s          	H      	HT#s(^$< #      r-   r   c                      e Zd ZdZeej        ded         fd                        Zeej        dee	         fd                        Z
eej        defd                        Zej        ddedeeef         fd	            Zej        defd
            Zej        dedefd            Zej        dededefd            ZdS )r   al  
    Interface to an asymmetric verification key, e.g. a WAMP-Cryptosign client or server authentication
    public key (with Ed25519), or a WAMP-XBR data transaction signature public key or address (with Ethereum).

    The key implementation can use various methods, such as a key read from a file, database table
    or a key residing in a hardware device.
    r%   r"   c                     dS )a  
        When this key is hosted by a security module, return a reference.
        If the key is freestanding (exists of its own outside any security
        module or key store), return ``None``.

        :return: The security module of the key if the key is hosted.
        Nr'   r(   s    r*   security_modulezIKey.security_module  r,   r-   c                     dS )ar  
        When this key is hosted by a security module, return an identifier
        to refer to this key within the security module.
        If the key is freestanding (exists of its own outside any security
        module or key store), return ``None``.

        :return: The identifier of this key within the security
            module if this key is hosted.
        Nr'   r(   s    r*   key_nozIKey.key_no  r,   r-   c                     dS )a  
        Type of key and signature scheme, currently one of:

        * ``ed25519``: Ed25519, that is **EdDSA** signing algo with **Curve25519** elliptic curve and **SHA-512** hash,
                used with WAMP-cryptosign session authentication
        * ``eth``: Ethereum, that is **ECDSA** signing algo, **secp256k1** elliptic curve and **Keccak-256** hash,
                used with WAMP-XBR data and transaction signatures

        :return: Key type, one of ``ed25519`` or ``eth``.
        Nr'   r(   s    r*   key_typezIKey.key_type  r,   r-   Fbinaryc                     dS )z
        Returns the public key part of a signing key or the (public) verification key.

        :param binary: If the return type should be binary instead of hex
        :return: The public key in hex or byte encoding.
        Nr'   r)   r   s     r*   
public_keyzIKey.public_key  r,   r-   c                     dS )z
        Check if the key can be used to sign and create new signatures, or only to verify signatures.

        :returns: ``True``, if the key can be used for signing.
        Nr'   r(   s    r*   can_signzIKey.can_sign  r,   r-   datac                     dS )z
        Sign the given data, only available if ``can_sign == True``. This method (always) runs asynchronously.

        :param data: The data to be signed.

        :return: The signature, that is a future object that resolves to bytes.
        Nr'   r)   r   s     r*   signz	IKey.sign  r,   r-   	signaturec                     dS )a@  
        Recover the signer from the data signed, and the signature given. This method (always) runs asynchronously.

        :param data: The data that was signed.
        :param signature: The signature over the data.

        :return: The signer public key that signed the data to create the signature given.
        Nr'   )r)   r   r   s      r*   recoverzIKey.recover  r,   r-   NF)r6   r7   r8   r9   r:   r;   r<   r   r   rO   r   r=   r   r>   r   r?   r   r   r   r   r'   r-   r*   r   r     s         *;!<     X 	 	 	 	  X	 
# 
 
 
  X
 	  %U
2C     	$     	 5     	E e       r-   r   c                       e Zd ZdZej        	 	 d
dedee         dee	         defd            Z
ej        	 	 d
dededee         dee	         def
d	            ZdS )r    z\
    Interface to a WAMP-Cryptosign client authentication (or server verification) key.
    Nr   
channel_idchannel_id_typer%   c                     dS )a  
        Sign the data from the given WAMP challenge message, and the optional TLS channel ID
        using this key and return a valid signature that can be used in a WAMP-cryptosign
        authentication handshake.

        :param challenge: The WAMP challenge message as sent or received during the WAMP-cryptosign
            authentication handshake. This can be used by WAMP clients to compute the signature
            returned in the handshake, or by WAMP routers to verify the signature returned by clients,
            during WAMP-cryptosign client authentication.

        :param channel_id: Optional TLS channel ID. Using this binds the WAMP session authentication
            to the underlying TLS channel, and thus prevents authentication-forwarding attacks.
        :param channel_id_type: Optional TLS channel ID type, e.g. ``"tls-unique"``.

        :return: The signature, that is a future object that resolves to bytes.
        Nr'   )r)   r   r   r   s       r*   sign_challengezICryptosignKey.sign_challenge  r,   r-   r   c                     dS )a  
        Verify the data from the given WAMP challenge message, and the optional TLS channel ID
        to be signed by this key.

        :param challenge: The WAMP challenge message as sent or received during the WAMP-cryptosign
            authentication handshake. This can be used by WAMP clients to compute the signature
            returned within the handshake, or by WAMP routers to verify the signature returned by clients,
            during WAMP-cryptosign client authentication.
        :param signature: The signature to verify.
        :param channel_id: Optional TLS channel ID. Using this binds the WAMP session authentication
            to the underlying TLS channel, and thus prevents authentication-forwarding attacks.
        :param channel_id_type: Optional TLS channel ID type, e.g. ``"tls-unique"``.

        :return: Returns ``True`` if the signature over the data matches this key.
        Nr'   )r)   r   r   r   r   s        r*   verify_challengezICryptosignKey.verify_challenge1  r,   r-   r   )r6   r7   r8   r9   r;   r<   r   r   r?   r=   r   r>   r   r'   r-   r*   r    r      s          	QU8< 	 x (0AF   & 	ei:> )  S[\aSb *23-CG     r-   r    c            	           e Zd ZdZej        ddedeee	f         fd            Z
ej        deeef         de	fd            Zej        deeef         de	d	eee	f         defd
            ZdS )r!   z
    Interface to an Ethereum signing (or transaction verification) key, used for WAMP-XBR transaction
    signing (or verification).
    Fr   r%   c                     dS )a?  
        Returns the Ethereum (public) address of the key (which is derived from
        the public key).

        :param binary: Return address as 160 bits (20 bytes) binary instead of
            the ``0x`` prefixed hex, check-summed address as a string.
        :return: The address in hex or byte encoding.
        Nr'   r   s     r*   addresszIEthereumKey.addressL  r,   r-   r   c                     dS )a,  
        Sign the given typed data according to `EIP712 <https://eips.ethereum.org/EIPS/eip-712>`_
        and create an Ethereum signature.

        :param data: The data to be signed. This must follow EIP712.

        :return: The signature, that is a future object that resolves to bytes.
        Nr'   r   s     r*   sign_typed_datazIEthereumKey.sign_typed_dataW  r,   r-   r   signer_addressc                     dS )a  
        Verify the given typed data according to `EIP712 <https://eips.ethereum.org/EIPS/eip-712>`_
        to be signed by this key.

        :param data: The data to be signed. This must follow EIP712.
        :param signature: The signature to be verified.
        :param signer_address: Address against which the signature is verified.

        :return: Returns ``True`` if the signature over the data matches this key.
        Nr'   )r)   r   r   r   s       r*   verify_typed_datazIEthereumKey.verify_typed_datab  r,   r-   Nr   )r6   r7   r8   r9   r;   r<   r>   r   r=   r?   r   r   r   r   r   r'   r-   r*   r!   r!   E  s         
 	 d uS%Z/@     	DcN u     	
d38n 
 
X]^ach^hXi 
nr 
 
 
 
 
 
r-   r!   c                      e Zd ZdZej        defd            Zej        dedefd            Z	ej        dede
eef         fd            Zej        dede
eef         ddfd	            Zej        deddfd
            Zej        d             Zej        d             Zeej        defd                        Zeej        defd                        Zeej        defd                        Zej        d             Zej        d             Zej        dedefd            Zej        defd            Zej        dedefd            Zej        dedefd            Zej        dedefd            ZdS )r"   a  
    Interface for key security modules, which

    * include filesystem and HSM backed persistent key implementations, and
    * provides secure key signature generation and verification with
    * two key types and signature schemes

    The two key types and signature schemes support WAMP-cryptosign based authentication
    for WAMP sessions, and WAMP-XBR based signed transactions and data encryption.

    References:

    * `SE050 APDU Specification (AN12413) <https://www.nxp.com/docs/en/application-note/AN12413.pdf>`_
    * https://neuromancer.sk/std/secg/secp256r1
    * https://neuromancer.sk/std/secg/secp256k1
    * https://asecuritysite.com/curve25519/eddsa2
    * https://asecuritysite.com/secp256k1/ecdsa
    * https://safecurves.cr.yp.to/
    * https://www.ietf.org/rfc/rfc3279.txt
    * https://crypto.stackexchange.com/questions/70927/naming-convention-for-nist-elliptic-curves-in-openssl
    * https://www.johndcook.com/blog/2018/08/21/a-tale-of-two-elliptic-curves/
    r%   c                     dS )z
        Get number of key pairs currently stored within the security module.

        :return: Current number of keys stored in security module.
        Nr'   r(   s    r*   __len__zISecurityModule.__len__  r,   r-   r   c                     dS z2

        :param key_no:
        :return:
        Nr'   r)   r   s     r*   __contains__zISecurityModule.__contains__  r,   r-   c                     dS )z
        Get a key from the security module given the key number.

        :param key_no: Number of key to get.

        :return: The key, either a :class:`ICryptosignKey` or :class:`IEthereumKey` instance.
        Nr'   r   s     r*   __getitem__zISecurityModule.__getitem__  r,   r-   keyNc                     dS )zF

        :param key_no:
        :param key:
        :return:
        Nr'   )r)   r   r   s      r*   __setitem__zISecurityModule.__setitem__  r,   r-   c                     dS r   r'   r   s     r*   __delitem__zISecurityModule.__delitem__  r,   r-   c                     dS )zV
        Open this security module. This method (always) runs asynchronously.
        Nr'   r(   s    r*   openzISecurityModule.open  r,   r-   c                     dS )zW
        Close this security module. This method (always) runs asynchronously.
        Nr'   r(   s    r*   rc   zISecurityModule.close  r,   r-   c                     dS )z
        Check if the security module is currently opened. Security module operations
        can only be run when the module is opened.

        :return: Flag indicating whether the security module is currently opened.
        Nr'   r(   s    r*   is_openzISecurityModule.is_open  r,   r-   c                     dS )z
        Flag indicating whether this security module can be locked, e.g. by a
        user passphrase or PIN.

        :return: Flag indicating whether the security module can be locked/unlocked at all.
        Nr'   r(   s    r*   can_lockzISecurityModule.can_lock  r,   r-   c                     dS )z
        Check if this security module is currently locked.

        :return: Flag indicating whether the security module is currently locked.
        Nr'   r(   s    r*   	is_lockedzISecurityModule.is_locked  r,   r-   c                     dS )zV
        Lock this security module. This method (always) runs asynchronously.
        Nr'   r(   s    r*   lockzISecurityModule.lock  r,   r-   c                     dS )zX
        Unlock this security module. This method (always) runs asynchronously.
        Nr'   r(   s    r*   unlockzISecurityModule.unlock  r,   r-   r   c                     dS )z
        Create a new public-private asymmetric key pair, stored within the security module.

        :param key_type: Type of key to generate, e.g. ``"cryptosign"`` or ``"ethereum"``.

        :return: ID of new key.
        Nr'   )r)   r   s     r*   
create_keyzISecurityModule.create_key  r,   r-   c                     dS )z}
        Delete an existing key pair stored within the security module.

        :param key_no: ID of key to delete.
        Nr'   r   s     r*   
delete_keyzISecurityModule.delete_key  r,   r-   octetsc                     dS )z
        Generate random bytes within the security module.

        :param octets: Number of bytes (octets) to generate.

        :return: Random bytes, generated within the security module, e.g. in a HW RNG.
        Nr'   )r)   r  s     r*   
get_randomzISecurityModule.get_random	  r,   r-   
counter_noc                     dS )z
        Return current value of the given persistent counter.

        :param counter_no: Counter to access.

        :return: Current value of counter, or ``0`` to indicate the counter does not
            exist (was never incremented).
        Nr'   r)   r  s     r*   get_counterzISecurityModule.get_counter  r,   r-   c                     dS )z
        Increment the given persistent counter and return the new value.

        :param counter_no: Counter to increment and access.

        :return: New value of counter, e.g. ``1`` once a counter was first incremented.
        Nr'   r
  s     r*   increment_counterz!ISecurityModule.increment_counter  r,   r-   )r6   r7   r8   r9   r;   r<   rO   r   r>   r   r   r    r!   r   r   r   r   rc   r:   r   r   r   r   r   r=   r  r  r?   r  r  r  r'   r-   r*   r"   r"   p  s;        . 	     	3 4    * 	# %0L*M     	# E.,2N,O TX     	# $     	  
 	  
      X $     X 4     X 	  
 	  
 	3 3     	     	      	c c     	C C      r-   r"   c                   t    e Zd ZdZeej        dd                        Zeej        d                         ZdS )r#   a{  
    WAMP payload codecs are used with WAMP payload transparency mode.

    In payload transparency mode, application payloads are transmitted "raw",
    as binary strings, without any processing at the WAMP router.

    Payload transparency can be used eg for these use cases:

    * end-to-end encryption of application payloads (WAMP-cryptobox)
    * using serializers with custom user types, where the serializer and
      the serializer implementation has native support for serializing
      custom types (such as CBOR)
    * transmitting MQTT payloads within WAMP, when the WAMP router is
      providing a MQTT-WAMP bridge
    Nc                     dS )a  
        Encodes application payload.

        :param is_originating: Flag indicating whether the encoding
            is to be done from an originator (a caller or publisher).
        :type is_originating: bool

        :param uri: The WAMP URI associated with the WAMP message for which
            the payload is to be encoded (eg topic or procedure).
        :type uri: str

        :param args: Positional application payload.
        :type args: list or None

        :param kwargs: Keyword-based application payload.
        :type kwargs: dict or None

        :returns: The encoded application payload or None to
            signal no encoding should be used.
        :rtype: instance of :class:`autobahn.wamp.types.EncodedPayload`
        Nr'   )r)   is_originatingurir   r   s        r*   encodezIPayloadCodec.encode;  r,   r-   c                     dS )a  
        Decode application payload.

        :param is_originating: Flag indicating whether the encoding
            is to be done from an originator (a caller or publisher).
        :type is_originating: bool

        :param uri: The WAMP URI associated with the WAMP message for which
            the payload is to be encoded (eg topic or procedure).
        :type uri: str

        :param encoded_payload: The encoded application payload to be decoded.
        :type encoded_payload: instance of :class:`autobahn.wamp.types.EncodedPayload`

        :returns: A tuple with the decoded positional and keyword-based
            application payload: ``(uri, args, kwargs)``
        :rtype: tuple
        Nr'   )r)   r  r  encoded_payloads       r*   decodezIPayloadCodec.decodeT  r,   r-   r   )	r6   r7   r8   r9   r
   r;   r<   r  r  r'   r-   r*   r#   r#   )  su               V.    V  r-   r#   )*r;   typingr   r   r   r   r   r   r	   autobahn.utilr
   autobahn.wamp.typesr   r   r   r   r   r   r   r   r   r   r   autobahn.wamp.messager   r   __all__rq   r   r   r   rr   r   r   rp   r   r   r   r    r!   r"   r#   r'   r-   r*   <module>r     s  6 


 D D D D D D D D D D D D D D D D D D
 !          a a a a a a a a a a a a a a a a a a a a a a a a a a 2 2 2 2 2 2 2 2  , , , , , , , ,^ < < < < <#' < < <~ . . . . .sw . . .b 	  '    5 5 5 5 5 5 5 5p        F$ $ $ $ $37 $ $ $ g g g g gt g g gT    SW   2 S S S S S37 S S Sl * * * * *T * * *Z ' ' ' ' '4 ' ' 'T u u u u ucg u u up > > > > >CG > > > > >r-   