aries_cloudagent.messaging package¶
Subpackages¶
- aries_cloudagent.messaging.ack package
- aries_cloudagent.messaging.credential_definitions package
- aries_cloudagent.messaging.decorators package
- Submodules
- aries_cloudagent.messaging.decorators.attach_decorator module
- aries_cloudagent.messaging.decorators.base module
- aries_cloudagent.messaging.decorators.default module
- aries_cloudagent.messaging.decorators.localization_decorator module
- aries_cloudagent.messaging.decorators.please_ack_decorator module
- aries_cloudagent.messaging.decorators.signature_decorator module
- aries_cloudagent.messaging.decorators.thread_decorator module
- aries_cloudagent.messaging.decorators.timing_decorator module
- aries_cloudagent.messaging.decorators.trace_decorator module
- aries_cloudagent.messaging.decorators.transport_decorator module
- aries_cloudagent.messaging.jsonld package
- aries_cloudagent.messaging.models package
- aries_cloudagent.messaging.schemas package
Submodules¶
aries_cloudagent.messaging.agent_message module¶
Agent message base class and schema.
-
class
aries_cloudagent.messaging.agent_message.AgentMessage(_id: str = None, _decorators: aries_cloudagent.messaging.decorators.base.BaseDecoratorSet = None)[source]¶ Bases:
aries_cloudagent.messaging.models.base.BaseModelAgent message base class.
-
Handler¶ Accessor for the agent message’s handler class.
Returns: Handler class
-
class
Meta[source]¶ Bases:
objectAgentMessage metadata.
-
handler_class= None¶
-
message_type= None¶
-
schema_class= None¶
-
-
add_trace_decorator(target: str = 'log', full_thread: bool = True)[source]¶ Create a new trace decorator.
Parameters: - target – The trace target
- full_thread – Full thread flag
-
add_trace_report(val: Union[aries_cloudagent.messaging.decorators.trace_decorator.TraceReport, dict])[source]¶ Append a new trace report.
Parameters: val – The trace target
-
assign_thread_from(msg: aries_cloudagent.messaging.agent_message.AgentMessage)[source]¶ Copy thread information from a previous message.
Parameters: msg – The received message containing optional thread information
-
assign_thread_id(thid: str, pthid: str = None)[source]¶ Assign a specific thread ID.
Parameters: - thid – The thread identifier
- pthid – The parent thread identifier
-
assign_trace_decorator(context, trace)[source]¶ Copy trace from a json structure.
Parameters: trace – string containing trace json stucture
-
assign_trace_from(msg: aries_cloudagent.messaging.agent_message.AgentMessage)[source]¶ Copy trace information from a previous message.
Parameters: msg – The received message containing optional trace information
-
get_signature(field_name: str) → aries_cloudagent.messaging.decorators.signature_decorator.SignatureDecorator[source]¶ Get the signature for a named field.
Parameters: field_name – Field name to get the signature for Returns: A SignatureDecorator for the requested field name
-
set_signature(field_name: str, signature: aries_cloudagent.messaging.decorators.signature_decorator.SignatureDecorator)[source]¶ Add or replace the signature for a named field.
Parameters: - field_name – Field to set signature on
- signature – Signature for the field
-
sign_field(field_name: str, signer_verkey: str, wallet: aries_cloudagent.wallet.base.BaseWallet, timestamp=None) → aries_cloudagent.messaging.decorators.signature_decorator.SignatureDecorator[source]¶ Create and store a signature for a named field.
Parameters: - field_name – Field to sign
- signer_verkey – Verkey of signer
- wallet – Wallet to use for signature
- timestamp – Optional timestamp for signature
Returns: A SignatureDecorator for newly created signature
Raises: ValueError– If field_name doesn’t exist on this message
-
verify_signatures(wallet: aries_cloudagent.wallet.base.BaseWallet) → bool[source]¶ Verify all associated field signatures.
Parameters: wallet – Wallet to use in verification Returns: True if all signatures verify, else false
-
verify_signed_field(field_name: str, wallet: aries_cloudagent.wallet.base.BaseWallet, signer_verkey: str = None) → str[source]¶ Verify a specific field signature.
Parameters: - field_name – The field name to verify
- wallet – Wallet to use for the verification
- signer_verkey – Verkey of signer to use
Returns: The verkey of the signer
Raises: ValueError– If field_name does not exist on this messageValueError– If the verification failsValueError– If the verkey of the signature does not match the- provided verkey
-
-
exception
aries_cloudagent.messaging.agent_message.AgentMessageError(*args, error_code: str = None, **kwargs)[source]¶ Bases:
aries_cloudagent.messaging.models.base.BaseModelErrorBase exception for agent message issues.
-
class
aries_cloudagent.messaging.agent_message.AgentMessageSchema(*args, **kwargs)[source]¶ Bases:
aries_cloudagent.messaging.models.base.BaseModelSchemaAgentMessage schema.
-
class
Meta[source]¶ Bases:
objectAgentMessageSchema metadata.
-
model_class= None¶
-
signed_fields= None¶
-
unknown¶ Used by autodoc_mock_imports.
-
-
check_dump_decorators(obj, **kwargs)[source]¶ Pre-dump hook to validate and load the message decorators.
Parameters: obj – The AgentMessage object Raises: BaseModelError– If a decorator does not validate
-
dump_decorators(data, **kwargs)[source]¶ Post-dump hook to write the decorators to the serialized output.
Parameters: obj – The serialized data Returns: The modified data
-
extract_decorators(data: Mapping[KT, VT_co], **kwargs)[source]¶ Pre-load hook to extract the decorators and check the signed fields.
Parameters: data – Incoming data to parse
Returns: Parsed and modified data
Raises: ValidationError– If a field signature does not correlate- to a field in the message
ValidationError– If the message defines both a field signature- and a value for the same field
ValidationError– If there is a missing field signature
-
class
aries_cloudagent.messaging.base_handler module¶
A Base handler class for all message handlers.
-
class
aries_cloudagent.messaging.base_handler.BaseHandler[source]¶ Bases:
abc.ABCAbstract base class for handlers.
-
exception
aries_cloudagent.messaging.base_handler.HandlerException(*args, error_code: str = None, **kwargs)[source]¶ Bases:
aries_cloudagent.core.error.BaseErrorException base class for generic handler errors.
aries_cloudagent.messaging.error module¶
Messaging-related error classes and codes.
-
exception
aries_cloudagent.messaging.error.MessageParseError(*args, error_code: str = None, **kwargs)[source]¶ Bases:
aries_cloudagent.core.error.BaseErrorMessage parse error.
-
error_code= 'message_parse_error'¶
-
-
exception
aries_cloudagent.messaging.error.MessagePrepareError(*args, error_code: str = None, **kwargs)[source]¶ Bases:
aries_cloudagent.core.error.BaseErrorMessage preparation error.
-
error_code= 'message_prepare_error'¶
-
aries_cloudagent.messaging.request_context module¶
Request context class.
A request context provides everything required by handlers and other parts of the system to process a message.
-
class
aries_cloudagent.messaging.request_context.RequestContext(profile: aries_cloudagent.core.profile.Profile, *, context: aries_cloudagent.config.injection_context.InjectionContext = None, settings: Mapping[str, object] = None)[source]¶ Bases:
objectContext established by the Conductor and passed into message handlers.
-
connection_ready¶ Accessor for the flag indicating an active connection with the sender.
Returns: True if the connection is active, else False
-
connection_record¶ Accessor for the related connection record.
-
default_endpoint¶ Accessor for the default agent endpoint (from agent config).
Returns: The default agent endpoint
-
default_label¶ Accessor for the default agent label (from agent config).
Returns: The default label
-
inject(base_cls: Type[Inject], settings: Mapping[str, object] = None, *, required: bool = True) → Optional[Inject][source]¶ Get the provided instance of a given class identifier.
Parameters: - cls – The base class to retrieve an instance of
- settings – An optional mapping providing configuration to the provider
Returns: An instance of the base class, or None
-
injector¶ Accessor for the associated Injector instance.
-
message¶ Accessor for the deserialized message instance.
Returns: This context’s agent message
-
message_receipt¶ Accessor for the message receipt information.
Returns: This context’s message receipt information
-
profile¶ Accessor for the associated Profile instance.
-
session() → aries_cloudagent.core.profile.ProfileSession[source]¶ Start a new interactive session with no transaction support requested.
-
settings¶ Accessor for the context settings.
-
classmethod
test_context() → aries_cloudagent.messaging.request_context.RequestContext[source]¶ Quickly set up a new request context for tests.
-
aries_cloudagent.messaging.responder module¶
A message responder.
The responder is provided to message handlers to enable them to send a new message in response to the message being handled.
-
class
aries_cloudagent.messaging.responder.BaseResponder(*, connection_id: str = None, reply_session_id: str = None, reply_to_verkey: str = None)[source]¶ Bases:
abc.ABCInterface for message handlers to send responses.
-
create_outbound(message: Union[aries_cloudagent.messaging.agent_message.AgentMessage, str, bytes], *, connection_id: str = None, reply_session_id: str = None, reply_thread_id: str = None, reply_to_verkey: str = None, target: aries_cloudagent.connections.models.connection_target.ConnectionTarget = None, target_list: Sequence[aries_cloudagent.connections.models.connection_target.ConnectionTarget] = None, to_session_only: bool = False) → aries_cloudagent.transport.outbound.message.OutboundMessage[source]¶ Create an OutboundMessage from a message payload.
-
send(message: Union[aries_cloudagent.messaging.agent_message.AgentMessage, str, bytes], **kwargs)[source]¶ Convert a message to an OutboundMessage and send it.
-
send_outbound(message: aries_cloudagent.transport.outbound.message.OutboundMessage)[source]¶ Send an outbound message.
Parameters: message – The OutboundMessage to be sent
-
send_reply(message: Union[aries_cloudagent.messaging.agent_message.AgentMessage, str, bytes], *, connection_id: str = None, target: aries_cloudagent.connections.models.connection_target.ConnectionTarget = None, target_list: Sequence[aries_cloudagent.connections.models.connection_target.ConnectionTarget] = None)[source]¶ Send a reply to an incoming message.
Parameters: - message – the AgentMessage, or pre-packed str or bytes to reply with
- connection_id – optionally override the target connection ID
- target – optionally specify a ConnectionTarget to send to
Raises: ResponderError– If there is no active connection
-
-
class
aries_cloudagent.messaging.responder.MockResponder[source]¶ Bases:
aries_cloudagent.messaging.responder.BaseResponderMock responder implementation for use by tests.
-
send(message: Union[aries_cloudagent.messaging.agent_message.AgentMessage, str, bytes], **kwargs)[source]¶ Convert a message to an OutboundMessage and send it.
-
send_outbound(message: aries_cloudagent.transport.outbound.message.OutboundMessage)[source]¶ Send an outbound message.
-
-
exception
aries_cloudagent.messaging.responder.ResponderError(*args, error_code: str = None, **kwargs)[source]¶ Bases:
aries_cloudagent.core.error.BaseErrorResponder error.
aries_cloudagent.messaging.util module¶
Utils for messages.
-
aries_cloudagent.messaging.util.canon(raw_attr_name: str) → str[source]¶ Canonicalize input attribute name for indy proofs and credential offers.
Parameters: raw_attr_name – raw attribute name Returns: canonicalized attribute name
-
aries_cloudagent.messaging.util.datetime_to_str(dt: Union[str, datetime.datetime]) → str[source]¶ Convert a datetime object to an indy-standard datetime string.
Parameters: dt – May be a string or datetime to allow automatic conversion
-
aries_cloudagent.messaging.util.encode(orig: Any) → str[source]¶ Encode a credential value as an int.
Encode credential attribute value, purely stringifying any int32 and leaving numeric int32 strings alone, but mapping any other input to a stringified 256-bit (but not 32-bit) integer. Predicates in indy-sdk operate on int32 values properly only when their encoded values match their raw values.
Parameters: orig – original value to encode Returns: encoded value
-
aries_cloudagent.messaging.util.epoch_to_str(epoch: int) → str[source]¶ Convert epoch seconds to indy-standard datetime string.
Parameters: epoch – epoch seconds
-
aries_cloudagent.messaging.util.str_to_datetime(dt: Union[str, datetime.datetime]) → datetime.datetime[source]¶ Convert an indy-standard datetime string to a datetime.
Using a fairly lax regex pattern to match slightly different formats. In Python 3.7 datetime.fromisoformat might be used.
Parameters: dt – May be a string or datetime to allow automatic conversion
aries_cloudagent.messaging.valid module¶
Validators for schema fields.
-
class
aries_cloudagent.messaging.valid.Base58SHA256Hash[source]¶ Bases:
sphinx.ext.autodoc.importer._MockObjectValidate value against base58 encoding of SHA-256 hash.
-
EXAMPLE= 'H3C2AVvLMv6gmMNam3uVAjZpfkcJCwDwnZn6z3wXmqPV'¶
-
PATTERN= '^[<sphinx.ext.autodoc.importer._MockObject object>]{43,44}$'¶
-
-
class
aries_cloudagent.messaging.valid.Base64[source]¶ Bases:
sphinx.ext.autodoc.importer._MockObjectValidate base64 value.
-
EXAMPLE= 'ey4uLn0='¶
-
PATTERN= '^[a-zA-Z0-9+/]*={0,2}$'¶
-
-
class
aries_cloudagent.messaging.valid.Base64URL[source]¶ Bases:
sphinx.ext.autodoc.importer._MockObjectValidate base64 value.
-
EXAMPLE= 'ey4uLn0='¶
-
PATTERN= '^[-_a-zA-Z0-9]*={0,2}$'¶
-
-
class
aries_cloudagent.messaging.valid.Base64URLNoPad[source]¶ Bases:
sphinx.ext.autodoc.importer._MockObjectValidate base64 value.
-
EXAMPLE= 'ey4uLn0'¶
-
PATTERN= '^[-_a-zA-Z0-9]*$'¶
-
-
class
aries_cloudagent.messaging.valid.DIDKey[source]¶ Bases:
sphinx.ext.autodoc.importer._MockObjectValidate value against DID key specification.
-
EXAMPLE= 'did:key:z6MkpTHR8VNsBxYAAWHut2Geadd9jSwuBV8xRoAnwWsdvktH'¶
-
PATTERN= '^did:key:z[<sphinx.ext.autodoc.importer._MockObject object>]+$'¶
-
-
class
aries_cloudagent.messaging.valid.DIDPosture[source]¶ Bases:
sphinx.ext.autodoc.importer._MockObjectValidate value against defined DID postures.
-
EXAMPLE= 'wallet_only'¶
-
-
class
aries_cloudagent.messaging.valid.Endpoint[source]¶ Bases:
sphinx.ext.autodoc.importer._MockObjectValidate value against endpoint URL on any scheme.
-
EXAMPLE= 'https://myhost:8021'¶
-
PATTERN= '^[A-Za-z0-9\\.\\-\\+]+://([A-Za-z0-9][.A-Za-z0-9-]+[A-Za-z0-9])+(:[1-9][0-9]*)?(/[^?&#]+)?$'¶
-
-
class
aries_cloudagent.messaging.valid.EndpointType[source]¶ Bases:
sphinx.ext.autodoc.importer._MockObjectValidate value against allowed endpoint/service types.
-
EXAMPLE= 'Endpoint'¶
-
-
class
aries_cloudagent.messaging.valid.IndyCredDefId[source]¶ Bases:
sphinx.ext.autodoc.importer._MockObjectValidate value against indy credential definition identifier specification.
-
EXAMPLE= 'WgWxqztrNooG92RXvxSTWv:3:CL:20:tag'¶
-
PATTERN= '^([<sphinx.ext.autodoc.importer._MockObject object>]{21,22}):3:CL:(([1-9][0-9]*)|([<sphinx.ext.autodoc.importer._MockObject object>]{21,22}:2:.+:[0-9.]+)):(.+)?$'¶
-
-
class
aries_cloudagent.messaging.valid.IndyCredRevId[source]¶ Bases:
sphinx.ext.autodoc.importer._MockObjectValidate value against indy credential revocation identifier specification.
-
EXAMPLE= '12345'¶
-
PATTERN= '^[1-9][0-9]*$'¶
-
-
class
aries_cloudagent.messaging.valid.IndyDID[source]¶ Bases:
sphinx.ext.autodoc.importer._MockObjectValidate value against indy DID.
-
EXAMPLE= 'WgWxqztrNooG92RXvxSTWv'¶
-
PATTERN= '^(did:sov:)?[<sphinx.ext.autodoc.importer._MockObject object>]{21,22}$'¶
-
-
class
aries_cloudagent.messaging.valid.IndyExtraWQL[source]¶ Bases:
sphinx.ext.autodoc.importer._MockObjectValidate value as potential extra WQL query in cred search for proof req.
-
EXAMPLE= '{"0_drink_uuid": {"attr::drink::value": "martini"}}'¶
-
PATTERN= '^{\\s*".*?"\\s*:\\s*{.*?}\\s*(,\\s*".*?"\\s*:\\s*{.*?}\\s*)*\\s*}$'¶
-
-
class
aries_cloudagent.messaging.valid.IndyISO8601DateTime[source]¶ Bases:
sphinx.ext.autodoc.importer._MockObjectValidate value against ISO 8601 datetime format, indy profile.
-
EXAMPLE= '2021-02-25 23:41:27Z'¶
-
PATTERN= '^\\d{4}-\\d\\d-\\d\\d[T ]\\d\\d:\\d\\d(?:\\:(?:\\d\\d(?:\\.\\d{1,6})?))?(?:[+-]\\d\\d:?\\d\\d|Z|)$'¶
-
-
class
aries_cloudagent.messaging.valid.IndyPredicate[source]¶ Bases:
sphinx.ext.autodoc.importer._MockObjectValidate value against indy predicate.
-
EXAMPLE= '>='¶
-
-
class
aries_cloudagent.messaging.valid.IndyRawPublicKey[source]¶ Bases:
sphinx.ext.autodoc.importer._MockObjectValidate value against indy (Ed25519VerificationKey2018) raw public key.
-
EXAMPLE= 'H3C2AVvLMv6gmMNam3uVAjZpfkcJCwDwnZn6z3wXmqPV'¶
-
PATTERN= '^[<sphinx.ext.autodoc.importer._MockObject object>]{43,44}$'¶
-
-
class
aries_cloudagent.messaging.valid.IndyRevRegId[source]¶ Bases:
sphinx.ext.autodoc.importer._MockObjectValidate value against indy revocation registry identifier specification.
-
EXAMPLE= 'WgWxqztrNooG92RXvxSTWv:4:WgWxqztrNooG92RXvxSTWv:3:CL:20:tag:CL_ACCUM:0'¶
-
PATTERN= '^([<sphinx.ext.autodoc.importer._MockObject object>]{21,22}):4:([<sphinx.ext.autodoc.importer._MockObject object>]{21,22}):3:CL:(([1-9][0-9]*)|([<sphinx.ext.autodoc.importer._MockObject object>]{21,22}:2:.+:[0-9.]+))(:.+)?:CL_ACCUM:(.+$)'¶
-
-
class
aries_cloudagent.messaging.valid.IndyRevRegSize[source]¶ Bases:
sphinx.ext.autodoc.importer._MockObjectValidate value as indy revocation registry size.
-
EXAMPLE= 1000¶
-
-
class
aries_cloudagent.messaging.valid.IndySchemaId[source]¶ Bases:
sphinx.ext.autodoc.importer._MockObjectValidate value against indy schema identifier specification.
-
EXAMPLE= 'WgWxqztrNooG92RXvxSTWv:2:schema_name:1.0'¶
-
PATTERN= '^[<sphinx.ext.autodoc.importer._MockObject object>]{21,22}:2:.+:[0-9.]+$'¶
-
-
class
aries_cloudagent.messaging.valid.IndyVersion[source]¶ Bases:
sphinx.ext.autodoc.importer._MockObjectValidate value against indy version specification.
-
EXAMPLE= '1.0'¶
-
PATTERN= '^[0-9.]+$'¶
-
-
class
aries_cloudagent.messaging.valid.IndyWQL[source]¶ Bases:
sphinx.ext.autodoc.importer._MockObjectValidate value as potential WQL query.
-
EXAMPLE= '{"attr::name::value": "Alex"}'¶
-
PATTERN= '^{.*}$'¶
-
-
class
aries_cloudagent.messaging.valid.IntEpoch[source]¶ Bases:
sphinx.ext.autodoc.importer._MockObjectValidate value against (integer) epoch format.
-
EXAMPLE= 1614296487¶
-
-
class
aries_cloudagent.messaging.valid.JSONWebToken[source]¶ Bases:
sphinx.ext.autodoc.importer._MockObjectValidate JSON Web Token.
-
EXAMPLE= 'eyJhbGciOiJFZERTQSJ9.eyJhIjogIjAifQ.dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk'¶
-
PATTERN= '^[-_a-zA-Z0-9]*\\.[-_a-zA-Z0-9]*\\.[-_a-zA-Z0-9]*$'¶
-
-
class
aries_cloudagent.messaging.valid.JWSHeaderKid[source]¶ Bases:
sphinx.ext.autodoc.importer._MockObjectValidate value against JWS header kid.
-
EXAMPLE= 'did:sov:LjgpST2rjsoxYegQDRm7EL#keys-4'¶
-
PATTERN= '^did:(?:key:z[<sphinx.ext.autodoc.importer._MockObject object>]+|sov:[<sphinx.ext.autodoc.importer._MockObject object>]{21,22}(;.*)?(\\?.*)?#.+)$'¶
-
-
class
aries_cloudagent.messaging.valid.NaturalNumber[source]¶ Bases:
sphinx.ext.autodoc.importer._MockObjectValidate value as positive integer.
-
EXAMPLE= 10¶
-
-
class
aries_cloudagent.messaging.valid.NumericStrNatural[source]¶ Bases:
sphinx.ext.autodoc.importer._MockObjectValidate value against natural number numeric string.
-
EXAMPLE= '1'¶
-
PATTERN= '^[1-9][0-9]*$'¶
-
-
class
aries_cloudagent.messaging.valid.NumericStrWhole[source]¶ Bases:
sphinx.ext.autodoc.importer._MockObjectValidate value against whole number numeric string.
-
EXAMPLE= '0'¶
-
PATTERN= '^[0-9]*$'¶
-
-
class
aries_cloudagent.messaging.valid.SHA256Hash[source]¶ Bases:
sphinx.ext.autodoc.importer._MockObjectValidate (binhex-encoded) SHA256 value.
-
EXAMPLE= '617a48c7c8afe0521efdc03e5bb0ad9e655893e6b4b51f0e794d70fba132aacb'¶
-
PATTERN= '^[a-fA-F0-9+/]{64}$'¶
-
-
class
aries_cloudagent.messaging.valid.UUIDFour[source]¶ Bases:
sphinx.ext.autodoc.importer._MockObjectValidate UUID4: 8-4-4-4-12 hex digits, the 13th of which being 4.
-
EXAMPLE= '3fa85f64-5717-4562-b3fc-2c963f66afa6'¶
-
PATTERN= '[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-4[a-fA-F0-9]{3}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}'¶
-