aries_cloudagent.connections.models package

Subpackages

Submodules

aries_cloudagent.connections.models.conn_record module

Handle connection information interface with non-secrets storage.

class aries_cloudagent.connections.models.conn_record.ConnRecord(*, connection_id: Optional[str] = None, my_did: Optional[str] = None, their_did: Optional[str] = None, their_label: Optional[str] = None, their_role: Optional[Union[str, Role]] = None, invitation_key: Optional[str] = None, invitation_msg_id: Optional[str] = None, request_id: Optional[str] = None, state: Optional[Union[str, State]] = None, inbound_connection_id: Optional[str] = None, error_msg: Optional[str] = None, accept: Optional[str] = None, invitation_mode: Optional[str] = None, alias: Optional[str] = None, their_public_did: Optional[str] = None, connection_protocol: Optional[Union[str, Protocol]] = None, rfc23_state: Optional[str] = None, routing_state: Optional[str] = None, initiator: Optional[str] = None, **kwargs)[source]

Bases: BaseRecord

Represents a single pairwise connection.

ACCEPT_AUTO = 'auto'
ACCEPT_MANUAL = 'manual'
INVITATION_MODE_MULTI = 'multi'
INVITATION_MODE_ONCE = 'once'
INVITATION_MODE_STATIC = 'static'
LOG_STATE_FLAG = 'debug.connections'
class Meta[source]

Bases: object

ConnRecord metadata.

schema_class = 'MaybeStoredConnRecordSchema'
class Protocol(value)[source]

Bases: Enum

Supported Protocols for Connection.

RFC_0023 = 'didexchange/1.0'
RFC_0160 = 'connections/1.0'
property aries_protocol

Return used connection protocol.

classmethod get(label: Union[str, Protocol])[source]

Get aries protocol enum for label.

RECORD_ID_NAME = 'connection_id'
RECORD_TOPIC: Optional[str] = 'connections'
RECORD_TYPE = 'connection'
RECORD_TYPE_INVITATION = 'connection_invitation'
RECORD_TYPE_METADATA = 'connection_metadata'
RECORD_TYPE_REQUEST = 'connection_request'
class Role(value)[source]

Bases: Enum

RFC 160 (inviter, invitee) = RFC 23 (responder, requester).

REQUESTER = ('invitee', 'requester')
RESPONDER = ('inviter', 'responder')
flip()[source]

Return opposite interlocutor role: theirs for ours, ours for theirs.

classmethod get(label: Union[str, Role])[source]

Get role enum for label.

property rfc160

Return RFC 160 (connection protocol) nomenclature.

property rfc23

Return RFC 23 (DID exchange protocol) nomenclature.

class State(value)[source]

Bases: Enum

Collator for equivalent states between RFC 160 and RFC 23.

On the connection record, the state has to serve for both RFCs. Hence, internally, RFC23 requester/responder states collate to their RFC160 condensed equivalent.

ABANDONED = ('error', 'abandoned')
COMPLETED = ('active', 'completed')
INIT = ('init', 'start')
INVITATION = ('invitation', 'invitation')
REQUEST = ('request', 'request')
RESPONSE = ('response', 'response')
classmethod get(label: Union[str, State])[source]

Get state enum for label.

property rfc160

Return RFC 160 (connection protocol) nomenclature.

property rfc23

Return RFC 23 (DID exchange protocol) nomenclature to record logic.

rfc23strict(their_role: Role)[source]

Return RFC 23 (DID exchange protocol) nomenclature to role as per RFC.

TAG_NAMES = {'invitation_key', 'invitation_msg_id', 'my_did', 'request_id', 'state', 'their_did', 'their_public_did', 'their_role'}
async abandon(session: ProfileSession, *, reason: Optional[str] = None)[source]

Set state to abandoned.

async attach_invitation(session: ProfileSession, invitation: Union[ConnectionInvitation, InvitationMessage])[source]

Persist the related connection invitation to storage.

Parameters
  • session – The active profile session

  • invitation – The invitation to relate to this connection record

async attach_request(session: ProfileSession, request: Union[ConnectionRequest, DIDXRequest])[source]

Persist the related connection request to storage.

Parameters
  • session – The active profile session

  • request – The request to relate to this connection record

property connection_id: str

Accessor for the ID associated with this connection.

async delete_record(session: ProfileSession)[source]

Perform connection record deletion actions.

Parameters

session (ProfileSession) – session

async classmethod find_existing_connection(session: ProfileSession, their_public_did: str) Optional[ConnRecord][source]

Retrieve existing active connection records (public did).

Parameters
  • session – The active profile session

  • their_public_did – Inviter public DID

property is_multiuse_invitation: bool

Accessor for multi use invitation mode.

property is_ready: str

