aries_cloudagent.messaging.decorators package

Submodules

aries_cloudagent.messaging.decorators.attach_decorator module

A message decorator for attachments.

An attach decorator embeds content or specifies appended content.

class aries_cloudagent.messaging.decorators.attach_decorator.AttachDecorator(*, ident: Optional[str] = None, description: Optional[str] = None, filename: Optional[str] = None, mime_type: Optional[str] = None, lastmod_time: Optional[str] = None, byte_count: Optional[int] = None, data: AttachDecoratorData, **kwargs)[source]

Bases: BaseModel

Class representing attach decorator.

class Meta[source]

Bases: object

AttachDecorator metadata.

schema_class = 'AttachDecoratorSchema'
property content: Union[Mapping, Tuple[Sequence[str], str]]

Return attachment content.

Returns

data attachment, decoded if necessary and json-loaded, or data links and sha-256 hash.

classmethod data_base64(mapping: Mapping, *, ident: Optional[str] = None, description: Optional[str] = None, filename: Optional[str] = None, lastmod_time: Optional[str] = None, byte_count: Optional[int] = None)[source]

Create AttachDecorator instance on base64-encoded data from input mapping.

Given mapping, JSON dump, base64-encode, and embed it as data; mark application/json MIME type.

Parameters
  • mapping – (dict) data structure; e.g., indy production

  • ident – optional attachment identifier (default random UUID4)

  • description – optional attachment description

  • filename – optional attachment filename

  • lastmod_time – optional attachment last modification time

  • byte_count – optional attachment byte count

classmethod data_base64_string(content: str, *, ident: Optional[str] = None, description: Optional[str] = None, filename: Optional[str] = None, lastmod_time: Optional[str] = None, byte_count: Optional[int] = None)[source]

Create AttachDecorator instance on base64-encoded string data.

Given string content, base64-encode, and embed it as data; mark text/string MIME type.

Parameters
  • content – string content

  • ident – optional attachment identifier (default random UUID4)

  • description – optional attachment description

  • filename – optional attachment filename

  • lastmod_time – optional attachment last modification time

  • byte_count – optional attachment byte count

classmethod data_json(mapping: Union[Sequence[dict], dict], *, ident: Optional[str] = None, description: Optional[str] = None, filename: Optional[str] = None, lastmod_time: Optional[str] = None, byte_count: Optional[int] = None)[source]

Create AttachDecorator instance on json-encoded data from input mapping.

Given message object (dict), JSON dump, and embed it as data; mark application/json MIME type.

Parameters
  • mapping – (dict) data structure; e.g., Aries message

  • ident – optional attachment identifier (default random UUID4)

  • description – optional attachment description

  • filename – optional attachment filename

  • lastmod_time – optional attachment last modification time

  • byte_count – optional attachment byte count

Create AttachDecorator instance on json-encoded data from input mapping.

Given message object (dict), JSON dump, and embed it as data; mark application/json MIME type.

Parameters
  • links – URL or list of URLs

  • sha256 – optional sha-256 hash for content

  • ident – optional attachment identifier (default random UUID4)

  • mime_type – optional MIME type

  • description – optional attachment description

  • filename – optional attachment filename

  • lastmod_time – optional attachment last modification time

  • byte_count – optional attachment byte count

class aries_cloudagent.messaging.decorators.attach_decorator.AttachDecoratorData(*, jws_: Optional[AttachDecoratorDataJWS] = None, sha256_: Optional[str] = None, links_: Optional[Union[Sequence[str], str]] = None, base64_: Optional[str] = None, json_: Optional[Union[Sequence[dict], dict]] = None)[source]

Bases: BaseModel

Attach decorator data.

class Meta[source]

Bases: object

AttachDecoratorData metadata.

schema_class = 'AttachDecoratorDataSchema'
property base64

Accessor for base64 decorator data, or None.

header_map(idx: int = 0, jose: bool = True) Mapping[source]

Accessor for header info at input index, default 0 or unique for singly-signed.

Parameters
  • idx – index of interest, zero-based (default 0)

  • jose – True to return unprotected header attributes, False for protected only

property json

Accessor for json decorator data, or None.

property jws

Accessor for JWS, or None.

Accessor for links decorator data, or None.

