aries_cloudagent.protocols.connections package

Submodules

aries_cloudagent.protocols.connections.manager module

Classes to manage connections.

class aries_cloudagent.protocols.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.protocols.connections.messages.connection_response.ConnectionResponse, receipt: aries_cloudagent.transport.inbound.receipt.MessageReceipt) → aries_cloudagent.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
  • receipt – The message receipt
Returns:

The updated ConnectionRecord representing the connection

Raises:
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(did_info: aries_cloudagent.wallet.base.DIDInfo, inbound_connection_id: str = None, svc_endpoints: Sequence[str] = []) → aries_cloudagent.connections.models.diddoc.diddoc.DIDDoc[source]

Create our DID document for a given DID.

Parameters:
  • did_info – The DID information (DID and verkey) used in the connection
  • inbound_connection_id – The ID of the inbound routing connection to use
  • svc_endpoints – Custom endpoints 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, multi_use: bool = False, alias: str = None) → Tuple[aries_cloudagent.connections.models.connection_record.ConnectionRecord, aries_cloudagent.protocols.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:

{
    "@type":
        "did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/connections/1.0/invitation",
    "label": "Alice",
    "did": "did:sov:QmWbsNYhMrjHiqZDTUTEJs"
}

Or, in the case of a peer DID:

{
    "@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
  • multi_use – set to True to create an invitation for multiple use
  • alias – optional alias to apply to connection for later use
Returns:

A tuple of the new ConnectionRecord and ConnectionInvitation instances

create_request(connection: aries_cloudagent.connections.models.connection_record.ConnectionRecord, my_label: str = None, my_endpoint: str = None) → aries_cloudagent.protocols.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.connections.models.connection_record.ConnectionRecord, my_endpoint: str = None) → aries_cloudagent.protocols.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

create_static_connection(my_did: str = None, my_seed: str = None, their_did: str = None, their_seed: str = None, their_verkey: str = None, their_endpoint: str = None, their_role: str = None, their_label: str = None, alias: str = None) -> (<class 'aries_cloudagent.wallet.base.DIDInfo'>, <class 'aries_cloudagent.wallet.base.DIDInfo'>, <class 'aries_cloudagent.connections.models.connection_record.ConnectionRecord'>)[source]

Register a new static connection (for use by the test suite).

Parameters:
  • my_did – override the DID used in the connection
  • my_seed – provide a seed used to generate our DID and keys
  • their_did – provide the DID used by the other party
  • their_seed – provide a seed used to generate their DID and keys
  • their_verkey – provide the verkey used by the other party
  • their_endpoint – their URL endpoint for routing messages
  • their_role – their role in this connection
  • alias – an alias for this connection record
Returns:

The new ConnectionRecord instance

diddoc_connection_targets(doc: aries_cloudagent.connections.models.diddoc.diddoc.DIDDoc, sender_verkey: str, their_label: str = None) → Sequence[aries_cloudagent.connections.models.connection_target.ConnectionTarget][source]

Get a list of connection targets 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.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_connection_targets(connection: aries_cloudagent.connections.models.connection_record.ConnectionRecord) → Sequence[aries_cloudagent.connections.models.connection_target.ConnectionTarget][source]

Get a list of connection target from a ConnectionRecord.

Parameters:connection – The connection record (with associated DIDDoc) used to generate the connection target
fetch_did_document(did: str) → Tuple[aries_cloudagent.connections.models.diddoc.diddoc.DIDDoc, aries_cloudagent.storage.record.StorageRecord][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.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_inbound_connection(receipt: aries_cloudagent.transport.inbound.receipt.MessageReceipt) → aries_cloudagent.connections.models.connection_record.ConnectionRecord[source]

Deserialize an incoming message and further populate the request context.

Parameters:receipt – The message receipt
Returns:The ConnectionRecord associated with the expanded message, if any
get_connection_targets(*, connection_id: str = None, connection: aries_cloudagent.connections.models.connection_record.ConnectionRecord = None)[source]

Create a connection target from a ConnectionRecord.

Parameters:
  • connection_id – The connection ID to search for
  • connection – The connection record itself, if already available
receive_invitation(invitation: aries_cloudagent.protocols.connections.messages.connection_invitation.ConnectionInvitation, their_role: str = None, accept: str = None, alias: str = None) → aries_cloudagent.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
  • alias – optional alias to set on the record
Returns:

The new ConnectionRecord instance

receive_request(request: aries_cloudagent.protocols.connections.messages.connection_request.ConnectionRequest, receipt: aries_cloudagent.transport.inbound.receipt.MessageReceipt) → aries_cloudagent.connections.models.connection_record.ConnectionRecord[source]

Receive and store a connection request.

Parameters:
  • request – The ConnectionRequest to accept
  • receipt – The message receipt
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
resolve_inbound_connection(receipt: aries_cloudagent.transport.inbound.receipt.MessageReceipt) → aries_cloudagent.connections.models.connection_record.ConnectionRecord[source]

Populate the receipt DID information and find the related ConnectionRecord.

Parameters:receipt – The message receipt
Returns:The ConnectionRecord associated with the expanded message, if any
store_did_document(did_doc: aries_cloudagent.connections.models.diddoc.diddoc.DIDDoc)[source]

Store a DID document.

Parameters:did_doc – The DIDDoc instance to be persisted
update_inbound(inbound_connection_id: str, recip_verkey: str, routing_state: str)[source]

Activate connections once a route has been established.

Looks up pending connections associated with the inbound routing connection and marks the routing as complete.

exception aries_cloudagent.protocols.connections.manager.ConnectionManagerError(*args, error_code: str = None, **kwargs)[source]

Bases: aries_cloudagent.core.error.BaseError

Connection error.

aries_cloudagent.protocols.connections.message_types module

Message type identifiers for Connections.

aries_cloudagent.protocols.connections.routes module

Connection handling admin routes.

class aries_cloudagent.protocols.connections.routes.ConnectionListSchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)[source]

Bases: marshmallow.schema.Schema

Result schema for connection list.

opts = <marshmallow.schema.SchemaOpts object>
class aries_cloudagent.protocols.connections.routes.ConnectionStaticRequestSchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)[source]