Accessor for connection readiness.

async metadata_delete(session: ProfileSession, key: str)[source]

Delete custom metadata associated with this connection.

Parameters
  • session (ProfileSession) – session used for storage

  • key (str) – key of metadata to delete

async metadata_get(session: ProfileSession, key: str, default: Optional[Any] = None) Any[source]

Retrieve arbitrary metadata associated with this connection.

Parameters
  • session (ProfileSession) – session used for storage

  • key (str) – key identifying metadata

  • default (Any) – default value to get; type should be a JSON compatible value.

Returns

metadata stored by key

Return type

Any

async metadata_get_all(session: ProfileSession) dict[source]

Return all custom metadata associated with this connection.

Parameters

session (ProfileSession) – session used for storage

Returns

dictionary representation of all metadata values

Return type

dict

async metadata_set(session: ProfileSession, key: str, value: Any)[source]

Set arbitrary metadata associated with this connection.

Parameters
  • session (ProfileSession) – session used for storage

  • key (str) – key identifying metadata

  • value (Any) – value to set

async post_save(session: ProfileSession, *args, **kwargs)[source]

Perform post-save actions.

Parameters

session – The active profile session

property record_value: dict

Accessor to for the JSON record value properties for this connection.

async classmethod retrieve_by_alias(session: ProfileSession, alias: str) ConnRecord[source]

Retrieve a connection record from an alias.

Parameters
  • session – The active profile session

  • alias – The alias of the connection

async classmethod retrieve_by_did(session: ProfileSession, their_did: Optional[str] = None, my_did: Optional[str] = None, their_role: Optional[str] = None) ConnRecord[source]

Retrieve a connection record by target DID.

Parameters
  • session – The active profile session

  • their_did – The target DID to filter by

  • my_did – One of our DIDs to filter by

  • my_role – Filter connections by their role

async classmethod retrieve_by_invitation_key(session: ProfileSession, invitation_key: str, their_role: Optional[str] = None) ConnRecord[source]

Retrieve a connection record by invitation key.

Parameters
  • session – The active profile session

  • invitation_key – The key on the originating invitation

  • their_role – Filter by their role

async classmethod retrieve_by_invitation_msg_id(session: ProfileSession, invitation_msg_id: str, their_role: Optional[str] = None) Optional[ConnRecord][source]

Retrieve a connection record by invitation_msg_id.

Parameters
  • session – The active profile session

  • invitation_msg_id – Invitation message identifier

  • their_role – Filter by their role

async classmethod retrieve_by_request_id(session: ProfileSession, request_id: str, their_role: Optional[str] = None) ConnRecord[source]

Retrieve a connection record from our previous request ID.

Parameters
  • session – The active profile session

  • request_id – The ID of the originating connection request

async retrieve_invitation(session: ProfileSession) Union[ConnectionInvitation, InvitationMessage][source]

Retrieve the related connection invitation.

Parameters

session – The active profile session

async retrieve_request(session: ProfileSession) Union[ConnectionRequest, DIDXRequest][source]

Retrieve the related connection invitation.

Parameters

session – The active profile session

property rfc23_state: str

RFC23 state per RFC text, potentially particular to role.

class aries_cloudagent.connections.models.conn_record.ConnRecordSchema(*args: Any, **kwargs: Any)[source]

Bases: MaybeStoredConnRecordSchema

Schema representing stored ConnRecords.

class Meta[source]

Bases: object

ConnRecordSchema metadata.

model_class

alias of ConnRecord

class aries_cloudagent.connections.models.conn_record.MaybeStoredConnRecordSchema(*args: Any, **kwargs: Any)[source]

Bases: BaseRecordSchema

Schema to allow serialization/deserialization of connection records.

class Meta[source]

Bases: object

MaybeStoredConnRecordSchema metadata.

model_class

alias of ConnRecord

aries_cloudagent.connections.models.connection_target module

Record used to handle routing of messages to another agent.

class aries_cloudagent.connections.models.connection_target.ConnectionTarget(*, did: Optional[str] = None, endpoint: Optional[str] = None, label: Optional[str] = None, recipient_keys: Optional[Sequence[str]] = None, routing_keys: Optional[Sequence[str]] = None, sender_key: Optional[str] = None)[source]

Bases: BaseModel

Record used to handle routing of messages to another agent.

class Meta[source]

Bases: object

ConnectionTarget metadata.

schema_class = 'ConnectionTargetSchema'
class aries_cloudagent.connections.models.connection_target.ConnectionTargetSchema(*args: Any, **kwargs: Any)[source]

Bases: BaseModelSchema

ConnectionTarget schema.

class Meta[source]

Bases: object

ConnectionTargetSchema metadata.

model_class

alias of ConnectionTarget