property sha256

Accessor for sha256 decorator data, or None.

async sign(verkeys: Union[str, Sequence[str]], wallet: BaseWallet)[source]

Sign base64 data value of attachment.

Parameters
  • verkeys – verkey(s) of the signing party (in raw or DID key format)

  • wallet – The wallet to use for the signature

property signatures: int

Accessor for number of signatures.

property signed: bytes

Accessor for signed content (payload), None for unsigned.

async verify(wallet: BaseWallet, signer_verkey: Optional[str] = None) bool[source]

Verify the signature(s).

Parameters

wallet – Wallet to use to verify signature

Returns

True if verification succeeds else False

class aries_cloudagent.messaging.decorators.attach_decorator.AttachDecoratorData1JWS(*, header: AttachDecoratorDataJWSHeader, protected: Optional[str] = None, signature: str)[source]

Bases: BaseModel

Single Detached JSON Web Signature for inclusion in attach decorator data.

class Meta[source]

Bases: object

AttachDecoratorData1JWS metadata.

schema_class = 'AttachDecoratorData1JWSSchema'
class aries_cloudagent.messaging.decorators.attach_decorator.AttachDecoratorData1JWSSchema(*args: Any, **kwargs: Any)[source]

Bases: BaseModelSchema

Single attach decorator data JWS schema.

class Meta[source]

Bases: object

Single attach decorator data JWS schema metadata.

model_class

alias of AttachDecoratorData1JWS

header

alias of AttachDecoratorDataJWSHeaderSchema

class aries_cloudagent.messaging.decorators.attach_decorator.AttachDecoratorDataJWS(*, header: Optional[AttachDecoratorDataJWSHeader] = None, protected: Optional[str] = None, signature: Optional[str] = None, signatures: Optional[Sequence[AttachDecoratorData1JWS]] = None)[source]

Bases: BaseModel

Detached JSON Web Signature for inclusion in attach decorator data.

May hold one signature in flattened format, or multiple signatures in the “signatures” member.

class Meta[source]

Bases: object

AttachDecoratorDataJWS metadata.

schema_class = 'AttachDecoratorDataJWSSchema'
class aries_cloudagent.messaging.decorators.attach_decorator.AttachDecoratorDataJWSHeader(kid: str)[source]

Bases: BaseModel

Attach decorator data JWS header.

class Meta[source]

Bases: object

AttachDecoratorDataJWS metadata.

schema_class = 'AttachDecoratorDataJWSHeaderSchema'
class aries_cloudagent.messaging.decorators.attach_decorator.AttachDecoratorDataJWSHeaderSchema(*args: Any, **kwargs: Any)[source]

Bases: BaseModelSchema

Attach decorator data JWS header schema.

class Meta[source]

Bases: object

Attach decorator data schema metadata.

model_class

alias of AttachDecoratorDataJWSHeader

class aries_cloudagent.messaging.decorators.attach_decorator.AttachDecoratorDataJWSSchema(*args: Any, **kwargs: Any)[source]

Bases: BaseModelSchema

Schema for detached JSON Web Signature for inclusion in attach decorator data.

class Meta[source]

Bases: object

Metadata for schema for detached JWS for inclusion in attach deco data.

model_class

alias of AttachDecoratorDataJWS

header

alias of AttachDecoratorDataJWSHeaderSchema

validate_single_xor_multi_sig(data: Mapping, **kwargs)

Ensure model is for either 1 or many sigatures, not mishmash of both.

class aries_cloudagent.messaging.decorators.attach_decorator.AttachDecoratorDataSchema(*args: Any, **kwargs: Any)[source]

Bases: BaseModelSchema

Attach decorator data schema.

class Meta[source]

Bases: object

Attach decorator data schema metadata.

model_class

alias of AttachDecoratorData

jws_

alias of AttachDecoratorDataJWSSchema

validate_data_spec(data: Mapping, **kwargs)

Ensure model chooses exactly one of base64, json, or links.

class aries_cloudagent.messaging.decorators.attach_decorator.AttachDecoratorSchema(*args: Any, **kwargs: Any)[source]

Bases: BaseModelSchema

Attach decorator schema used in serialization/deserialization.

class Meta[source]

Bases: object