Bases: marshmallow.schema.Schema

Request schema for a new static connection.

opts = <marshmallow.schema.SchemaOpts object>
class aries_cloudagent.protocols.connections.routes.ConnectionStaticResultSchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)[source]

Bases: marshmallow.schema.Schema

Result schema for new static connection.

opts = <marshmallow.schema.SchemaOpts object>
class aries_cloudagent.protocols.connections.routes.InvitationResultSchema(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)[source]

Bases: marshmallow.schema.Schema

Result schema for a new connection invitation.

opts = <marshmallow.schema.SchemaOpts object>
aries_cloudagent.protocols.connections.routes.connection_sort_key(conn)[source]

Get the sorting key for a particular connection.

aries_cloudagent.protocols.connections.routes.connections_accept_invitation(request: <sphinx.ext.autodoc.importer._MockObject object at 0x7faf68f52e48>)[source]

Request handler for accepting a stored connection invitation.

Parameters:request – aiohttp request object
Returns:The resulting connection record details
aries_cloudagent.protocols.connections.routes.connections_accept_request(request: <sphinx.ext.autodoc.importer._MockObject object at 0x7faf68f52e48>)[source]

Request handler for accepting a stored connection request.

Parameters:request – aiohttp request object
Returns:The resulting connection record details
aries_cloudagent.protocols.connections.routes.connections_create_invitation(request: <sphinx.ext.autodoc.importer._MockObject object at 0x7faf68f52e48>)[source]

Request handler for creating a new connection invitation.

Parameters:request – aiohttp request object
Returns:The connection invitation details
aries_cloudagent.protocols.connections.routes.connections_create_static(request: <sphinx.ext.autodoc.importer._MockObject object at 0x7faf68f52e48>)[source]

Request handler for creating a new static connection.

Parameters:request – aiohttp request object
Returns:The new connection record
aries_cloudagent.protocols.connections.routes.connections_establish_inbound(request: <sphinx.ext.autodoc.importer._MockObject object at 0x7faf68f52e48>)[source]

Request handler for setting the inbound connection on a connection record.

Parameters:request – aiohttp request object
aries_cloudagent.protocols.connections.routes.connections_list(request: <sphinx.ext.autodoc.importer._MockObject object at 0x7faf68f52e48>)[source]

Request handler for searching connection records.

Parameters:request – aiohttp request object
Returns:The connection list response
aries_cloudagent.protocols.connections.routes.connections_receive_invitation(request: <sphinx.ext.autodoc.importer._MockObject object at 0x7faf68f52e48>)[source]

Request handler for receiving a new connection invitation.

Parameters:request – aiohttp request object
Returns:The resulting connection record details
aries_cloudagent.protocols.connections.routes.connections_remove(request: <sphinx.ext.autodoc.importer._MockObject object at 0x7faf68f52e48>)[source]

Request handler for removing a connection record.

Parameters:request – aiohttp request object
aries_cloudagent.protocols.connections.routes.connections_retrieve(request: <sphinx.ext.autodoc.importer._MockObject object at 0x7faf68f52e48>)[source]

Request handler for fetching a single connection record.

Parameters:request – aiohttp request object
Returns:The connection record response
aries_cloudagent.protocols.connections.routes.register(app: <sphinx.ext.autodoc.importer._MockObject object at 0x7faf68f52e48>)[source]

Register routes.