aries_cloudagent.messaging.connections package¶
Subpackages¶
- aries_cloudagent.messaging.connections.handlers package
- aries_cloudagent.messaging.connections.messages package
- Subpackages
- Submodules
- aries_cloudagent.messaging.connections.messages.connection_invitation module
- aries_cloudagent.messaging.connections.messages.connection_request module
- aries_cloudagent.messaging.connections.messages.connection_response module
- aries_cloudagent.messaging.connections.messages.problem_report module
- aries_cloudagent.messaging.connections.models package
- aries_cloudagent.messaging.connections.tests package
Submodules¶
aries_cloudagent.messaging.connections.manager module¶
Classes to manage connections.
-
class
aries_cloudagent.messaging.connections.manager.
ConnectionManager
(context: aries_cloudagent.config.injection_context.InjectionContext)[source]¶ Bases:
object
Class for managing connections.
-
RECORD_TYPE_DID_DOC
= 'did_doc'¶
-
RECORD_TYPE_DID_KEY
= 'did_key'¶
-
accept_response
(response: aries_cloudagent.messaging.connections.messages.connection_response.ConnectionResponse, delivery: aries_cloudagent.messaging.message_delivery.MessageDelivery) → aries_cloudagent.messaging.connections.models.connection_record.ConnectionRecord[source]¶ Accept a connection response.
Process a ConnectionResponse message by looking up the connection request and setting up the pairwise connection.
Parameters: - response – The ConnectionResponse to accept
- delivery – The message delivery metadata
Returns: The updated ConnectionRecord representing the connection
Raises: ConnectionManagerError
– If there is no DID associated with the connection responseConnectionManagerError
– If the corresponding connection is not at the request or response stage
-
add_key_for_did
(did: str, key: str)[source]¶ Store a verkey for lookup against a DID.
Parameters: - did – The DID to associate with this key
- key – The verkey to be added
-
context
¶ Accessor for the current injection context.
Returns: The injection context for this connection manager
-
create_did_document
(my_info: aries_cloudagent.wallet.base.DIDInfo, inbound_connection_id: str = None, my_endpoint: str = None) → aries_cloudagent.messaging.connections.models.diddoc.diddoc.DIDDoc[source]¶ Create our DID document for a given DID.
Parameters: - my_info – The DID I am using in this connection
- inbound_connection_id – The DID of the inbound routing connection to use
- my_endpoint – A custom endpoint for the DID Document
Returns: The prepared DIDDoc instance
-
create_invitation
(my_label: str = None, my_endpoint: str = None, their_role: str = None, accept: str = None, public: bool = False) → Tuple[aries_cloudagent.messaging.connections.models.connection_record.ConnectionRecord, aries_cloudagent.messaging.connections.messages.connection_invitation.ConnectionInvitation][source]¶ Generate new connection invitation.
This interaction represents an out-of-band communication channel. In the future and in practice, these sort of invitations will be received over any number of channels such as SMS, Email, QR Code, NFC, etc.
Structure of an invite message: ```json {
“@type”: “did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/connections/1.0/invitation”, “label”: “Alice”, “did”: “did:sov:QmWbsNYhMrjHiqZDTUTEJs”}```
Or, in the case of a peer DID: ```json {
“@type”: “did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/connections/1.0/invitation”, “label”: “Alice”, “did”: “did:peer:oiSqsNYhMrjHiqZDTUthsw”, “recipientKeys”: [“8HH5gYEeNc3z7PYXmd54d4x6qAfCNrqQqEB3nS7Zfu7K”], “serviceEndpoint”: “https://example.com/endpoint”}```
Currently, only peer DID is supported.
Parameters: - my_label – label for this connection
- my_endpoint – endpoint where other party can reach me
- their_role – a role to assign the connection
- accept – set to ‘auto’ to auto-accept a corresponding connection request
- public – set to True to create an invitation from the public DID
Returns: A tuple of the new ConnectionRecord and ConnectionInvitation instances
-
create_request
(connection: aries_cloudagent.messaging.connections.models.connection_record.ConnectionRecord, my_label: str = None, my_endpoint: str = None) → aries_cloudagent.messaging.connections.messages.connection_request.ConnectionRequest[source]¶ Create a new connection request for a previously-received invitation.
Parameters: - connection – The ConnectionRecord representing the invitation to accept
- my_label – My label
- my_endpoint – My endpoint
Returns: A new ConnectionRequest message to send to the other agent
-
create_response
(connection: aries_cloudagent.messaging.connections.models.connection_record.ConnectionRecord, my_endpoint: str = None) → aries_cloudagent.messaging.connections.messages.connection_response.ConnectionResponse[source]¶ Create a connection response for a received connection request.
Parameters: - connection – The ConnectionRecord with a pending connection request
- my_endpoint – The endpoint I can be reached at
Returns: A tuple of the updated ConnectionRecord new ConnectionResponse message
-
diddoc_connection_target
(doc: aries_cloudagent.messaging.connections.models.diddoc.diddoc.DIDDoc, sender_verkey: str, their_label: str = None) → aries_cloudagent.messaging.connections.models.connection_target.ConnectionTarget[source]¶ Create a connection target from a DID Document.
Parameters: - doc – The DID Document to create the target from
- sender_verkey – The verkey we are using
- their_label – The connection label they are using
-
establish_inbound
(connection: aries_cloudagent.messaging.connections.models.connection_record.ConnectionRecord, inbound_connection_id: str, outbound_handler) → str[source]¶ Assign the inbound routing connection for a connection record.
Returns: the current routing state (request or done)
-
fetch_did_document
(did: str) → aries_cloudagent.messaging.connections.models.diddoc.diddoc.DIDDoc[source]¶ Retrieve a DID Document for a given DID.
Parameters: did – The DID to search for
-
find_connection
(their_did: str, my_did: str = None, my_verkey: str = None, auto_complete=False) → aries_cloudagent.messaging.connections.models.connection_record.ConnectionRecord[source]¶ Look up existing connection information for a sender verkey.
Parameters: - their_did – Their DID
- my_did – My DID
- my_verkey – My verkey
- auto_complete – Should this connection automatically be promoted to active
Returns: The located ConnectionRecord, if any
-
find_did_for_key
(key: str) → str[source]¶ Find the DID previously associated with a key.
Parameters: key – The verkey to look up
-
find_message_connection
(delivery: aries_cloudagent.messaging.message_delivery.MessageDelivery) → aries_cloudagent.messaging.connections.models.connection_record.ConnectionRecord[source]¶ Deserialize an incoming message and further populate the request context.
Parameters: delivery – The message delivery details Returns: The ConnectionRecord associated with the expanded message, if any
-
get_connection_target
(connection: aries_cloudagent.messaging.connections.models.connection_record.ConnectionRecord) → aries_cloudagent.messaging.connections.models.connection_target.ConnectionTarget[source]¶ Create a connection target from a ConnectionRecord.
Parameters: connection – The connection record (with associated DIDDoc) used to generate the connection target
-
log_activity
(connection: aries_cloudagent.messaging.connections.models.connection_record.ConnectionRecord, activity_type: str, direction: str, meta: dict = None)[source]¶ Log activity against a connection record and send webhook.
-
receive_invitation
(invitation: aries_cloudagent.messaging.connections.messages.connection_invitation.ConnectionInvitation, their_role: str = None, accept: str = None) → aries_cloudagent.messaging.connections.models.connection_record.ConnectionRecord[source]¶ Create a new connection record to track a received invitation.
Parameters: - invitation – The ConnectionInvitation to store
- their_role – The role assigned to this connection
- accept – set to ‘auto’ to auto-accept the invitation
Returns: The new ConnectionRecord instance
-
receive_request
(request: aries_cloudagent.messaging.connections.messages.connection_request.ConnectionRequest, delivery: aries_cloudagent.messaging.message_delivery.MessageDelivery) → aries_cloudagent.messaging.connections.models.connection_record.ConnectionRecord[source]¶ Receive and store a connection request.
Parameters: - request – The ConnectionRequest to accept
- delivery – The message delivery metadata
Returns: The new or updated ConnectionRecord instance
-
remove_keys_for_did
(did: str)[source]¶ Remove all keys associated with a DID.
Parameters: did – The DID to remove keys for
-
-
exception
aries_cloudagent.messaging.connections.manager.
ConnectionManagerError
(*args, error_code: str = None, **kwargs)[source]¶ Bases:
aries_cloudagent.error.BaseError
Connection error.
aries_cloudagent.messaging.connections.message_types module¶
Message type identifiers for Connections.
aries_cloudagent.messaging.connections.routes module¶
Connection handling admin routes.
-
class
aries_cloudagent.messaging.connections.routes.
ConnectionListSchema
(*args, **kwargs)[source]¶ Bases:
sphinx.ext.autodoc.importer._MockObject
Result schema for connection list.
-
results
¶ Used by autodoc_mock_imports.
-
-
class
aries_cloudagent.messaging.connections.routes.
InvitationResultSchema
(*args, **kwargs)[source]¶ Bases:
sphinx.ext.autodoc.importer._MockObject
Result schema for a new connection invitation.
-
connection_id
¶ Used by autodoc_mock_imports.
-
invitation
¶ Used by autodoc_mock_imports.
-
invitation_url
¶ Used by autodoc_mock_imports.
-
-
aries_cloudagent.messaging.connections.routes.
connection_sort_key
(conn)[source]¶ Get the sorting key for a particular connection.
-
aries_cloudagent.messaging.connections.routes.
connections_accept_invitation
(request: <sphinx.ext.autodoc.importer._MockObject object at 0x7fd66218d240>)[source]¶ Request handler for accepting a stored connection invitation.
Parameters: request – aiohttp request object Returns: The resulting connection record details
-
aries_cloudagent.messaging.connections.routes.
connections_accept_request
(request: <sphinx.ext.autodoc.importer._MockObject object at 0x7fd66218d240>)[source]¶ Request handler for accepting a stored connection request.
Parameters: request – aiohttp request object Returns: The resulting connection record details
-
aries_cloudagent.messaging.connections.routes.
connections_create_invitation
(request: <sphinx.ext.autodoc.importer._MockObject object at 0x7fd66218d240>)[source]¶ Request handler for creating a new connection invitation.
Parameters: request – aiohttp request object Returns: The connection invitation details
-
aries_cloudagent.messaging.connections.routes.
connections_establish_inbound
(request: <sphinx.ext.autodoc.importer._MockObject object at 0x7fd66218d240>)[source]¶ Request handler for setting the inbound connection on a connection record.
Parameters: request – aiohttp request object
-
aries_cloudagent.messaging.connections.routes.
connections_list
(request: <sphinx.ext.autodoc.importer._MockObject object at 0x7fd66218d240>)[source]¶ Request handler for searching connection records.
Parameters: request – aiohttp request object Returns: The connection list response
-
aries_cloudagent.messaging.connections.routes.
connections_receive_invitation
(request: <sphinx.ext.autodoc.importer._MockObject object at 0x7fd66218d240>)[source]¶ Request handler for receiving a new connection invitation.
Parameters: request – aiohttp request object Returns: The resulting connection record details
-
aries_cloudagent.messaging.connections.routes.
connections_remove
(request: <sphinx.ext.autodoc.importer._MockObject object at 0x7fd66218d240>)[source]¶ Request handler for removing a connection record.
Parameters: request – aiohttp request object