AttachDecoratorSchema metadata.

model_class

alias of AttachDecorator

data

alias of AttachDecoratorDataSchema

aries_cloudagent.messaging.decorators.attach_decorator.did_key(verkey: str) str[source]

Qualify verkey into DID key if need be.

aries_cloudagent.messaging.decorators.attach_decorator.raw_key(verkey: str) str[source]

Strip qualified key to raw key if need be.

aries_cloudagent.messaging.decorators.base module

Classes for managing a collection of decorators.

class aries_cloudagent.messaging.decorators.base.BaseDecoratorSet(models: Optional[dict] = None)[source]

Bases: OrderedDict

Collection of decorators.

add_model(key: str, model: Type[BaseModel])[source]

Add a registered decorator model.

copy() BaseDecoratorSet[source]

Return a copy of the decorator set.

extract_decorators(message: Mapping, schema: Optional[Type[marshmallow.Schema]] = None, serialized: bool = True, skip_attrs: Optional[Sequence[str]] = None) OrderedDict[source]

Extract decorators and return the remaining properties.

field(name: str) BaseDecoratorSet[source]

Access a named decorated field.

property fields: OrderedDict

Acessor for the set of currently defined fields.

has_field(name: str) bool[source]

Check for the existence of a named decorator field.

load_decorator(key: str, value, serialized=False)[source]

Convert a decorator value to its loaded representation.

property models: dict

Accessor for the models dictionary.

property prefix: str

Accessor for the decorator prefix.

remove_field(name: str)[source]

Remove a named decorated field.

remove_model(key: str)[source]

Remove a registered decorator model.

to_dict(prefix: Optional[str] = None) OrderedDict[source]

Convert to a dictionary (serialize).

Raises

BaseModelError – on decorator validation errors

exception aries_cloudagent.messaging.decorators.base.DecoratorError(*args, error_code: Optional[str] = None, **kwargs)[source]

Bases: BaseError

Base error for decorator issues.

aries_cloudagent.messaging.decorators.default module

Default decorator set implementation.

class aries_cloudagent.messaging.decorators.default.DecoratorSet(models: Optional[dict] = None)[source]

Bases: BaseDecoratorSet

Default decorator set implementation.

aries_cloudagent.messaging.decorators.localization_decorator module

The localization decorator (~l10n) for message localization information.

class aries_cloudagent.messaging.decorators.localization_decorator.LocalizationDecorator(*, locale: Optional[str] = None, localizable: Optional[Sequence[str]] = None, catalogs: Optional[Sequence[str]] = None)[source]

Bases: BaseModel

Class representing the localization decorator.

class Meta[source]

Bases: object

LocalizationDecorator metadata.

schema_class = 'LocalizationDecoratorSchema'
class aries_cloudagent.messaging.decorators.localization_decorator.LocalizationDecoratorSchema(*args: Any, **kwargs: Any)[source]

Bases: BaseModelSchema

Localization decorator schema used in serialization/deserialization.

class Meta[source]

Bases: object

LocalizationDecoratorSchema metadata.

model_class

alias of LocalizationDecorator

aries_cloudagent.messaging.decorators.please_ack_decorator module

The please-ack decorator to request acknowledgement.

class aries_cloudagent.messaging.decorators.please_ack_decorator.PleaseAckDecorator(message_id: Optional[str] = None, on: Optional[Sequence[str]] = None)[source]

Bases: BaseModel

Class representing the please-ack decorator.

class Meta[source]

Bases: object

PleaseAckDecorator metadata.

schema_class = 'PleaseAckDecoratorSchema'
class aries_cloudagent.messaging.decorators.please_ack_decorator.PleaseAckDecoratorSchema(*args: Any, **kwargs: Any)[source]

Bases: BaseModelSchema

PleaseAck decorator schema used in serialization/deserialization.

class Meta[source]

Bases: object

PleaseAckDecoratorSchema metadata.

model_class

alias of PleaseAckDecorator

aries_cloudagent.messaging.decorators.service_decorator module

A message decorator for services.

A service decorator adds routing information to a message so agent can respond without needing to perform a handshake.

class aries_cloudagent.messaging.decorators.service_decorator.ServiceDecorator(*, endpoint: str, recipient_keys: List[str], routing_keys: Optional[List[str]] = None)[source]

Bases: BaseModel

Class representing service decorator.

class Meta[source]

Bases: object

ServiceDecorator metadata.

schema_class = 'ServiceDecoratorSchema'
property endpoint

Accessor for service endpoint.

Returns

This service’s serviceEndpoint

property recipient_keys

Accessor for recipient keys.

Returns

This service’s recipientKeys

property routing_keys

Accessor for routing keys.

Returns

This service’s routingKeys

class aries_cloudagent.messaging.decorators.service_decorator.ServiceDecoratorSchema(*args: Any, **kwargs: Any)[source]

Bases: BaseModelSchema

Thread decorator schema used in serialization/deserialization.

class Meta[source]

Bases: object

ServiceDecoratorSchema metadata.

model_class

alias of ServiceDecorator

aries_cloudagent.messaging.decorators.signature_decorator module

Model and schema for working with field signatures within message bodies.

class aries_cloudagent.messaging.decorators.signature_decorator.SignatureDecorator(*, signature_type: Optional[str] = None, signature: Optional[str] = None, sig_data: Optional[str] = None, signer: Optional[str] = None)[source]

Bases: BaseModel

Class representing a field value signed by a known verkey.

class Meta[source]

Bases: object

SignatureDecorator metadata.

schema_class = 'SignatureDecoratorSchema'
TYPE_ED25519SHA512 = 'signature/1.0/ed25519Sha512_single'
async classmethod create(value, signer: str, wallet: BaseWallet, timestamp=None) SignatureDecorator[source]

Create a Signature.

Sign a field value and return a newly constructed SignatureDecorator representing the resulting signature.

Parameters
  • value – Value to sign

  • signer – Verkey of the signing party

  • wallet – The wallet to use for the signature

Returns

The created SignatureDecorator object

decode() -> (<class 'object'>, <class 'int'>)[source]

Decode the signature to its timestamp and value.

Returns

A tuple of (decoded message, timestamp)

async verify(wallet: BaseWallet) bool[source]

Verify the signature against the signer’s public key.

Parameters

wallet – Wallet to use to verify signature

Returns

True if verification succeeds else False

class aries_cloudagent.messaging.decorators.signature_decorator.SignatureDecoratorSchema(*args: Any, **kwargs: Any)[source]

Bases: BaseModelSchema

SignatureDecorator schema.

class Meta[source]

Bases: object

SignatureDecoratorSchema metadata.

model_class

alias of SignatureDecorator

aries_cloudagent.messaging.decorators.thread_decorator module

A message decorator for threads.

A thread decorator identifies a message that may require additional context from previous messages.

class aries_cloudagent.messaging.decorators.thread_decorator.ThreadDecorator(*, thid: Optional[str] = None, pthid: Optional[str] = None, sender_order: Optional[int] = None, received_orders: Optional[Mapping] = None)[source]

Bases: BaseModel

Class representing thread decorator.

class Meta[source]

Bases: object

ThreadDecorator metadata.

schema_class = 'ThreadDecoratorSchema'
property pthid

Accessor for parent thread identifier.

Returns

This thread’s pthid

property received_orders: dict

Get received orders.

Returns

The highest sender_order value that the sender has seen from other sender(s) on the thread.

property sender_order: int

Get sender order.

Returns

A number that tells where this message fits in the sequence of all messages that the current sender has contributed to this thread

property thid

Accessor for thread identifier.

Returns

This thread’s thid

class aries_cloudagent.messaging.decorators.thread_decorator.ThreadDecoratorSchema(*args: Any, **kwargs: Any)[source]

Bases: BaseModelSchema

Thread decorator schema used in serialization/deserialization.

class Meta[source]

Bases: object

ThreadDecoratorSchema metadata.

model_class

alias of ThreadDecorator

aries_cloudagent.messaging.decorators.timing_decorator module

The timing decorator (~timing).

This decorator allows the timing of agent messages to be communicated and constrained.

class aries_cloudagent.messaging.decorators.timing_decorator.TimingDecorator(*, in_time: Optional[Union[str, datetime]] = None, out_time: Optional[Union[str, datetime]] = None, stale_time: Optional[Union[str, datetime]] = None, expires_time: Optional[Union[str, datetime]] = None, delay_milli: Optional[int] = None, wait_until_time: Optional[Union[str, datetime]] = None)[source]

Bases: BaseModel

Class representing the timing decorator.

class Meta[source]

Bases: object

TimingDecorator metadata.

schema_class = 'TimingDecoratorSchema'
class aries_cloudagent.messaging.decorators.timing_decorator.TimingDecoratorSchema(*args: Any, **kwargs: Any)[source]

Bases: BaseModelSchema

Timing decorator schema used in serialization/deserialization.

class Meta[source]

Bases: object

TimingDecoratorSchema metadata.

model_class

alias of TimingDecorator

aries_cloudagent.messaging.decorators.trace_decorator module

A message decorator for trace events.

A trace decorator identifies a responsibility on the processor to record information on message processing events.

class aries_cloudagent.messaging.decorators.trace_decorator.TraceDecorator(*, target: Optional[str] = None, full_thread: bool = True, trace_reports: Optional[Sequence] = None)[source]

Bases: BaseModel

Class representing trace decorator.

class Meta[source]

Bases: object

TraceDecorator metadata.

schema_class = 'TraceDecoratorSchema'
append_trace_report(trace_report: TraceReport)[source]

Append a trace report to this decorator.

property full_thread

Accessor for full_thread flag.

Returns

The full_thread flag

property target

Accessor for trace target.

Returns

The target for tracing messages

property trace_reports

Set of trace reports for this message.

Returns

The trace reports that have been logged on this message/thread so far. (Only for target=”message”.)

class aries_cloudagent.messaging.decorators.trace_decorator.TraceDecoratorSchema(*args: Any, **kwargs: Any)[source]

Bases: BaseModelSchema

Trace decorator schema used in serialization/deserialization.

class Meta[source]

Bases: object

TraceDecoratorSchema metadata.

model_class

alias of TraceDecorator

class aries_cloudagent.messaging.decorators.trace_decorator.TraceReport(*, msg_id: Optional[str] = None, thread_id: Optional[str] = None, traced_type: Optional[str] = None, timestamp: Optional[str] = None, str_time: Optional[str] = None, handler: Optional[str] = None, ellapsed_milli: Optional[int] = None, outcome: Optional[str] = None)[source]

Bases: BaseModel

Class representing a Trace Report.

class Meta[source]

Bases: object

TraceReport metadata.

schema_class = 'TraceReport'
property ellapsed_milli

Accessor for ellapsed_milli.

Returns

The sender ellapsed_milli

property handler

Accessor for handler.

Returns

The sender handler

property msg_id

Accessor for msg_id.

Returns

The msg_id

property outcome

Accessor for outcome.

Returns

The sender outcome

property str_time

Accessor for str_time.

Returns

Formatted representation of the sender timestamp

property thread_id

Accessor for thread_id.

Returns

The thread_id

property timestamp

Accessor for timestamp.

Returns

The sender timestamp

property traced_type

Accessor for traced_type.

Returns

The sender traced_type

class aries_cloudagent.messaging.decorators.trace_decorator.TraceReportSchema(*args: Any, **kwargs: Any)[source]

Bases: BaseModelSchema

Trace report schema.

class Meta[source]

Bases: object

TraceReportSchema metadata.

model_class

alias of TraceReport

aries_cloudagent.messaging.decorators.transport_decorator module

The transport decorator (~transport).

This decorator allows changes to agent response behaviour and queue status updates.

class aries_cloudagent.messaging.decorators.transport_decorator.TransportDecorator(*, return_route: Optional[str] = None, return_route_thread: Optional[str] = None, queued_message_count: Optional[int] = None)[source]

Bases: BaseModel

Class representing the transport decorator.

class Meta[source]

Bases: object

TransportDecorator metadata.

schema_class = 'TransportDecoratorSchema'
class aries_cloudagent.messaging.decorators.transport_decorator.TransportDecoratorSchema(*args: Any, **kwargs: Any)[source]

Bases: BaseModelSchema

Transport decorator schema used in serialization/deserialization.

class Meta[source]

Bases: object

TransportDecoratorSchema metadata.

model_class

alias of TransportDecorator