From a0cd8d85925b5bac84fc4e36dd1c9eb9a581ffd6 Mon Sep 17 00:00:00 2001 From: jamshale Date: Fri, 28 Jun 2024 20:13:19 +0000 Subject: [PATCH] Update documentation and implement rule D417 Signed-off-by: jamshale --- aries_cloudagent/admin/request_context.py | 5 +- aries_cloudagent/admin/server.py | 23 +++-- aries_cloudagent/anoncreds/base.py | 14 ++- aries_cloudagent/anoncreds/holder.py | 15 ++- aries_cloudagent/anoncreds/issuer.py | 16 +++- .../anoncreds/models/anoncreds_cred_def.py | 5 + .../anoncreds/models/anoncreds_revocation.py | 7 ++ .../anoncreds/models/anoncreds_schema.py | 3 + aries_cloudagent/anoncreds/verifier.py | 3 +- aries_cloudagent/config/base.py | 7 +- aries_cloudagent/config/injection_context.py | 9 +- aries_cloudagent/config/injector.py | 14 ++- aries_cloudagent/config/logging.py | 30 ++++-- aries_cloudagent/connections/base_manager.py | 91 +++++++++++++------ .../connections/models/conn_record.py | 6 ++ .../connections/models/connection_target.py | 3 +- aries_cloudagent/core/conductor.py | 9 +- aries_cloudagent/core/dispatcher.py | 10 +- aries_cloudagent/core/profile.py | 20 ++-- aries_cloudagent/core/protocol_registry.py | 14 +-- aries_cloudagent/indy/credx/holder.py | 28 ++++-- aries_cloudagent/indy/credx/issuer.py | 25 ++--- aries_cloudagent/indy/holder.py | 20 ++-- aries_cloudagent/indy/issuer.py | 15 +-- aries_cloudagent/indy/models/cred_abstract.py | 1 + .../indy/models/non_rev_interval.py | 1 + aries_cloudagent/indy/models/pres_preview.py | 5 +- aries_cloudagent/indy/models/proof_request.py | 14 ++- aries_cloudagent/indy/models/xform.py | 3 +- aries_cloudagent/indy/verifier.py | 6 +- aries_cloudagent/ledger/base.py | 61 ++++++++++--- aries_cloudagent/ledger/error.py | 3 + aries_cloudagent/ledger/indy_vdr.py | 8 +- .../multiple_ledger/indy_vdr_manager.py | 12 ++- aries_cloudagent/messaging/agent_message.py | 10 +- .../credential_definitions/routes.py | 1 + .../messaging/decorators/attach_decorator.py | 3 + .../decorators/signature_decorator.py | 2 + aries_cloudagent/messaging/models/base.py | 11 ++- .../messaging/models/base_record.py | 5 +- aries_cloudagent/messaging/request_context.py | 9 +- aries_cloudagent/messaging/responder.py | 2 + aries_cloudagent/multitenant/admin/routes.py | 1 + .../multitenant/askar_profile_manager.py | 4 +- aries_cloudagent/multitenant/base.py | 1 + aries_cloudagent/multitenant/manager.py | 1 + .../actionmenu/v1_0/messages/menu.py | 1 + .../actionmenu/v1_0/messages/perform.py | 1 + .../v1_0/messages/basicmessage.py | 1 + .../protocols/connections/v1_0/manager.py | 25 ++++- .../v1_0/messages/connection_invitation.py | 2 + .../v1_0/messages/connection_request.py | 2 + .../v1_0/messages/connection_response.py | 2 +- .../v1_0/messages/problem_report.py | 3 +- .../v1_0/models/connection_detail.py | 7 ++ .../coordinate_mediation/v1_0/manager.py | 3 + .../v1_0/messages/inner/keylist_key.py | 1 + .../messages/inner/keylist_query_paginate.py | 1 + .../messages/inner/keylist_update_rule.py | 1 + .../v1_0/messages/inner/keylist_updated.py | 1 + .../v1_0/messages/keylist.py | 1 + .../v1_0/messages/keylist_query.py | 1 + .../v1_0/messages/keylist_update.py | 1 + .../v1_0/messages/keylist_update_response.py | 3 +- .../v1_0/messages/mediate_grant.py | 1 + .../v1_0/models/mediation_record.py | 2 + .../v1_0/messages/problem_report.py | 1 + .../protocols/didexchange/v1_0/manager.py | 47 +++++++--- .../didexchange/v1_0/messages/request.py | 1 + .../didexchange/v1_0/messages/response.py | 4 + .../discovery/v1_0/messages/disclose.py | 1 + .../discovery/v1_0/messages/query.py | 3 +- .../discovery/v2_0/messages/disclosures.py | 1 + .../discovery/v2_0/messages/queries.py | 4 +- .../endorse_transaction/v1_0/manager.py | 31 ++++++- .../v1_0/messages/cancel_transaction.py | 1 + .../messages/endorsed_transaction_response.py | 2 + .../v1_0/messages/messages_attach.py | 2 + .../messages/refused_transaction_response.py | 1 + .../messages/transaction_acknowledgement.py | 2 + .../v1_0/messages/transaction_job_to_send.py | 1 + .../v1_0/messages/transaction_request.py | 2 + .../v1_0/messages/transaction_resend.py | 1 + .../v0_1/messages/forward_invitation.py | 1 + .../introduction/v0_1/messages/invitation.py | 1 + .../v0_1/messages/invitation_request.py | 1 + .../issue_credential/v1_0/manager.py | 15 ++- .../v1_0/messages/credential_issue.py | 1 + .../v1_0/messages/credential_offer.py | 1 + .../messages/credential_problem_report.py | 5 +- .../v1_0/messages/credential_proposal.py | 1 + .../v1_0/messages/credential_request.py | 3 +- .../v1_0/messages/inner/credential_preview.py | 2 + .../v1_0/models/credential_exchange.py | 3 +- .../issue_credential/v2_0/__init__.py | 4 +- .../v2_0/formats/vc_di/models/cred.py | 7 +- .../v2_0/formats/vc_di/models/cred_offer.py | 16 ++-- .../issue_credential/v2_0/manager.py | 38 +++++--- .../v2_0/messages/cred_issue.py | 5 +- .../v2_0/messages/cred_offer.py | 1 + .../v2_0/messages/cred_problem_report.py | 3 +- .../v2_0/messages/cred_proposal.py | 3 +- .../v2_0/messages/cred_request.py | 11 ++- .../v2_0/messages/inner/cred_preview.py | 2 + .../v2_0/models/cred_ex_record.py | 3 +- .../protocols/issue_credential/v2_0/routes.py | 1 + .../notification/v1_0/messages/ack.py | 1 + .../protocols/out_of_band/v1_0/manager.py | 53 +++++++---- .../out_of_band/v1_0/messages/invitation.py | 20 +++- .../out_of_band/v1_0/messages/service.py | 6 +- .../present_proof/dif/pres_exch_handler.py | 13 ++- .../protocols/present_proof/v1_0/manager.py | 9 +- .../v1_0/messages/presentation.py | 6 +- .../v1_0/messages/presentation_ack.py | 2 + .../messages/presentation_problem_report.py | 4 +- .../v1_0/messages/presentation_proposal.py | 1 + .../v1_0/messages/presentation_request.py | 3 +- .../v1_0/models/presentation_exchange.py | 3 +- .../present_proof/v2_0/formats/dif/handler.py | 13 +-- .../protocols/present_proof/v2_0/manager.py | 49 +++++----- .../present_proof/v2_0/messages/pres.py | 9 +- .../present_proof/v2_0/messages/pres_ack.py | 2 + .../v2_0/messages/pres_problem_report.py | 2 +- .../v2_0/messages/pres_proposal.py | 1 + .../v2_0/messages/pres_request.py | 11 ++- .../v2_0/models/pres_exchange.py | 3 +- .../protocols/present_proof/v2_0/routes.py | 3 + .../protocols/problem_report/v1_0/message.py | 2 + .../routing/v1_0/messages/forward.py | 3 +- .../routing/v1_0/models/route_record.py | 3 +- .../protocols/trustping/v1_0/messages/ping.py | 1 + .../trustping/v1_0/messages/ping_response.py | 1 + aries_cloudagent/resolver/base.py | 8 +- aries_cloudagent/revocation/indy.py | 9 +- aries_cloudagent/revocation/manager.py | 65 ++++++++++--- aries_cloudagent/revocation/models/indy.py | 1 + .../models/issuer_rev_reg_record.py | 2 + .../revocation_anoncreds/manager.py | 55 +++++++++-- aries_cloudagent/storage/askar.py | 1 + aries_cloudagent/storage/vc_holder/askar.py | 7 +- .../storage/vc_holder/in_memory.py | 36 +++++--- aries_cloudagent/tails/base.py | 4 +- aries_cloudagent/transport/inbound/base.py | 13 ++- aries_cloudagent/transport/inbound/http.py | 1 + aries_cloudagent/transport/inbound/receipt.py | 2 +- aries_cloudagent/transport/inbound/ws.py | 2 +- aries_cloudagent/transport/outbound/base.py | 4 +- aries_cloudagent/transport/outbound/http.py | 3 +- .../transport/outbound/manager.py | 25 ++--- aries_cloudagent/transport/outbound/ws.py | 2 +- aries_cloudagent/utils/tracing.py | 18 +++- aries_cloudagent/vc/ld_proofs/check.py | 4 +- aries_cloudagent/wallet/askar.py | 35 ++++--- aries_cloudagent/wallet/base.py | 38 ++++++-- aries_cloudagent/wallet/bbs.py | 24 +++-- aries_cloudagent/wallet/crypto.py | 45 ++++----- aries_cloudagent/wallet/routes.py | 67 +++++++++++--- pyproject.toml | 2 +- 158 files changed, 1108 insertions(+), 438 deletions(-) diff --git a/aries_cloudagent/admin/request_context.py b/aries_cloudagent/admin/request_context.py index 215a64f3bb..8d88bc539f 100644 --- a/aries_cloudagent/admin/request_context.py +++ b/aries_cloudagent/admin/request_context.py @@ -5,10 +5,10 @@ from typing import Mapping, Optional, Type -from ..core.profile import Profile, ProfileSession -from ..config.injector import Injector, InjectionError, InjectType from ..config.injection_context import InjectionContext +from ..config.injector import InjectionError, Injector, InjectType from ..config.settings import Settings +from ..core.profile import Profile, ProfileSession from ..utils.classloader import DeferLoad IN_MEM = DeferLoad("aries_cloudagent.core.in_memory.InMemoryProfile") @@ -78,6 +78,7 @@ def inject( Args: cls: The base class to retrieve an instance of + base_cls: The base class to retrieve an instance of settings: An optional mapping providing configuration to the provider Returns: diff --git a/aries_cloudagent/admin/server.py b/aries_cloudagent/admin/server.py index eb755c14a6..36ad7944e4 100644 --- a/aries_cloudagent/admin/server.py +++ b/aries_cloudagent/admin/server.py @@ -80,7 +80,9 @@ def __init__( """Initialize an instance of `AdminResponder`. Args: - send: Function to send outbound message + profile (Profile): The profile for this responder. + send (Coroutine): Function to send outbound message. + **kwargs: Additional keyword arguments. """ super().__init__(**kwargs) @@ -98,6 +100,7 @@ async def send_outbound( Args: message: The `OutboundMessage` to be sent + **kwargs: Additional keyword arguments """ profile = self._profile() if not profile: @@ -227,14 +230,16 @@ def __init__( """Initialize an AdminServer instance. Args: - host: Host to listen on - port: Port to listen on - context: The application context instance - outbound_message_router: Coroutine for delivering outbound messages - webhook_router: Callable for delivering webhooks - conductor_stop: Conductor (graceful) stop for shutdown API call - task_queue: An optional task queue for handlers - conductor_stats: Conductor statistics API call + host (str): The host to listen on. + port (int): The port to listen on. + context (InjectionContext): The application context instance. + root_profile (Profile): The root profile. + outbound_message_router (Coroutine): Coroutine for delivering + outbound messages. + webhook_router (Callable): Callable for delivering webhooks. + conductor_stop (Coroutine): Conductor (graceful) stop for shutdown API call. + task_queue (TaskQueue, optional): An optional task queue for handlers. + conductor_stats (Coroutine, optional): Conductor statistics API call. """ self.app = None self.admin_api_key = context.settings.get("admin.admin_api_key") diff --git a/aries_cloudagent/anoncreds/base.py b/aries_cloudagent/anoncreds/base.py index 2e0fc87c34..7088cc69e5 100644 --- a/aries_cloudagent/anoncreds/base.py +++ b/aries_cloudagent/anoncreds/base.py @@ -53,9 +53,11 @@ def __init__( """Initialize an instance. Args: - message: Message - obj_id: Object ID - obj: Generic Object + message (str): The message associated with the instance. + obj_id (str): The ID of the object. + obj (T, optional): The generic object associated with the instance. + *args: Variable length argument list. + **kwargs: Arbitrary keyword arguments. """ super().__init__(message, obj_id, obj, *args, **kwargs) self._message = message @@ -124,7 +126,11 @@ async def get_revocation_registry_definition( @abstractmethod async def get_revocation_list( - self, profile: Profile, revocation_registry_id: str, timestamp: int + self, + profile: Profile, + revocation_registry_id: str, + timestamp_from: Optional[int] = 0, + timestamp_to: Optional[int] = None, ) -> GetRevListResult: """Get a revocation list from the registry.""" diff --git a/aries_cloudagent/anoncreds/holder.py b/aries_cloudagent/anoncreds/holder.py index 2c08bbf188..caa599de38 100644 --- a/aries_cloudagent/anoncreds/holder.py +++ b/aries_cloudagent/anoncreds/holder.py @@ -479,11 +479,18 @@ async def _get_credential(self, credential_id: str) -> Credential: async def credential_revoked( self, ledger: BaseLedger, credential_id: str, fro: int = None, to: int = None ) -> bool: - """Check ledger for revocation status of credential by cred id. + """Check ledger for revocation status of credential by credential id. Args: - credential_id: Credential id to check + ledger (BaseLedger): The ledger to check for revocation status. + credential_id (str): The ID of the credential to check. + fro (int, optional): The earliest timestamp to consider for revocation status. + Defaults to None. + to (int, optional): The latest timestamp to consider for revocation status. + Defaults to None. + Returns: + bool: True if the credential is revoked, False otherwise. """ cred = await self._get_credential(credential_id) rev_reg_id = cred.rev_reg_id @@ -652,8 +659,8 @@ async def create_revocation_state( Args: cred_rev_id: credential revocation id in revocation registry rev_reg_def: revocation registry definition - rev_reg_delta: revocation delta - timestamp: delta timestamp + rev_list: revocation registry + tails_file_path: path to tails file Returns: the revocation state diff --git a/aries_cloudagent/anoncreds/issuer.py b/aries_cloudagent/anoncreds/issuer.py index 78bc65f0d2..513b3dc573 100644 --- a/aries_cloudagent/anoncreds/issuer.py +++ b/aries_cloudagent/anoncreds/issuer.py @@ -172,13 +172,19 @@ async def create_and_register_schema( """Create a new credential schema and store it in the wallet. Args: - issuer_id: the DID issuing the credential definition - name: the schema name - version: the schema version - attr_names: a sequence of schema attribute names + issuer_id (str): The DID issuing the credential definition. + name (str): The schema name. + version (str): The schema version. + attr_names (Sequence[str]): A sequence of schema attribute names. + options (Optional[dict]): Additional options for schema creation. + Defaults to None. Returns: - A SchemaResult instance + SchemaResult: An instance of SchemaResult. + + Raises: + AnonCredsSchemaAlreadyExists: If a similar schema already exists in + the records. """ options = options or {} diff --git a/aries_cloudagent/anoncreds/models/anoncreds_cred_def.py b/aries_cloudagent/anoncreds/models/anoncreds_cred_def.py index a194973e01..17d41098e7 100644 --- a/aries_cloudagent/anoncreds/models/anoncreds_cred_def.py +++ b/aries_cloudagent/anoncreds/models/anoncreds_cred_def.py @@ -43,6 +43,7 @@ def __init__(self, n: str, s: str, r: dict, rctxt: str, z: str, **kwargs): z: is equal to s^(xz), where xz is a randomly selected integer between 2 and p'q'-1. This makes up part of the CL-RSA public key, independent of the message blocks being signed. + kwargs: Keyword arguments """ super().__init__(**kwargs) self.n = n @@ -172,6 +173,7 @@ def __init__( Args: primary: Cred Def value primary revocation: Cred Def value revocation + kwargs: Keyword arguments """ super().__init__(**kwargs) self.primary = primary @@ -223,6 +225,7 @@ def __init__( type: Type tag: Tag value: Cred Def value + kwargs: Keyword arguments """ super().__init__(**kwargs) self.issuer_id = issuer_id @@ -362,6 +365,7 @@ def __init__( credential_definition_state: Cred Def state registration_metadata: Registration metadata credential_definition_metadata: Cred Def metadata + kwargs: Keyword arguments """ super().__init__(**kwargs) self.job_id = job_id @@ -409,6 +413,7 @@ def __init__( credential_definition: Cred Def resolution_metadata: Resolution metadata credential_definition_metadata: Cred Def metadata + kwargs: Keyword arguments """ super().__init__(**kwargs) self.credential_definition_id = credential_definition_id diff --git a/aries_cloudagent/anoncreds/models/anoncreds_revocation.py b/aries_cloudagent/anoncreds/models/anoncreds_revocation.py index 4ee1be85a6..85cf81db50 100644 --- a/aries_cloudagent/anoncreds/models/anoncreds_revocation.py +++ b/aries_cloudagent/anoncreds/models/anoncreds_revocation.py @@ -41,6 +41,7 @@ def __init__( max_cred_num: Max. number of Creds tails_location: Tails file location tails_hash: Tails file hash + kwargs: Keyword arguments """ super().__init__(**kwargs) self.public_keys = public_keys @@ -99,6 +100,7 @@ def __init__( cred_def_id: Cred Def ID tag: Tag value: Rev Reg Def Value + kwargs: Keyword arguments """ super().__init__(**kwargs) self.issuer_id = issuer_id @@ -238,6 +240,7 @@ def __init__( revocation_registry_definition_state: Rev Reg Def state registration_metadata: Registration metadata revocation_registry_definition_metadata: Rev Reg Def metadata + kwargs: Keyword arguments """ super().__init__(**kwargs) self.job_id = job_id @@ -299,6 +302,7 @@ def __init__( revocation_registry_id: Revocation Registry ID resolution_metadata: Resolution metadata revocation_registry_metadata: Revocation Registry metadata + kwargs: Keyword arguments """ super().__init__(**kwargs) self.revocation_registry = revocation_registry @@ -347,6 +351,7 @@ def __init__( revocation_list: Revocation list current_accumulator: Current accumulator timestamp: Timestamp + kwargs: Keyword arguments """ super().__init__(**kwargs) self.issuer_id = issuer_id @@ -487,6 +492,7 @@ def __init__( revocation_list_state: Revocation list state registration_metadata: Registration metadata revocation_list_metadata: Revocation list metadata + kwargs: Keyword arguments """ super().__init__(**kwargs) self.job_id = job_id @@ -537,6 +543,7 @@ def __init__( revocation_list: Revocation list resolution_metadata: Resolution metadata revocation_registry_metadata: Rev Reg metadata + kwargs: Keyword arguments """ super().__init__(**kwargs) self.revocation_list = revocation_list diff --git a/aries_cloudagent/anoncreds/models/anoncreds_schema.py b/aries_cloudagent/anoncreds/models/anoncreds_schema.py index bc2a6884e7..1357a79e0a 100644 --- a/aries_cloudagent/anoncreds/models/anoncreds_schema.py +++ b/aries_cloudagent/anoncreds/models/anoncreds_schema.py @@ -28,6 +28,7 @@ def __init__( attr_names: Schema Attribute Name list name: Schema name version: Schema version + kwargs: Addiiotnal keyword arguments """ super().__init__(**kwargs) self.issuer_id = issuer_id @@ -100,6 +101,7 @@ def __init__( schema_id: Schema ID resolution_metadata: Resolution Metdata schema_metadata: Schema Metadata + kwargs: Additional keyword arguments """ super().__init__(**kwargs) self.schema_value = schema @@ -212,6 +214,7 @@ def __init__( schema_state: Schema state registration_metadata: Registration Metdata schema_metadata: Schema Metadata + kwargs: Additional keyword arguments """ super().__init__(**kwargs) self.job_id = job_id diff --git a/aries_cloudagent/anoncreds/verifier.py b/aries_cloudagent/anoncreds/verifier.py index f320d82013..3e9edd5448 100644 --- a/aries_cloudagent/anoncreds/verifier.py +++ b/aries_cloudagent/anoncreds/verifier.py @@ -50,7 +50,7 @@ def non_revoc_intervals(self, pres_req: dict, pres: dict, cred_defs: dict) -> li Args: pres_req: presentation request pres: corresponding presentation - + cred_defs: credential definitions by cred def id """ msgs = [] for req_proof_key, pres_key in { @@ -453,6 +453,7 @@ async def verify_presentation( credential_definitions: credential definition data rev_reg_defs: revocation registry definitions rev_reg_entries: revocation registry entries + rev_lists: revocation lists """ msgs = [] diff --git a/aries_cloudagent/config/base.py b/aries_cloudagent/config/base.py index 8494c758c1..644fbfd9e4 100644 --- a/aries_cloudagent/config/base.py +++ b/aries_cloudagent/config/base.py @@ -123,11 +123,12 @@ def inject( """Get the provided instance of a given class identifier. Args: - cls: The base class to retrieve an instance of - settings: An optional mapping providing configuration to the provider + base_cls (Type[InjectType]): The base class to retrieve an instance of. + settings (Optional[Mapping[str, Any]]): An optional mapping providing + configuration to the provider. Returns: - An instance of the base class, or None + InjectType: An instance of the base class, or None. """ diff --git a/aries_cloudagent/config/injection_context.py b/aries_cloudagent/config/injection_context.py index bdd91de149..0ba68d63a8 100644 --- a/aries_cloudagent/config/injection_context.py +++ b/aries_cloudagent/config/injection_context.py @@ -1,7 +1,7 @@ """Injection context implementation.""" -from collections import namedtuple import copy +from collections import namedtuple from typing import Mapping, Optional, Type from .base import BaseInjector, InjectionError @@ -81,11 +81,12 @@ def inject( """Get the provided instance of a given class identifier. Args: - cls: The base class to retrieve an instance of - settings: An optional mapping providing configuration to the provider + base_cls (Type[InjectType]): The base class to retrieve an instance of. + settings (Optional[Mapping[str, object]]): An optional mapping providing + configuration to the provider. Returns: - An instance of the base class, or None + InjectType: An instance of the base class, or None. """ return self.injector.inject(base_cls, settings) diff --git a/aries_cloudagent/config/injector.py b/aries_cloudagent/config/injector.py index 26130623db..1bcd6fea9c 100644 --- a/aries_cloudagent/config/injector.py +++ b/aries_cloudagent/config/injector.py @@ -2,8 +2,8 @@ from typing import Dict, Mapping, Optional, Type -from .base import BaseProvider, BaseInjector, InjectionError, InjectType -from .provider import InstanceProvider, CachedProvider +from .base import BaseInjector, BaseProvider, InjectionError, InjectType +from .provider import CachedProvider, InstanceProvider from .settings import Settings @@ -118,11 +118,15 @@ def inject( """Get the provided instance of a given class identifier. Args: - cls: The base class to retrieve an instance of - params: An optional dict providing configuration to the provider + base_cls (Type[InjectType]): The base class to retrieve an instance of. + settings (Optional[Mapping[str, object]]): An optional dictionary providing + configuration to the provider. Returns: - An instance of the base class, or None + InjectType: An instance of the base class, or None. + + Raises: + InjectionError: If no instance is provided for the given class identifier. """ result = self.inject_or(base_cls, settings) diff --git a/aries_cloudagent/config/logging.py b/aries_cloudagent/config/logging.py index 7af8366ebe..7cb55ec829 100644 --- a/aries_cloudagent/config/logging.py +++ b/aries_cloudagent/config/logging.py @@ -61,9 +61,12 @@ def load_resource(path: str, encoding: str = None): """Open a resource file located in a python package or the local filesystem. Args: - path: The resource path in the form of `dir/file` or `package:dir/file` + path (str): The resource path in the form of `dir/file` or `package:dir/file` + encoding (str, optional): The encoding to use when reading the resource file. + Defaults to None. + Returns: - A file-like object representing the resource + file-like object: A file-like object representing the resource """ components = path.rsplit(":", 1) try: @@ -458,11 +461,23 @@ def __init__( """Initialize an instance of `TimedRotatingFileMultiProcessHandler`. Args: - filename: log file name with path - when: specify when to rotate log file - interval: interval when to rotate - backupCount: count of backup file, backupCount of 0 will mean - no limit on count of backup file [no backup will be deleted] + filename (str): The log file name with path. + when (str, optional): Specifies when to rotate the log file. Defaults to "h". + interval (int, optional): The interval when to rotate. Defaults to 1. + backupCount (int, optional): The count of backup files. A backupCount of 0 + means no limit on the count of backup files (no backup will be deleted). + Defaults to 1. + encoding (str, optional): The encoding to use for the log file. + Defaults to None. + delay (bool, optional): Whether to delay file opening until the first log + message is emitted. Defaults to False. + utc (bool, optional): Whether to use UTC time for log rotation. + Defaults to False. + atTime (datetime.time, optional): The specific time at which log rotation + should occur. Defaults to None. + + Raises: + ValueError: If an invalid rollover interval is specified. """ BaseRotatingHandler.__init__( @@ -479,6 +494,7 @@ def __init__( self.mylogfile = "%s.%08d" % ("/tmp/trfmphanldler", randint(0, 99999999)) self.interval = interval + # Set the appropriate suffix and regular expression pattern based on the specified rollover interval # noqa: E501 if self.when == "S": self.interval = 1 self.suffix = "%Y-%m-%d_%H-%M-%S" diff --git a/aries_cloudagent/connections/base_manager.py b/aries_cloudagent/connections/base_manager.py index a35a44bfaf..cfbaff8dd1 100644 --- a/aries_cloudagent/connections/base_manager.py +++ b/aries_cloudagent/connections/base_manager.py @@ -76,7 +76,8 @@ def __init__(self, profile: Profile): """Initialize a BaseConnectionManager. Args: - session: The profile session for this presentation + profile (Profile): The profile object associated with this connection manager. + """ self._profile = profile self._route_manager = profile.inject(RouteManager) @@ -124,12 +125,14 @@ async def create_did_peer_4( """Create a did:peer:4 DID for a connection. Args: - svc_endpoints: Custom endpoints for the DID Document - mediation_record: The record for mediation that contains routing_keys and - service endpoint + svc_endpoints (Optional[Sequence[str]]): Custom endpoints for the + DID Document. + mediation_records (Optional[List[MediationRecord]]): The records for + mediation that contain routing keys and service endpoint. + metadata (Optional[Dict]): Additional metadata for the DID. Returns: - The new `DIDInfo` instance + DIDInfo: The new `DIDInfo` instance representing the created DID. """ routing_keys: List[str] = [] if mediation_records: @@ -190,12 +193,14 @@ async def create_did_peer_2( """Create a did:peer:2 DID for a connection. Args: - svc_endpoints: Custom endpoints for the DID Document - mediation_record: The record for mediation that contains routing_keys and - service endpoint + svc_endpoints (Optional[Sequence[str]]): Custom endpoints for the + DID Document. + mediation_records (Optional[List[MediationRecord]]): The records for + mediation that contain routing keys and service endpoint. + metadata (Optional[Dict]): Additional metadata for the DID. Returns: - The new `DIDInfo` instance + DIDInfo: The new `DIDInfo` instance representing the created DID. """ routing_keys: List[str] = [] if mediation_records: @@ -274,16 +279,17 @@ async def create_did_document( """Create our DID doc for a given DID. Args: - did_info: The DID information (DID and verkey) used in the connection - svc_endpoints: Custom endpoints for the DID Document - mediation_record: The record for mediation that contains routing_keys and - service endpoint + did_info (DIDInfo): The DID information (DID and verkey) used in the + connection. + svc_endpoints (Optional[Sequence[str]]): Custom endpoints for the + DID Document. + mediation_records (Optional[List[MediationRecord]]): The records for + mediation that contain routing keys and service endpoints. Returns: - The prepared `DIDDoc` instance + DIDDoc: The prepared `DIDDoc` instance. """ - did_doc = DIDDoc(did=did_info.did) did_controller = did_info.did did_key = did_info.verkey @@ -463,7 +469,16 @@ async def resolve_invitation( """Resolve invitation with the DID Resolver. Args: - did: Document ID to resolve + did (str): Document ID to resolve. + service_accept (Optional[Sequence[Text]]): List of accepted service types. + + Returns: + Tuple[str, List[str], List[str]]: A tuple containing the endpoint, + recipient keys, and routing keys. + + Raises: + BaseConnectionManagerError: If the public DID has no associated + DIDComm services. """ doc, didcomm_services = await self.resolve_didcomm_services(did, service_accept) if not didcomm_services: @@ -589,14 +604,18 @@ async def _fetch_connection_targets_for_invitation( ) -> Sequence[ConnectionTarget]: """Get a list of connection targets for an invitation. - This will extract target info for either a connection or OOB invitation. + This method extracts target information for either a connection or out-of-band + (OOB) invitation. Args: - connection: ConnRecord the invitation is associated with. - invitation: Connection or OOB invitation retrieved from conn record. + connection (ConnRecord): The connection record associated with the invitation. + invitation (Union[ConnectionInvitation, InvitationMessage]): The connection + or OOB invitation retrieved from the connection record. + sender_verkey (str): The sender's verification key. Returns: - A list of `ConnectionTarget` objects + Sequence[ConnectionTarget]: A list of `ConnectionTarget` objects + representing the connection targets for the invitation. """ if isinstance(invitation, ConnectionInvitation): # conn protocol invitation @@ -656,6 +675,7 @@ async def _fetch_targets_for_connection_in_progress( Args: connection: The connection record (with associated `DIDDoc`) used to generate the connection target + sender_verkey: The verkey we are using Returns: A list of `ConnectionTarget` objects """ @@ -1041,17 +1061,32 @@ async def create_static_connection( ) -> Tuple[DIDInfo, DIDInfo, ConnRecord]: """Register a new static connection (for use by the test suite). + This method is used to create a new static connection. It allows overriding + various parameters such as DIDs, seeds, verkeys, endpoints, labels, and aliases. + It returns the created connection record along with the associated DID + information. + Args: - 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 - alias: an alias for this connection record + my_did (Optional[str]): Override the DID used in the connection. + my_seed (Optional[str]): Provide a seed used to generate our DID and keys. + their_did (Optional[str]): Provide the DID used by the other party. + their_seed (Optional[str]): Provide a seed used to generate their DID and + keys. + their_verkey (Optional[str]): Provide the verkey used by the other party. + their_endpoint (Optional[str]): Their URL endpoint for routing messages. + their_label (Optional[str]): An alias for this connection record. + alias (Optional[str]): An alias for this connection record. + mediation_id (Optional[str]): The mediation ID for routing through a mediator. Returns: - Tuple: my DIDInfo, their DIDInfo, new `ConnRecord` instance + Tuple[DIDInfo, DIDInfo, ConnRecord]: A tuple containing the following: + - my DIDInfo: The DID information for the local party. + - their DIDInfo: The DID information for the other party. + - new `ConnRecord` instance: The newly created connection record. + + Raises: + BaseConnectionManagerError: If either a verkey or seed must be provided for + the other party. """ async with self._profile.session() as session: diff --git a/aries_cloudagent/connections/models/conn_record.py b/aries_cloudagent/connections/models/conn_record.py index 116a91568f..9bf137b7f0 100644 --- a/aries_cloudagent/connections/models/conn_record.py +++ b/aries_cloudagent/connections/models/conn_record.py @@ -27,6 +27,8 @@ from ...protocols.didcomm_prefix import DIDCommPrefix from ...protocols.didexchange.v1_0.message_types import ( ARIES_PROTOCOL as DIDEX_1_1, +) +from ...protocols.didexchange.v1_0.message_types import ( DIDEX_1_0, ) from ...protocols.didexchange.v1_0.messages.request import DIDXRequest @@ -277,6 +279,7 @@ async def retrieve_by_did( their_did: The target DID to filter by my_did: One of our DIDs to filter by my_role: Filter connections by their role + their_role: Filter connections by their role """ tag_filter = {} if their_did: @@ -364,6 +367,7 @@ async def retrieve_by_request_id( Args: session: The active profile session request_id: The ID of the originating connection request + their_role: Filter by their role """ tag_filter = {"request_id": request_id} if their_role: @@ -483,6 +487,8 @@ async def post_save(self, session: ProfileSession, *args, **kwargs): Args: session: The active profile session + args: Additional positional arguments + kwargs: Additional keyword arguments """ await super().post_save(session, *args, **kwargs) diff --git a/aries_cloudagent/connections/models/connection_target.py b/aries_cloudagent/connections/models/connection_target.py index 99ebb7c1bd..ad7219db0a 100644 --- a/aries_cloudagent/connections/models/connection_target.py +++ b/aries_cloudagent/connections/models/connection_target.py @@ -37,8 +37,9 @@ def __init__( did: A did for the connection endpoint: An endpoint for the connection label: A label for the connection - recipient_key: A list of recipient keys + recipient_keys: A list of recipient keys routing_keys: A list of routing keys + sender_key: A sender key """ self.did = did self.endpoint = endpoint diff --git a/aries_cloudagent/core/conductor.py b/aries_cloudagent/core/conductor.py index 564dd4d3b2..f93900e577 100644 --- a/aries_cloudagent/core/conductor.py +++ b/aries_cloudagent/core/conductor.py @@ -104,6 +104,7 @@ def __init__(self, context_builder: ContextBuilder) -> None: inbound_transports: Configuration for inbound transports outbound_transports: Configuration for outbound transports settings: Dictionary of various settings + context_builder: Context builder for the conductor """ self.admin_server = None @@ -577,7 +578,7 @@ def inbound_message_router( """Route inbound messages. Args: - context: The context associated with the inbound message + profile: The active profile for the request message: The inbound message instance can_respond: If the session supports return routing @@ -662,7 +663,7 @@ async def outbound_message_router( Args: profile: The active profile for the request - message: An outbound message to be sent + outbound: An outbound message to be sent inbound: The inbound message that produced this response, if available """ status: OutboundSendStatus = await self._outbound_message_router( @@ -681,7 +682,7 @@ async def _outbound_message_router( Args: profile: The active profile for the request - message: An outbound message to be sent + outbound: An outbound message to be sent inbound: The inbound message that produced this response, if available """ if not outbound.target and outbound.reply_to_verkey: @@ -714,7 +715,7 @@ async def queue_outbound( Args: profile: The active profile - message: An outbound message to be sent + outbound: The outbound message to be sent inbound: The inbound message that produced this response, if available """ has_target = outbound.target or outbound.target_list diff --git a/aries_cloudagent/core/dispatcher.py b/aries_cloudagent/core/dispatcher.py index 4887af4de5..1b46b74b0e 100644 --- a/aries_cloudagent/core/dispatcher.py +++ b/aries_cloudagent/core/dispatcher.py @@ -7,9 +7,9 @@ import asyncio import logging import os -from typing import Callable, Coroutine, Union import warnings import weakref +from typing import Callable, Coroutine, Union from aiohttp.web import HTTPException @@ -21,7 +21,7 @@ from ..messaging.error import MessageParseError from ..messaging.models.base import BaseModelError from ..messaging.request_context import RequestContext -from ..messaging.responder import BaseResponder, SKIP_ACTIVE_CONN_CHECK_MSG_TYPES +from ..messaging.responder import SKIP_ACTIVE_CONN_CHECK_MSG_TYPES, BaseResponder from ..messaging.util import datetime_now from ..protocols.problem_report.v1_0.message import ProblemReport from ..transport.inbound.message import InboundMessage @@ -298,6 +298,7 @@ def __init__( context: The request context of the incoming message inbound_message: The inbound message triggering this handler send_outbound: Async function to send outbound message + kwargs: Additional keyword arguments """ super().__init__(**kwargs) @@ -315,6 +316,10 @@ async def create_outbound( Args: message: The message payload + kwargs: Additional keyword arguments + + Returns: + OutboundMessage: The created outbound message. """ context = self._context() if not context: @@ -338,6 +343,7 @@ async def send_outbound( Args: message: The `OutboundMessage` to be sent + kwargs: Additional keyword arguments """ context = self._context() if not context: diff --git a/aries_cloudagent/core/profile.py b/aries_cloudagent/core/profile.py index 7030769003..f5d66f5241 100644 --- a/aries_cloudagent/core/profile.py +++ b/aries_cloudagent/core/profile.py @@ -1,7 +1,7 @@ """Classes for managing profile information within a request context.""" -from abc import ABC, abstractmethod import logging +from abc import ABC, abstractmethod from typing import Any, Mapping, Optional, Type from weakref import ref @@ -84,6 +84,7 @@ def inject( Args: cls: The base class to retrieve an instance of + base_cls: The base class to retrieve settings: An optional mapping providing configuration to the provider Returns: @@ -266,11 +267,12 @@ async def emit_event(self, topic: str, payload: Any, force_emit: bool = False): If we are in an active transaction, just queue the event, otherwise emit it. Args: - session: The profile session to use - payload: The event payload + topic (str): The topic of the event. + payload (Any): The payload of the event. + force_emit (bool, optional): If True, force the event to be emitted even + if there is an active transaction. Defaults to False. """ - # TODO check transaction, either queue or emit event if force_emit or (not self.is_transaction): # just emit directly await self.profile.notify(topic, payload) @@ -291,11 +293,15 @@ def inject( """Get the provided instance of a given class identifier. Args: - cls: The base class to retrieve an instance of - settings: An optional mapping providing configuration to the provider + base_cls (Type[InjectType]): The base class to retrieve an instance of. + settings (Mapping[str, object], optional): An optional mapping providing + configuration to the provider. Returns: - An instance of the base class, or None + InjectType: An instance of the base class, or None. + + Raises: + ProfileSessionInactiveError: If the profile session is inactive. """ if not self._active: diff --git a/aries_cloudagent/core/protocol_registry.py b/aries_cloudagent/core/protocol_registry.py index b64b789efd..273233b374 100644 --- a/aries_cloudagent/core/protocol_registry.py +++ b/aries_cloudagent/core/protocol_registry.py @@ -1,15 +1,13 @@ """Handle registration and publication of supported protocols.""" -from dataclasses import dataclass import logging - +from dataclasses import dataclass from typing import Any, Dict, Mapping, Optional, Sequence, Union from ..config.injection_context import InjectionContext -from ..utils.classloader import ClassLoader, DeferLoad from ..messaging.message_type import MessageType, MessageVersion, ProtocolIdentifier - -from .error import ProtocolMinorVersionNotSupported, ProtocolDefinitionValidationError +from ..utils.classloader import ClassLoader, DeferLoad +from .error import ProtocolDefinitionValidationError, ProtocolMinorVersionNotSupported LOGGER = logging.getLogger(__name__) @@ -108,8 +106,10 @@ def register_message_types( """Add new supported message types. Args: - typesets: Mappings of message types to register - version_definition: Optional version definition dict + typeset (Mapping[str, Union[str, type]]): Mappings of message types to + register. + version_definition (Optional[Union[dict[str, Any], VersionDefinition]]): + Optional version definition dict. """ if version_definition is not None and isinstance(version_definition, dict): diff --git a/aries_cloudagent/indy/credx/holder.py b/aries_cloudagent/indy/credx/holder.py index 616f3bdaaf..88d02f14cf 100644 --- a/aries_cloudagent/indy/credx/holder.py +++ b/aries_cloudagent/indy/credx/holder.py @@ -379,8 +379,15 @@ async def credential_revoked( """Check ledger for revocation status of credential by cred id. Args: - credential_id: Credential id to check + ledger (BaseLedger): The ledger to check for revocation status. + credential_id (str): The ID of the credential to check. + fro (int, optional): The starting sequence number of the revocation registry + delta. Defaults to None. + to (int, optional): The ending sequence number of the revocation registry + delta. Defaults to None. + Returns: + bool: True if the credential is revoked, False otherwise. """ cred = await self._get_credential(credential_id) rev_reg_id = cred.rev_reg_id @@ -537,17 +544,24 @@ async def create_revocation_state( ) -> str: """Create current revocation state for a received credential. + This method creates the current revocation state for a received credential. + It takes the credential revocation ID, revocation registry definition, + revocation delta, delta timestamp, and tails file path as input parameters. + Args: - cred_rev_id: credential revocation id in revocation registry - rev_reg_def: revocation registry definition - rev_reg_delta: revocation delta - timestamp: delta timestamp + cred_rev_id (str): The credential revocation ID in the revocation registry. + rev_reg_def (dict): The revocation registry definition. + rev_reg_delta (dict): The revocation delta. + timestamp (int): The delta timestamp. + tails_file_path (str): The path to the tails file. Returns: - the revocation state + str: The revocation state. - """ + Raises: + IndyHolderError: If there is an error creating the revocation state. + """ try: rev_state = await asyncio.get_event_loop().run_in_executor( None, diff --git a/aries_cloudagent/indy/credx/issuer.py b/aries_cloudagent/indy/credx/issuer.py index 26843c0428..cd0ff3343b 100644 --- a/aries_cloudagent/indy/credx/issuer.py +++ b/aries_cloudagent/indy/credx/issuer.py @@ -2,11 +2,9 @@ import asyncio import logging - from typing import Sequence, Tuple from aries_askar import AskarError - from indy_credx import ( Credential, CredentialDefinition, @@ -21,13 +19,12 @@ ) from ...askar.profile import AskarProfile - from ..issuer import ( + DEFAULT_CRED_DEF_TAG, + DEFAULT_SIGNATURE_TYPE, IndyIssuer, IndyIssuerError, IndyIssuerRevocationRegistryFullError, - DEFAULT_CRED_DEF_TAG, - DEFAULT_SIGNATURE_TYPE, ) LOGGER = logging.getLogger(__name__) @@ -122,14 +119,20 @@ async def create_and_store_credential_definition( """Create a new credential definition and store it in the wallet. Args: - origin_did: the DID issuing the credential definition - schema_json: the schema used as a basis - signature_type: the credential definition signature type (default 'CL') - tag: the credential definition tag - support_revocation: whether to enable revocation for this credential def + origin_did (str): The DID issuing the credential definition. + schema (dict): The schema to create a credential definition for. + signature_type (str, optional): The credential definition signature type + (default 'CL'). + tag (str, optional): The credential definition tag. + support_revocation (bool, optional): Whether to enable revocation for this + credential definition. Returns: - A tuple of the credential definition ID and JSON + Tuple[str, str]: A tuple of the credential definition ID and JSON. + + Raises: + IndyIssuerError: If there is an error creating or storing the credential + definition. """ try: diff --git a/aries_cloudagent/indy/holder.py b/aries_cloudagent/indy/holder.py index ad0f8dbc3b..cab2d70e3f 100644 --- a/aries_cloudagent/indy/holder.py +++ b/aries_cloudagent/indy/holder.py @@ -42,8 +42,15 @@ async def credential_revoked( """Check ledger for revocation status of credential by cred id. Args: - credential_id: Credential id to check + ledger (BaseLedger): The ledger to check for revocation status. + credential_id (str): The ID of the credential to check. + fro (int, optional): The starting time of the revocation status check range. + Defaults to None. + to (int, optional): The ending time of the revocation status check range. + Defaults to None. + Returns: + bool: True if the credential is revoked, False otherwise. """ @abstractmethod @@ -144,12 +151,13 @@ async def create_revocation_state( """Create current revocation state for a received credential. Args: - cred_rev_id: credential revocation id in revocation registry - rev_reg_def: revocation registry definition - rev_reg_delta: revocation delta - timestamp: delta timestamp + cred_rev_id (str): The credential revocation ID in the revocation registry. + rev_reg_def (dict): The revocation registry definition. + rev_reg_delta (dict): The revocation delta. + timestamp (int): The delta timestamp. + tails_file_path (str): The file path to the tails file. Returns: - the revocation state + str: The revocation state. """ diff --git a/aries_cloudagent/indy/issuer.py b/aries_cloudagent/indy/issuer.py index d97863737d..2fa531fec6 100644 --- a/aries_cloudagent/indy/issuer.py +++ b/aries_cloudagent/indy/issuer.py @@ -5,7 +5,6 @@ from ..core.error import BaseError - DEFAULT_CRED_DEF_TAG = "default" DEFAULT_SIGNATURE_TYPE = "CL" @@ -87,14 +86,16 @@ async def create_and_store_credential_definition( """Create a new credential definition and store it in the wallet. Args: - origin_did: the DID issuing the credential definition - schema_json: the schema used as a basis - signature_type: the credential definition signature type (default 'CL') - tag: the credential definition tag - support_revocation: whether to enable revocation for this credential def + origin_did (str): The DID issuing the credential definition. + schema (dict): The schema used as a basis. + signature_type (str, optional): The credential definition signature type. + Defaults to 'CL'. + tag (str, optional): The credential definition tag. + support_revocation (bool, optional): Whether to enable revocation for this + credential definition. Returns: - A tuple of the credential definition ID and JSON + Tuple[str, str]: A tuple of the credential definition ID and JSON. """ diff --git a/aries_cloudagent/indy/models/cred_abstract.py b/aries_cloudagent/indy/models/cred_abstract.py index 9abdbd5bb3..dd3eaacee6 100644 --- a/aries_cloudagent/indy/models/cred_abstract.py +++ b/aries_cloudagent/indy/models/cred_abstract.py @@ -105,6 +105,7 @@ def __init__( cred_def_id: credential definition identifier nonce: nonce key_correctness_proof: key correctness proof + kwargs: aditional keyword arguments """ super().__init__(**kwargs) diff --git a/aries_cloudagent/indy/models/non_rev_interval.py b/aries_cloudagent/indy/models/non_rev_interval.py index 114e80724d..3951f20a5a 100644 --- a/aries_cloudagent/indy/models/non_rev_interval.py +++ b/aries_cloudagent/indy/models/non_rev_interval.py @@ -22,6 +22,7 @@ def __init__(self, fro: int = None, to: int = None, **kwargs): Args: fro: earliest time of interest to: latest time of interest + kwargs: additional attributes """ super().__init__(**kwargs) diff --git a/aries_cloudagent/indy/models/pres_preview.py b/aries_cloudagent/indy/models/pres_preview.py index 6e2cd073d0..aeea3b2e77 100644 --- a/aries_cloudagent/indy/models/pres_preview.py +++ b/aries_cloudagent/indy/models/pres_preview.py @@ -53,6 +53,7 @@ def __init__( cred_def_id: credential definition identifier predicate: predicate type (e.g., ">=") threshold: threshold value + kwargs: additional keyword arguments """ super().__init__(**kwargs) @@ -144,6 +145,7 @@ def __init__( value: attribute value as credential stores it (None for unrevealed attribute) referent: credential referent + kwargs: additional keyword arguments """ super().__init__(**kwargs) @@ -278,6 +280,7 @@ def __init__( _type: formalism for Marshmallow model creation: ignored attributes: list of attribute specifications predicates: list of predicate specifications + kwargs: additional keyword arguments """ super().__init__(**kwargs) @@ -323,10 +326,10 @@ async def indy_proof_request( Typically the verifier turns the proof preview into a proof request. Args: + profile: agent profile to use for ledger access name: for proof request version: version for proof request nonce: nonce for proof request - ledger: ledger with credential definitions, to check for revocation support non_revoc_intervals: non-revocation interval to use per cred def id where applicable (default from and to the current time if applicable) diff --git a/aries_cloudagent/indy/models/proof_request.py b/aries_cloudagent/indy/models/proof_request.py index d73c3ff026..a94e34c1e8 100644 --- a/aries_cloudagent/indy/models/proof_request.py +++ b/aries_cloudagent/indy/models/proof_request.py @@ -100,6 +100,7 @@ def validate_fields(self, data, **kwargs): Args: data: The data to validate + kwargs: Additional keyword arguments Raises: ValidationError: if data has both or neither of name and names @@ -208,10 +209,15 @@ def __init__( """Initialize indy cred abstract object. Args: - schema_id: schema identifier - cred_def_id: credential definition identifier - nonce: nonce - key_correctness_proof: key correctness proof + nonce (str): The nonce value. + name (str): The name of the proof request. + version (str): The version of the proof request. + requested_attributes (Mapping): A mapping of attribute names to attribute + constraints. + requested_predicates (Mapping): A mapping of predicate names to predicate + constraints. + non_revoked (Mapping): A mapping of non-revocation timestamps. + kwargs: Keyword arguments for BaseModel """ super().__init__(**kwargs) diff --git a/aries_cloudagent/indy/models/xform.py b/aries_cloudagent/indy/models/xform.py index f15587abf4..ee2e53c2ec 100644 --- a/aries_cloudagent/indy/models/xform.py +++ b/aries_cloudagent/indy/models/xform.py @@ -1,7 +1,6 @@ """Utilities to deal with indy.""" from ...indy.holder import IndyHolder - from .pres_preview import IndyPresPreview @@ -19,7 +18,7 @@ async def indy_proof_req_preview2indy_requested_creds( Args: indy_proof_req: indy proof request - pres_preview: preview from presentation proposal, if applicable + preview: preview from presentation proposal, if applicable holder: holder injected into current context """ diff --git a/aries_cloudagent/indy/verifier.py b/aries_cloudagent/indy/verifier.py index 0b7dd5f536..56b1432f32 100644 --- a/aries_cloudagent/indy/verifier.py +++ b/aries_cloudagent/indy/verifier.py @@ -1,7 +1,6 @@ """Base Indy Verifier class.""" import logging - from abc import ABC, ABCMeta, abstractmethod from enum import Enum from time import time @@ -14,10 +13,8 @@ ) from ..messaging.util import canon, encode from ..multitenant.base import BaseMultitenantManager - from .models.xform import indy_proof_req2non_revoc_intervals - LOGGER = logging.getLogger(__name__) @@ -54,6 +51,7 @@ def non_revoc_intervals(self, pres_req: dict, pres: dict, cred_defs: dict) -> li Args: pres_req: presentation request pres: corresponding presentation + cred_defs: credential definitions by cred def id """ msgs = [] @@ -118,7 +116,7 @@ async def check_timestamps( superfluous or missing. Args: - ledger: the base ledger for retrieving revocation registry definitions + profile: profile pres_req: indy proof request pres: indy proof request rev_reg_defs: rev reg defs by rev reg id, augmented with transaction times diff --git a/aries_cloudagent/ledger/base.py b/aries_cloudagent/ledger/base.py index 509dc48d4b..48d61e2c25 100644 --- a/aries_cloudagent/ledger/base.py +++ b/aries_cloudagent/ledger/base.py @@ -128,6 +128,9 @@ async def update_endpoint_for_did( did: The ledger DID endpoint: The endpoint address endpoint_type: The type of the endpoint (default 'endpoint') + write_ledger: Flag to write the endpoint to the ledger + endorser_did: Optional DID of the endorser + routing_keys: List of routing_keys if mediator is present """ @abstractmethod @@ -147,6 +150,8 @@ async def register_nym( verkey: The verification key of the keypair. alias: Human-friendly alias to assign to the DID. role: For permissioned ledgers, what role should the new DID have. + write_ledger: Flag to write the nym to the ledger + endorser_did: Optional DID of the endorser """ @abstractmethod @@ -284,6 +289,8 @@ async def create_and_send_schema( schema_name: The schema name schema_version: The schema version attribute_names: A list of schema attributes + write_ledger: Flag to write the schema to the ledger + endorser_did: Optional DID of the endorser """ @@ -433,6 +440,8 @@ async def create_and_send_credential_definition( signature_type: The signature type to use on the credential definition tag: Optional tag to distinguish multiple credential definitions support_revocation: Optional flag to enable revocation for this cred def + write_ledger: Flag to write the cred def to the ledger + endorser_did: Optional DID of the endorser Returns: Tuple with cred def id, cred def structure, and whether it's novel @@ -592,13 +601,30 @@ async def send_schema_anoncreds( write_ledger: bool = True, endorser_did: str = None, ) -> Tuple[str, dict]: - """Send schema to ledger. + """Send schema to the ledger. + + This method sends a schema to the ledger for publication. Args: - issuer: The issuer instance to use for schema creation - schema_name: The schema name - schema_version: The schema version - attribute_names: A list of schema attributes + schema_id (str): The ID of the schema. + schema_def (dict): The definition of the schema. + write_ledger (bool, optional): Whether to write the schema to the ledger. + Defaults to True. + endorser_did (str, optional): The DID of the endorser. Defaults to None. + + Returns: + Tuple[str, dict]: A tuple containing the schema ID and the schema definition. + + Raises: + BadLedgerRequestError: If there is no public DID available for publishing the + schema. + BadLedgerRequestError: If the public DID is not an IndyDID. + LedgerError: If the ledger is in read-only mode or if the TAA is required and + not accepted. + LedgerError: If the ledger is in read-only mode. + LedgerError: If parsing the schema sequence number from the ledger response + fails. + LedgerObjectAlreadyExistsError: If the schema already exists on the ledger. """ from aries_cloudagent.anoncreds.default.legacy_indy.registry import ( @@ -697,14 +723,27 @@ async def send_credential_definition_anoncreds( """Send credential definition to ledger and store relevant key matter in wallet. Args: - issuer: The issuer instance to use for credential definition creation - schema_id: The schema id of the schema to create cred def for - signature_type: The signature type to use on the credential definition - tag: Optional tag to distinguish multiple credential definitions - support_revocation: Optional flag to enable revocation for this cred def + schema_id (str): The schema id of the schema to create credential definition + for. + cred_def_id (str): The credential definition id. + cred_def (dict): The credential definition structure. + write_ledger (bool, optional): Flag indicating whether to write the + credential definition to the ledger. Defaults to True. + endorser_did (str, optional): The DID of the endorser. Defaults to None. Returns: - Tuple with cred def id, cred def structure, and whether it's novel + Tuple[str, dict, bool]: A tuple containing the credential definition id, + credential definition structure, and a boolean indicating whether it's + novel. + + Raises: + BadLedgerRequestError: If there is no public DID available to publish the + credential definition. + LedgerError: If the ledger does not have the specified schema. + LedgerObjectAlreadyExistsError: If the credential definition already exists + in the wallet and on the ledger. + LedgerError: If the ledger is in read-only mode and cannot write the + credential definition. """ public_info = await self.get_wallet_public_did() diff --git a/aries_cloudagent/ledger/error.py b/aries_cloudagent/ledger/error.py index 6934e34523..bea5777f4d 100644 --- a/aries_cloudagent/ledger/error.py +++ b/aries_cloudagent/ledger/error.py @@ -1,6 +1,7 @@ """Ledger related errors.""" from typing import Generic, TypeVar + from ..core.error import BaseError @@ -44,6 +45,8 @@ def __init__( message: Human readable message text obj_id: ledger object id obj: ledger object + args: additional positional arguments + kwargs: additional keyword arguments """ super().__init__(message, obj_id, obj, *args, **kwargs) diff --git a/aries_cloudagent/ledger/indy_vdr.py b/aries_cloudagent/ledger/indy_vdr.py index fb3aa537f8..db2739284c 100644 --- a/aries_cloudagent/ledger/indy_vdr.py +++ b/aries_cloudagent/ledger/indy_vdr.py @@ -319,10 +319,11 @@ async def _submit( """Sign and submit request to ledger. Args: - request_json: The json string to submit + request: The request to submit sign: whether or not to sign the request taa_accept: whether to apply TAA acceptance to the (signed, write) request sign_did: override the signing DID + write_ledger: whether to write the request to the ledger """ @@ -723,6 +724,9 @@ async def update_endpoint_for_did( did: The ledger DID endpoint: The endpoint address endpoint_type: The type of the endpoint + write_ledger: Whether to write the endpoint to the ledger + endorser_did: DID of the endorser to use for the transaction + routing_keys: List of routing keys """ public_info = await self.get_wallet_public_did() if not public_info: @@ -791,6 +795,8 @@ async def register_nym( verkey: The verification key of the keypair. alias: Human-friendly alias to assign to the DID. role: For permissioned ledgers, what role should the new DID have. + write_ledger: Whether to write the nym to the ledger. + endorser_did: DID of the endorser to use for the transaction. """ if self.read_only: raise LedgerError( diff --git a/aries_cloudagent/ledger/multiple_ledger/indy_vdr_manager.py b/aries_cloudagent/ledger/multiple_ledger/indy_vdr_manager.py index 413d5d37d4..86a70704f5 100644 --- a/aries_cloudagent/ledger/multiple_ledger/indy_vdr_manager.py +++ b/aries_cloudagent/ledger/multiple_ledger/indy_vdr_manager.py @@ -38,10 +38,14 @@ def __init__( """Initialize MultiIndyLedgerManager. Args: - profile: The base profile for this manager - production_ledgers: production IndyVDRLedger mapping - non_production_ledgers: non_production IndyVDRLedger mapping - cache_ttl: Time in sec to persist did_ledger_id_resolver cache keys + profile (Profile): The base profile for this manager. + production_ledgers (Optional[OrderedDict]): Mapping of production + IndyVDRLedger. + non_production_ledgers (Optional[OrderedDict]): Mapping of non-production + IndyVDRLedger. + writable_ledgers (Optional[set]): Set of writable ledgers. + endorser_map (Optional[dict]): Mapping of endorsers. + cache_ttl (int): Time in seconds to persist did_ledger_id_resolver cache keys. """ self.profile = profile diff --git a/aries_cloudagent/messaging/agent_message.py b/aries_cloudagent/messaging/agent_message.py index e9bcb3031b..57d399af39 100644 --- a/aries_cloudagent/messaging/agent_message.py +++ b/aries_cloudagent/messaging/agent_message.py @@ -384,6 +384,7 @@ def assign_trace_decorator(self, context, trace): """Copy trace from a json structure. Args: + context: context object trace: string containing trace json structure """ if trace: @@ -480,6 +481,7 @@ def extract_decorators(self, data: Mapping, **kwargs): Args: data: Incoming data to parse + kwargs: Additional keyword arguments Returns: Parsed and modified data @@ -519,6 +521,7 @@ def populate_decorators(self, obj, **kwargs): Args: obj: The AgentMessage object + kwargs: Additional keyword arguments Returns: The AgentMessage object with populated decorators @@ -533,6 +536,7 @@ def check_dump_decorators(self, obj, **kwargs): Args: obj: The AgentMessage object + kwargs: Additional keyword arguments Raises: BaseModelError: If a decorator does not validate @@ -562,7 +566,8 @@ def dump_decorators(self, data, **kwargs): """Post-dump hook to write the decorators to the serialized output. Args: - obj: The serialized data + data: The serialized data + kwargs: Additional keyword arguments Returns: The modified data @@ -581,7 +586,8 @@ def replace_signatures(self, data, **kwargs): """Post-dump hook to write the signatures to the serialized output. Args: - obj: The serialized data + data: The serialized data + kwargs: Additional keyword arguments Returns: The modified data diff --git a/aries_cloudagent/messaging/credential_definitions/routes.py b/aries_cloudagent/messaging/credential_definitions/routes.py index 6a84a89ca5..56cb62403e 100644 --- a/aries_cloudagent/messaging/credential_definitions/routes.py +++ b/aries_cloudagent/messaging/credential_definitions/routes.py @@ -585,6 +585,7 @@ async def add_cred_def_non_secrets_record( wallet. Args: + profile: The active profile schema_id: The schema id (or stringified sequence number) issuer_did: The DID of the issuer credential_definition_id: The credential definition id diff --git a/aries_cloudagent/messaging/decorators/attach_decorator.py b/aries_cloudagent/messaging/decorators/attach_decorator.py index 820cf89c90..461e38ea1a 100644 --- a/aries_cloudagent/messaging/decorators/attach_decorator.py +++ b/aries_cloudagent/messaging/decorators/attach_decorator.py @@ -429,6 +429,7 @@ async def verify(self, wallet: BaseWallet, signer_verkey: str = None) -> bool: Args: wallet: Wallet to use to verify signature + signer_verkey: verkey of the signer to check against Returns: True if verification succeeds else False @@ -562,7 +563,9 @@ def __init__( filename: file name lastmod_time: last modification time, "%Y-%m-%d %H:%M:%SZ" description: content description + byte_count: byte count of data included by reference data: payload, as per `AttachDecoratorData` + kwargs: additional keyword arguments """ super().__init__(**kwargs) diff --git a/aries_cloudagent/messaging/decorators/signature_decorator.py b/aries_cloudagent/messaging/decorators/signature_decorator.py index 0abcef259f..11b86290ea 100644 --- a/aries_cloudagent/messaging/decorators/signature_decorator.py +++ b/aries_cloudagent/messaging/decorators/signature_decorator.py @@ -60,9 +60,11 @@ async def create( representing the resulting signature. Args: + cls: SignatureDecorator class value: Value to sign signer: Verkey of the signing party wallet: The wallet to use for the signature + timestamp: Timestamp to use for the signature Returns: The created `SignatureDecorator` object diff --git a/aries_cloudagent/messaging/models/base.py b/aries_cloudagent/messaging/models/base.py index c89f2a2734..3e654833f4 100644 --- a/aries_cloudagent/messaging/models/base.py +++ b/aries_cloudagent/messaging/models/base.py @@ -1,14 +1,13 @@ """Base classes for Models and Schemas.""" -import logging import json - +import logging from abc import ABC from collections import namedtuple from typing import Mapping, Optional, Type, TypeVar, Union, cast, overload -from typing_extensions import Literal -from marshmallow import Schema, post_dump, pre_load, post_load, ValidationError, EXCLUDE +from marshmallow import EXCLUDE, Schema, ValidationError, post_dump, post_load, pre_load +from typing_extensions import Literal from ...core.error import BaseError from ...utils.classloader import ClassLoader @@ -49,6 +48,7 @@ def resolve_meta_property(obj, prop_name: str, defval=None): """Resolve a meta property. Args: + obj: The object to resolve the property from prop_name: The property to resolve defval: The default value @@ -224,6 +224,7 @@ def serialize( Args: as_string: Return a string of JSON instead of a dict + unknown: Behaviour for unknown attributes Returns: A dict representation of this model, or a JSON string if as_string is True @@ -274,6 +275,7 @@ def from_json( Args: json_repr: JSON string + unknown: Behaviour for unknown attributes Returns: A model instance representation of this JSON @@ -362,6 +364,7 @@ def skip_dump_only(self, data, **kwargs): Args: data: The incoming data to clean + kwargs: Arbitrary keyword arguments Returns: The modified data diff --git a/aries_cloudagent/messaging/models/base_record.py b/aries_cloudagent/messaging/models/base_record.py index 08f6b9c09b..40b7c0ba04 100644 --- a/aries_cloudagent/messaging/models/base_record.py +++ b/aries_cloudagent/messaging/models/base_record.py @@ -229,6 +229,7 @@ async def retrieve_by_id( Args: session: The profile session to use record_id: The ID of the record to find + for_update: Whether to lock the record for update """ storage = session.inject(BaseStorage) @@ -250,10 +251,12 @@ async def retrieve_by_tag_filter( """Retrieve a record by tag filter. Args: + cls: The record class session: The profile session to use tag_filter: The filter dictionary to apply post_filter: Additional value filters to apply matching positively, with sequence values specifying alternatives to match (hit any) + for_update: Whether to lock the record for update """ storage = session.inject(BaseStorage) @@ -359,7 +362,7 @@ async def save( session: The profile session to use reason: A reason to add to the log log_params: Additional parameters to log - override: Override configured logging regimen, print to stderr instead + log_override: Override configured logging regimen, print to stderr instead event: Flag to override whether the event is sent """ diff --git a/aries_cloudagent/messaging/request_context.py b/aries_cloudagent/messaging/request_context.py index 171085c4bc..b346675aca 100644 --- a/aries_cloudagent/messaging/request_context.py +++ b/aries_cloudagent/messaging/request_context.py @@ -6,14 +6,13 @@ from typing import Mapping, Optional, Type -from ..core.profile import Profile, ProfileSession -from ..config.injector import Injector, InjectType from ..config.injection_context import InjectionContext +from ..config.injector import Injector, InjectType from ..config.settings import Settings from ..connections.models.conn_record import ConnRecord +from ..core.profile import Profile, ProfileSession from ..transport.inbound.receipt import MessageReceipt from ..utils.classloader import DeferLoad - from .agent_message import AgentMessage IN_MEM = DeferLoad("aries_cloudagent.core.in_memory.InMemoryProfile") @@ -145,7 +144,7 @@ def message_receipt(self, receipt: MessageReceipt): """Setter for the message receipt information. Args: - msg: This context's new message receipt information + receipt: This context's new message receipt information """ self._message_receipt = receipt @@ -184,7 +183,7 @@ def inject( """Get the provided instance of a given class identifier. Args: - cls: The base class to retrieve an instance of + base_cls: The base class to retrieve an instance of settings: An optional mapping providing configuration to the provider Returns: diff --git a/aries_cloudagent/messaging/responder.py b/aries_cloudagent/messaging/responder.py index 6c41393ee2..f179009c6b 100644 --- a/aries_cloudagent/messaging/responder.py +++ b/aries_cloudagent/messaging/responder.py @@ -121,6 +121,7 @@ async def send_reply( message: the `BaseMessage`, 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 + target_list: optionally specify a list of `ConnectionTarget` to send to Raises: ResponderError: If there is no active connection @@ -191,6 +192,7 @@ async def send_outbound( Args: message: The `OutboundMessage` to be sent + kwargs: Additional keyword arguments """ @abstractmethod diff --git a/aries_cloudagent/multitenant/admin/routes.py b/aries_cloudagent/multitenant/admin/routes.py index d4ce438db2..1d350cb658 100644 --- a/aries_cloudagent/multitenant/admin/routes.py +++ b/aries_cloudagent/multitenant/admin/routes.py @@ -234,6 +234,7 @@ def validate_fields(self, data, **kwargs): Args: data: The data to validate + kwargs: Additional keyword arguments Raises: ValidationError: If any of the fields do not validate diff --git a/aries_cloudagent/multitenant/askar_profile_manager.py b/aries_cloudagent/multitenant/askar_profile_manager.py index 22a118cf24..9946535b84 100644 --- a/aries_cloudagent/multitenant/askar_profile_manager.py +++ b/aries_cloudagent/multitenant/askar_profile_manager.py @@ -2,8 +2,8 @@ from typing import Iterable, Optional, cast -from ..askar.profile_anon import AskarAnoncredsProfile from ..askar.profile import AskarProfile +from ..askar.profile_anon import AskarAnoncredsProfile from ..config.injection_context import InjectionContext from ..config.wallet import wallet_config from ..core.profile import ( @@ -23,6 +23,7 @@ def __init__(self, profile: Profile, multitenant_profile: AskarProfile = None): Args: profile: The base profile for this manager + multitenant_profile: The multitenant profile for this manager """ super().__init__(profile) self._multitenant_profile: Optional[AskarProfile] = multitenant_profile @@ -57,6 +58,7 @@ async def get_wallet_profile( base_context: Base context to extend from wallet_record: Wallet record to get the context for extra_settings: Any extra context settings + provision: Whether to provision the wallet Returns: Profile: Profile for the wallet record diff --git a/aries_cloudagent/multitenant/base.py b/aries_cloudagent/multitenant/base.py index 7fa8e49115..fd0ef9f4c4 100644 --- a/aries_cloudagent/multitenant/base.py +++ b/aries_cloudagent/multitenant/base.py @@ -136,6 +136,7 @@ async def get_wallet_profile( base_context: Base context to extend from wallet_record: Wallet record to get the context for extra_settings: Any extra context settings + provision: Whether to provision the wallet Returns: Profile: Profile for the wallet record diff --git a/aries_cloudagent/multitenant/manager.py b/aries_cloudagent/multitenant/manager.py index 4f1cf89134..1a6bda9030 100644 --- a/aries_cloudagent/multitenant/manager.py +++ b/aries_cloudagent/multitenant/manager.py @@ -47,6 +47,7 @@ async def get_wallet_profile( base_context: Base context to extend from wallet_record: Wallet record to get the context for extra_settings: Any extra context settings + provision: Whether to provision the wallet Returns: Profile: Profile for the wallet record diff --git a/aries_cloudagent/protocols/actionmenu/v1_0/messages/menu.py b/aries_cloudagent/protocols/actionmenu/v1_0/messages/menu.py index 07b2034d4c..4474a78bc8 100644 --- a/aries_cloudagent/protocols/actionmenu/v1_0/messages/menu.py +++ b/aries_cloudagent/protocols/actionmenu/v1_0/messages/menu.py @@ -37,6 +37,7 @@ def __init__( description: Introductory text for the menu errormsg: An optional error message to display options: A sequence of menu options + kwargs: Additional keyword arguments """ super().__init__(**kwargs) self.title = title diff --git a/aries_cloudagent/protocols/actionmenu/v1_0/messages/perform.py b/aries_cloudagent/protocols/actionmenu/v1_0/messages/perform.py index 252387d2a9..aaf93c707c 100644 --- a/aries_cloudagent/protocols/actionmenu/v1_0/messages/perform.py +++ b/aries_cloudagent/protocols/actionmenu/v1_0/messages/perform.py @@ -26,6 +26,7 @@ def __init__(self, *, name: str = None, params: Mapping[str, str] = None, **kwar Args: name: The name of the menu option params: Input parameter values + kwargs: Additional keyword arguments """ super().__init__(**kwargs) self.name = name diff --git a/aries_cloudagent/protocols/basicmessage/v1_0/messages/basicmessage.py b/aries_cloudagent/protocols/basicmessage/v1_0/messages/basicmessage.py index 22d867f401..581abbace3 100644 --- a/aries_cloudagent/protocols/basicmessage/v1_0/messages/basicmessage.py +++ b/aries_cloudagent/protocols/basicmessage/v1_0/messages/basicmessage.py @@ -40,6 +40,7 @@ def __init__( sent_time: Time message was sent content: message content localization: localization + kwargs: additional keyword arguments """ super().__init__(**kwargs) diff --git a/aries_cloudagent/protocols/connections/v1_0/manager.py b/aries_cloudagent/protocols/connections/v1_0/manager.py index b2b590ebfe..5ee610724d 100644 --- a/aries_cloudagent/protocols/connections/v1_0/manager.py +++ b/aries_cloudagent/protocols/connections/v1_0/manager.py @@ -1,8 +1,8 @@ """Classes to manage connections.""" import logging -from typing import Optional, Sequence, Tuple, Union, cast import warnings +from typing import Optional, Sequence, Tuple, Union, cast from ....connections.base_manager import BaseConnectionManager from ....connections.models.conn_record import ConnRecord @@ -115,10 +115,18 @@ async def create_invitation( public: set 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 + routing_keys: optional list of routing keys for the invitation + recipient_keys: optional list of recipient keys for the invitation + metadata: optional metadata to include in the connection record + mediation_id: optional mediation ID for the connection Returns: A tuple of the new `ConnRecord` and `ConnectionInvitation` instances + Raises: + ConnectionManagerError: if public invitations are not enabled or + no public DID is available + """ self.deprecation_warning() # Mediation Record can still be None after this operation if no @@ -264,11 +272,19 @@ async def receive_invitation( Args: invitation: The `ConnectionInvitation` to store - auto_accept: set to auto-accept the invitation (None to use config) - alias: optional alias to set on the record + their_public_did: The public DID of the inviting party (optional) + auto_accept: Set to True to auto-accept the invitation, False to manually + accept, or None to use the default setting from the configuration + (optional) + alias: An optional alias to set on the connection record (optional) + mediation_id: The mediation ID to associate with the connection (optional) Returns: - The new `ConnRecord` instance + The new `ConnRecord` instance representing the connection + + Raises: + ConnectionManagerError: If the invitation is missing recipient keys or an + endpoint """ self.deprecation_warning() @@ -348,6 +364,7 @@ async def create_request( connection: The `ConnRecord` representing the invitation to accept my_label: My label my_endpoint: My endpoint + mediation_id: The record id for mediation Returns: A new `ConnectionRequest` message to send to the other agent diff --git a/aries_cloudagent/protocols/connections/v1_0/messages/connection_invitation.py b/aries_cloudagent/protocols/connections/v1_0/messages/connection_invitation.py index a20c0fee4c..889a3f1cd2 100644 --- a/aries_cloudagent/protocols/connections/v1_0/messages/connection_invitation.py +++ b/aries_cloudagent/protocols/connections/v1_0/messages/connection_invitation.py @@ -52,6 +52,7 @@ def __init__( endpoint: Endpoint which this agent can be reached at routing_keys: List of routing keys image_url: Optional image URL for connection invitation + kwargs: Additional keyword arguments for the message """ super().__init__(**kwargs) self.label = label @@ -191,6 +192,7 @@ def validate_fields(self, data, **kwargs): Args: data: The data to validate + kwargs: Additional keyword arguments Raises: ValidationError: If any of the fields do not validate diff --git a/aries_cloudagent/protocols/connections/v1_0/messages/connection_request.py b/aries_cloudagent/protocols/connections/v1_0/messages/connection_request.py index 38edfe408b..70583491f1 100644 --- a/aries_cloudagent/protocols/connections/v1_0/messages/connection_request.py +++ b/aries_cloudagent/protocols/connections/v1_0/messages/connection_request.py @@ -35,6 +35,8 @@ def __init__( connection (ConnectionDetail): Connection details object label: Label for this connection request image_url: Optional image URL for this connection request + kwargs: Additional keyword arguments for the message + """ super().__init__(**kwargs) self.connection = connection diff --git a/aries_cloudagent/protocols/connections/v1_0/messages/connection_response.py b/aries_cloudagent/protocols/connections/v1_0/messages/connection_response.py index 07824870bf..af7470448c 100644 --- a/aries_cloudagent/protocols/connections/v1_0/messages/connection_response.py +++ b/aries_cloudagent/protocols/connections/v1_0/messages/connection_response.py @@ -3,7 +3,6 @@ from marshmallow import EXCLUDE, fields from .....messaging.agent_message import AgentMessage, AgentMessageSchema - from ..message_types import CONNECTION_RESPONSE, PROTOCOL_PACKAGE from ..models.connection_detail import ConnectionDetail, ConnectionDetailSchema @@ -28,6 +27,7 @@ def __init__(self, *, connection: ConnectionDetail = None, **kwargs): Args: connection: Connection details object + kwargs: Additional keyword arguments for the message """ super().__init__(**kwargs) diff --git a/aries_cloudagent/protocols/connections/v1_0/messages/problem_report.py b/aries_cloudagent/protocols/connections/v1_0/messages/problem_report.py index 2823f8539c..e6533cb635 100644 --- a/aries_cloudagent/protocols/connections/v1_0/messages/problem_report.py +++ b/aries_cloudagent/protocols/connections/v1_0/messages/problem_report.py @@ -42,8 +42,9 @@ def __init__(self, *, problem_code: str = None, explain: str = None, **kwargs): """Initialize a ProblemReport message instance. Args: - explain: The localized error explanation problem_code: The standard error identifier + explain: The localized error explanation + kwargs: Additional keyword arguments """ super().__init__(**kwargs) self.explain = explain diff --git a/aries_cloudagent/protocols/connections/v1_0/models/connection_detail.py b/aries_cloudagent/protocols/connections/v1_0/models/connection_detail.py index fd842c9d13..1c6a0b97f0 100644 --- a/aries_cloudagent/protocols/connections/v1_0/models/connection_detail.py +++ b/aries_cloudagent/protocols/connections/v1_0/models/connection_detail.py @@ -15,6 +15,9 @@ def _serialize(self, value: DIDDoc, attr, obj, **kwargs): Args: value: The value to serialize + attr: The attribute being serialized + obj: The object being serialized + kwargs: Additional keyword arguments Returns: The serialized DIDDoc @@ -27,6 +30,9 @@ def _deserialize(self, value, attr=None, data=None, **kwargs): Args: value: The value to deserialize + attr: The attribute being deserialized + data: The full data being deserialized + kwargs: Additional keyword arguments Returns: The deserialized value @@ -49,6 +55,7 @@ def __init__(self, *, did: str = None, did_doc: DIDDoc = None, **kwargs): Args: did: DID for the connection detail did_doc: DIDDoc for connection detail + kwargs: Additional keyword arguments """ super().__init__(**kwargs) diff --git a/aries_cloudagent/protocols/coordinate_mediation/v1_0/manager.py b/aries_cloudagent/protocols/coordinate_mediation/v1_0/manager.py index 99ba961090..1b2184cf20 100644 --- a/aries_cloudagent/protocols/coordinate_mediation/v1_0/manager.py +++ b/aries_cloudagent/protocols/coordinate_mediation/v1_0/manager.py @@ -131,6 +131,7 @@ async def receive_request( """Create a new mediation record to track this request. Args: + connection_id (str): connection ID of mediator request (MediationRequest): request message Returns: @@ -458,6 +459,7 @@ async def request_granted(self, record: MediationRecord, grant: MediationGrant): Args: record (MediationRecord): record representing the granted mediation request + grant (MediationGrant): message from mediator granting request """ record.state = MediationRecord.STATE_GRANTED @@ -473,6 +475,7 @@ async def request_denied(self, record: MediationRecord, deny: MediationDeny): Args: record (MediationRecord): record representing the denied mediation request + deny (MediationDeny): message from mediator denying request """ record.state = MediationRecord.STATE_DENIED diff --git a/aries_cloudagent/protocols/coordinate_mediation/v1_0/messages/inner/keylist_key.py b/aries_cloudagent/protocols/coordinate_mediation/v1_0/messages/inner/keylist_key.py index 88e7b5f3a3..e77bfa37b8 100644 --- a/aries_cloudagent/protocols/coordinate_mediation/v1_0/messages/inner/keylist_key.py +++ b/aries_cloudagent/protocols/coordinate_mediation/v1_0/messages/inner/keylist_key.py @@ -29,6 +29,7 @@ def __init__( recipient_key: The recipient verkey of the route action: The requested action to perform result: The result of the requested action + kwargs: Additional key word arguments for BaseRecord """ super().__init__(**kwargs) diff --git a/aries_cloudagent/protocols/coordinate_mediation/v1_0/messages/inner/keylist_query_paginate.py b/aries_cloudagent/protocols/coordinate_mediation/v1_0/messages/inner/keylist_query_paginate.py index f7b400ce57..a0890f587b 100644 --- a/aries_cloudagent/protocols/coordinate_mediation/v1_0/messages/inner/keylist_query_paginate.py +++ b/aries_cloudagent/protocols/coordinate_mediation/v1_0/messages/inner/keylist_query_paginate.py @@ -19,6 +19,7 @@ def __init__(self, limit: int, offset: int, **kwargs): Args: limit: limit for response count offset: offset value + kwargs: additional keyword arguments for BaseModel """ super().__init__(**kwargs) diff --git a/aries_cloudagent/protocols/coordinate_mediation/v1_0/messages/inner/keylist_update_rule.py b/aries_cloudagent/protocols/coordinate_mediation/v1_0/messages/inner/keylist_update_rule.py index 99576e5be8..8fc98e8479 100644 --- a/aries_cloudagent/protocols/coordinate_mediation/v1_0/messages/inner/keylist_update_rule.py +++ b/aries_cloudagent/protocols/coordinate_mediation/v1_0/messages/inner/keylist_update_rule.py @@ -28,6 +28,7 @@ def __init__(self, recipient_key: str, action: str, **kwargs): Args: recipient_key: recipient key for the rule action: action for the rule + kwargs: additional keyword arguments """ super().__init__(**kwargs) diff --git a/aries_cloudagent/protocols/coordinate_mediation/v1_0/messages/inner/keylist_updated.py b/aries_cloudagent/protocols/coordinate_mediation/v1_0/messages/inner/keylist_updated.py index f151dcdcc8..8765a94272 100644 --- a/aries_cloudagent/protocols/coordinate_mediation/v1_0/messages/inner/keylist_updated.py +++ b/aries_cloudagent/protocols/coordinate_mediation/v1_0/messages/inner/keylist_updated.py @@ -37,6 +37,7 @@ def __init__( recipient_key: The recipient verkey of the route action: The requested action to perform result: The result of the requested action + kwargs: Additional key word arguments """ super().__init__(**kwargs) diff --git a/aries_cloudagent/protocols/coordinate_mediation/v1_0/messages/keylist.py b/aries_cloudagent/protocols/coordinate_mediation/v1_0/messages/keylist.py index 54609028b3..8b6472644a 100644 --- a/aries_cloudagent/protocols/coordinate_mediation/v1_0/messages/keylist.py +++ b/aries_cloudagent/protocols/coordinate_mediation/v1_0/messages/keylist.py @@ -37,6 +37,7 @@ def __init__( Args: keys: Found keys by requested query pagination: Pagination rules + kwargs: Additional keyword arguments for the message """ super().__init__(**kwargs) self.keys = list(keys) if keys else [] diff --git a/aries_cloudagent/protocols/coordinate_mediation/v1_0/messages/keylist_query.py b/aries_cloudagent/protocols/coordinate_mediation/v1_0/messages/keylist_query.py index 6273905659..4e7539eaf0 100644 --- a/aries_cloudagent/protocols/coordinate_mediation/v1_0/messages/keylist_query.py +++ b/aries_cloudagent/protocols/coordinate_mediation/v1_0/messages/keylist_query.py @@ -34,6 +34,7 @@ def __init__( Args: filter: Filter for query paginate: Pagination rules + kwargs: Additional keyword arguments for the message """ super().__init__(**kwargs) self.filter = filter diff --git a/aries_cloudagent/protocols/coordinate_mediation/v1_0/messages/keylist_update.py b/aries_cloudagent/protocols/coordinate_mediation/v1_0/messages/keylist_update.py index bff32ac09d..d736bce35c 100644 --- a/aries_cloudagent/protocols/coordinate_mediation/v1_0/messages/keylist_update.py +++ b/aries_cloudagent/protocols/coordinate_mediation/v1_0/messages/keylist_update.py @@ -33,6 +33,7 @@ def __init__( Args: updates: Update rules for keylist update request + kwargs: Additional keyword arguments for the message """ super(KeylistUpdate, self).__init__(**kwargs) self.updates = list(updates) if updates else [] diff --git a/aries_cloudagent/protocols/coordinate_mediation/v1_0/messages/keylist_update_response.py b/aries_cloudagent/protocols/coordinate_mediation/v1_0/messages/keylist_update_response.py index c14d8777f2..3ea951f9cf 100644 --- a/aries_cloudagent/protocols/coordinate_mediation/v1_0/messages/keylist_update_response.py +++ b/aries_cloudagent/protocols/coordinate_mediation/v1_0/messages/keylist_update_response.py @@ -33,7 +33,8 @@ def __init__( """Initialize keylist update object. Args: - updates: Update rules for keylist update request + updated: Update rules for keylist update request + kwargs: Additional keyword arguments for the message """ super(KeylistUpdateResponse, self).__init__(**kwargs) self.updated = list(updated) if updated else [] diff --git a/aries_cloudagent/protocols/coordinate_mediation/v1_0/messages/mediate_grant.py b/aries_cloudagent/protocols/coordinate_mediation/v1_0/messages/mediate_grant.py index 551f795eac..67a371c57e 100644 --- a/aries_cloudagent/protocols/coordinate_mediation/v1_0/messages/mediate_grant.py +++ b/aries_cloudagent/protocols/coordinate_mediation/v1_0/messages/mediate_grant.py @@ -37,6 +37,7 @@ def __init__( Args: endpoint: Endpoint address for the mediation route routing_keys: Keys for the mediation route + kwargs: Additional keyword arguments for the message """ super(MediationGrant, self).__init__(**kwargs) self.endpoint = endpoint diff --git a/aries_cloudagent/protocols/coordinate_mediation/v1_0/models/mediation_record.py b/aries_cloudagent/protocols/coordinate_mediation/v1_0/models/mediation_record.py index f616864a47..f80a585766 100644 --- a/aries_cloudagent/protocols/coordinate_mediation/v1_0/models/mediation_record.py +++ b/aries_cloudagent/protocols/coordinate_mediation/v1_0/models/mediation_record.py @@ -54,6 +54,8 @@ def __init__( routing_keys (Sequence[str]): keys in mediator control used to receive incoming messages endpoint (str): mediators endpoint + mediator_terms (Sequence[str]): (Optional) mediator terms + recipient_terms (Sequence[str]): (Optional) recipient terms kwargs: Pass arguments through to BaseRecord.__init__ """ diff --git a/aries_cloudagent/protocols/did_rotate/v1_0/messages/problem_report.py b/aries_cloudagent/protocols/did_rotate/v1_0/messages/problem_report.py index 3b353bb355..e5320b67f2 100644 --- a/aries_cloudagent/protocols/did_rotate/v1_0/messages/problem_report.py +++ b/aries_cloudagent/protocols/did_rotate/v1_0/messages/problem_report.py @@ -131,6 +131,7 @@ def validate_fields(self, data, **kwargs): Args: data: The data to validate + kwargs: Additional keyword arguments Raises: ValidationError: if data is invalid diff --git a/aries_cloudagent/protocols/didexchange/v1_0/manager.py b/aries_cloudagent/protocols/didexchange/v1_0/manager.py index 815e277cc4..9c6e3d959f 100644 --- a/aries_cloudagent/protocols/didexchange/v1_0/manager.py +++ b/aries_cloudagent/protocols/didexchange/v1_0/manager.py @@ -30,7 +30,8 @@ InvitationMessage as OOBInvitationMessage, ) from ...out_of_band.v1_0.messages.service import Service as OOBService -from .message_types import ARIES_PROTOCOL as DIDEX_1_1, DIDEX_1_0 +from .message_types import ARIES_PROTOCOL as DIDEX_1_1 +from .message_types import DIDEX_1_0 from .messages.complete import DIDXComplete from .messages.problem_report import DIDXProblemReport, ProblemReportReason from .messages.request import DIDXRequest @@ -90,6 +91,7 @@ async def receive_invitation( auto_accept: set to auto-accept invitation (None to use config) alias: optional alias to set on record mediation_id: record id for mediation with routing_keys, service endpoint + protocol: The protocol to use for the connection Returns: The new `ConnRecord` instance @@ -199,17 +201,38 @@ async def create_request_implicit( """Create and send a request against a public DID only (no explicit invitation). Args: - their_public_did: public DID to which to request a connection - my_label: my label for request - my_endpoint: my endpoint - mediation_id: record id for mediation with routing_keys, service endpoint - use_public_did: use my public DID for this connection - goal_code: Optional self-attested code for sharing intent of connection - goal: Optional self-attested string for sharing intent of connection - auto_accept: auto-accept a corresponding connection request + their_public_did (str): Public DID to which to request a connection. + my_label (Optional[str], optional): My label for the request. + Defaults to None. + my_endpoint (Optional[str], optional): My endpoint. Defaults to None. + mediation_id (Optional[str], optional): Record ID for mediation with routing + keys, service endpoint. Defaults to None. + use_public_did (bool, optional): Use my public DID for this connection. + Defaults to False. + alias (Optional[str], optional): Alias for the connection. Defaults to None. + goal_code (Optional[str], optional): Optional self-attested code for sharing + intent of connection. Defaults to None. + goal (Optional[str], optional): Optional self-attested string for sharing + intent of connection. Defaults to None. + auto_accept (bool, optional): Auto-accept a corresponding connection request. + Defaults to False. + protocol (Optional[str], optional): Protocol to use for the connection. + Defaults to None. + use_did (Optional[str], optional): Local DID to use for the connection. + Defaults to None. + use_did_method (Optional[str], optional): DID method to use for the + connection. Defaults to None. Returns: - The new `ConnRecord` instance + ConnRecord: The new `ConnRecord` instance representing the connection. + + Raises: + DIDXManagerError: If both `use_did` and `use_did_method` are specified, or + if both `use_public_did` and `use_did` are specified, or if both + `use_public_did` and `use_did_method` are specified. + WalletError: If no public DID is configured. + DIDXManagerError: If a connection already exists for the specified + `their_public_did` and `my_did`. """ @@ -316,6 +339,7 @@ async def create_request( service endpoint goal_code: Optional self-attested code for sharing intent of connection goal: Optional self-attested string for sharing intent of connection + use_did_method: The DID method to use for the connection Returns: A new `DIDXRequest` message to send to the other agent @@ -510,7 +534,7 @@ async def receive_request( recipient_verkey: The recipient verkey: None for public recipient DID my_endpoint: My endpoint alias: Alias for the connection - auto_accept: Auto-accept request against implicit invitation + auto_accept_implicit: Auto-accept request against implicit invitation Returns: The new or updated `ConnRecord` instance @@ -763,6 +787,7 @@ async def create_response( my_endpoint: Current agent endpoint mediation_id: The record id for mediation that contains routing_keys and service endpoint + use_public_did: Use public DID for connection Returns: New `DIDXResponse` message diff --git a/aries_cloudagent/protocols/didexchange/v1_0/messages/request.py b/aries_cloudagent/protocols/didexchange/v1_0/messages/request.py index f22fbe2134..4817fb3656 100644 --- a/aries_cloudagent/protocols/didexchange/v1_0/messages/request.py +++ b/aries_cloudagent/protocols/didexchange/v1_0/messages/request.py @@ -48,6 +48,7 @@ def __init__( invitation. goal: (optional) is a self-attested string that the receiver may want to display to the user about the context-specific goal of the request message. + kwargs: Additional keyword arguments for the message """ super().__init__(**kwargs) self.label = label diff --git a/aries_cloudagent/protocols/didexchange/v1_0/messages/response.py b/aries_cloudagent/protocols/didexchange/v1_0/messages/response.py index 927a038dec..8d04e26a3b 100644 --- a/aries_cloudagent/protocols/didexchange/v1_0/messages/response.py +++ b/aries_cloudagent/protocols/didexchange/v1_0/messages/response.py @@ -1,6 +1,7 @@ """Represents a DID exchange response message under RFC 23.""" from typing import Optional + from marshmallow import EXCLUDE, fields from .....messaging.agent_message import AgentMessage, AgentMessageSchema @@ -36,7 +37,10 @@ def __init__( Args: image_url: Optional image URL for this response + did: DID for this response did_doc_attach: signed DID doc attachment + did_rotate_attach: signed DID rotation attachment + kwargs: Additional keyword arguments for the message """ super().__init__(**kwargs) self.did = did diff --git a/aries_cloudagent/protocols/discovery/v1_0/messages/disclose.py b/aries_cloudagent/protocols/discovery/v1_0/messages/disclose.py index 45e080144a..0148572a6c 100644 --- a/aries_cloudagent/protocols/discovery/v1_0/messages/disclose.py +++ b/aries_cloudagent/protocols/discovery/v1_0/messages/disclose.py @@ -25,6 +25,7 @@ def __init__(self, *, protocols: Sequence[Mapping[str, Mapping]] = None, **kwarg Args: protocols: A mapping of protocol names to a dictionary of properties + kwargs: Additional keyword arguments for the message """ super().__init__(**kwargs) self.protocols = list(protocols) if protocols else [] diff --git a/aries_cloudagent/protocols/discovery/v1_0/messages/query.py b/aries_cloudagent/protocols/discovery/v1_0/messages/query.py index 6114561b81..7c055ea7f1 100644 --- a/aries_cloudagent/protocols/discovery/v1_0/messages/query.py +++ b/aries_cloudagent/protocols/discovery/v1_0/messages/query.py @@ -1,10 +1,10 @@ """Represents a feature discovery query message.""" from typing import Optional + from marshmallow import EXCLUDE, fields from .....messaging.agent_message import AgentMessage, AgentMessageSchema - from ..message_types import PROTOCOL_PACKAGE, QUERY HANDLER_CLASS = f"{PROTOCOL_PACKAGE}.handlers.query_handler.QueryHandler" @@ -31,6 +31,7 @@ def __init__( Args: query: The query string to match against supported message types comment: An optional comment + kwargs: Additional keyword arguments for the message """ super().__init__(**kwargs) self.query = query diff --git a/aries_cloudagent/protocols/discovery/v2_0/messages/disclosures.py b/aries_cloudagent/protocols/discovery/v2_0/messages/disclosures.py index a48fcb003c..2464142674 100644 --- a/aries_cloudagent/protocols/discovery/v2_0/messages/disclosures.py +++ b/aries_cloudagent/protocols/discovery/v2_0/messages/disclosures.py @@ -75,6 +75,7 @@ def __init__(self, *, disclosures: Sequence[Mapping] = None, **kwargs): Args: disclosures: A mapping of protocol names to a dictionary of properties + kwargs: Additional keyword arguments for the message """ super().__init__(**kwargs) self.disclosures = list(disclosures) if disclosures else [] diff --git a/aries_cloudagent/protocols/discovery/v2_0/messages/queries.py b/aries_cloudagent/protocols/discovery/v2_0/messages/queries.py index 6811ec3e98..6f03a04ac8 100644 --- a/aries_cloudagent/protocols/discovery/v2_0/messages/queries.py +++ b/aries_cloudagent/protocols/discovery/v2_0/messages/queries.py @@ -65,8 +65,8 @@ def __init__(self, *, queries: Sequence[QueryItem] = None, **kwargs): """Initialize query message object. Args: - query: The query string to match against supported message types - comment: An optional comment + queries: The query string to match against supported message types + kwargs: Additional key word arguments for the message """ super().__init__(**kwargs) self.queries = queries diff --git a/aries_cloudagent/protocols/endorse_transaction/v1_0/manager.py b/aries_cloudagent/protocols/endorse_transaction/v1_0/manager.py index 167fd842cc..13e7ad0386 100644 --- a/aries_cloudagent/protocols/endorse_transaction/v1_0/manager.py +++ b/aries_cloudagent/protocols/endorse_transaction/v1_0/manager.py @@ -46,7 +46,7 @@ def __init__(self, profile: Profile): """Initialize a TransactionManager. Args: - session: The Profile Session for this transaction manager + profile: The profile instance for this transaction manager """ self._profile = profile self._logger = logging.getLogger(__name__) @@ -69,6 +69,7 @@ async def create_record( Args: messages_attach: messages to attach, JSON-dumped connection_id: The connection_id of the ConnRecord between author and endorser + meta_data: The meta_data to attach to the transaction record Returns: The transaction Record @@ -119,11 +120,28 @@ async def create_request( """Create a new Transaction Request. Args: - transaction: The transaction from which the request is created. - expires_time: The time till which the endorser should endorse the transaction. + transaction (TransactionRecord): The transaction from which the request is + created. + signature (str, optional): The signature for the transaction. + Defaults to None. + signed_request (dict, optional): The signed request for the transaction. + Defaults to None. + expires_time (str, optional): The time till which the endorser should endorse + the transaction. Defaults to None. + endorser_write_txn (bool, optional): Flag indicating if the endorser should + write the transaction. Defaults to False. + author_goal_code (str, optional): The goal code for the author. + Defaults to None. + signer_goal_code (str, optional): The goal code for the signer. + Defaults to None. Returns: - The transaction Record and transaction request + Tuple[TransactionRecord, TransactionRequest]: The transaction record and + transaction request. + + Raises: + TransactionManagerError: If the transaction record is not in the + 'STATE_TRANSACTION_CREATED' state. """ @@ -216,6 +234,7 @@ async def create_endorse_response( Args: transaction: The transaction record which would be endorsed. state: The state of the transaction record + use_endorser_did: The public did of the endorser Returns: The updated transaction and an endorsed response @@ -392,6 +411,7 @@ async def complete_transaction( Args: transaction: The transaction record which would be completed + endorser: True if the endorser is writing the ledger transaction Returns: The updated transaction @@ -556,6 +576,7 @@ async def create_refuse_response( Args: transaction: The transaction record which would be refused state: The state of the transaction record + refuser_did: The public did of the refuser Returns: The updated transaction and the refused response @@ -787,6 +808,8 @@ async def endorsed_txn_post_processing( Args: transaction: The transaction from which the schema/cred_def would be stored in wallet. + ledger_response: The ledger response + connection_record: The connection record """ if isinstance(ledger_response, str): diff --git a/aries_cloudagent/protocols/endorse_transaction/v1_0/messages/cancel_transaction.py b/aries_cloudagent/protocols/endorse_transaction/v1_0/messages/cancel_transaction.py index 6c338f33fb..5785acc2ed 100644 --- a/aries_cloudagent/protocols/endorse_transaction/v1_0/messages/cancel_transaction.py +++ b/aries_cloudagent/protocols/endorse_transaction/v1_0/messages/cancel_transaction.py @@ -33,6 +33,7 @@ def __init__( Args: state: State of the transaction record thread_id: Thread id of transaction record + kwargs: Additional keyword arguments for the message """ super().__init__(**kwargs) diff --git a/aries_cloudagent/protocols/endorse_transaction/v1_0/messages/endorsed_transaction_response.py b/aries_cloudagent/protocols/endorse_transaction/v1_0/messages/endorsed_transaction_response.py index c51a5fe7a0..45073967bb 100644 --- a/aries_cloudagent/protocols/endorse_transaction/v1_0/messages/endorsed_transaction_response.py +++ b/aries_cloudagent/protocols/endorse_transaction/v1_0/messages/endorsed_transaction_response.py @@ -41,6 +41,8 @@ def __init__( signature_response: The response created to endorse the transaction state: The state of the transaction record endorser_did: The public did of the endorser who endorses the transaction + ledger_response: The response from the ledger + kwargs: Additional keyword arguments for the message """ super().__init__(**kwargs) diff --git a/aries_cloudagent/protocols/endorse_transaction/v1_0/messages/messages_attach.py b/aries_cloudagent/protocols/endorse_transaction/v1_0/messages/messages_attach.py index f3ab33e7aa..366dce27b9 100644 --- a/aries_cloudagent/protocols/endorse_transaction/v1_0/messages/messages_attach.py +++ b/aries_cloudagent/protocols/endorse_transaction/v1_0/messages/messages_attach.py @@ -40,9 +40,11 @@ def __init__( author_verkey: The verkey of the author who creates the transaction endorser_did: The public did of the endorser who endorses the transaction transaction_message: The actual data present in the transaction payload + transaction_type: The type of transaction mechanism: The mechanism of the latest TAA present on the ledger taaDigest: The digest of the latest TAA present on the ledger time: The time when the latest TAA was set/enabled + kwargs: Additional keyword arguments for the message """ super().__init__(**kwargs) diff --git a/aries_cloudagent/protocols/endorse_transaction/v1_0/messages/refused_transaction_response.py b/aries_cloudagent/protocols/endorse_transaction/v1_0/messages/refused_transaction_response.py index 2f585d18b9..0140ecd237 100644 --- a/aries_cloudagent/protocols/endorse_transaction/v1_0/messages/refused_transaction_response.py +++ b/aries_cloudagent/protocols/endorse_transaction/v1_0/messages/refused_transaction_response.py @@ -40,6 +40,7 @@ def __init__( signature_response: The response created to refuse the transaction state: The state of the transaction record endorser_did: The public did of the endorser who refuses the transaction + kwargs: Additional keyword arguments for the message """ super().__init__(**kwargs) diff --git a/aries_cloudagent/protocols/endorse_transaction/v1_0/messages/transaction_acknowledgement.py b/aries_cloudagent/protocols/endorse_transaction/v1_0/messages/transaction_acknowledgement.py index 8328403a79..90697d2d08 100644 --- a/aries_cloudagent/protocols/endorse_transaction/v1_0/messages/transaction_acknowledgement.py +++ b/aries_cloudagent/protocols/endorse_transaction/v1_0/messages/transaction_acknowledgement.py @@ -33,6 +33,8 @@ def __init__( Args: thread_id: Thread id of transaction record + ledger_response: Response from the ledger + kwargs: Additional keyword arguments for the message """ super().__init__(**kwargs) self.thread_id = thread_id diff --git a/aries_cloudagent/protocols/endorse_transaction/v1_0/messages/transaction_job_to_send.py b/aries_cloudagent/protocols/endorse_transaction/v1_0/messages/transaction_job_to_send.py index d4df7cc542..05758c36d1 100644 --- a/aries_cloudagent/protocols/endorse_transaction/v1_0/messages/transaction_job_to_send.py +++ b/aries_cloudagent/protocols/endorse_transaction/v1_0/messages/transaction_job_to_send.py @@ -31,6 +31,7 @@ def __init__( Args: job: The job that needs to be send + kwargs: Additional keyword arguments for the message """ diff --git a/aries_cloudagent/protocols/endorse_transaction/v1_0/messages/transaction_request.py b/aries_cloudagent/protocols/endorse_transaction/v1_0/messages/transaction_request.py index 4bd8154663..5618a3b56d 100644 --- a/aries_cloudagent/protocols/endorse_transaction/v1_0/messages/transaction_request.py +++ b/aries_cloudagent/protocols/endorse_transaction/v1_0/messages/transaction_request.py @@ -40,6 +40,8 @@ def __init__( timing: The time till the endorser should endorse/refuse a transaction transaction_type: The type of transaction messages_attach: The attached message describing the actual transaction + endorser_write_txn: Request Endorser to write the ledger transaction + kwargs: Additional keyword arguments for the message """ super().__init__(**kwargs) self.transaction_id = transaction_id diff --git a/aries_cloudagent/protocols/endorse_transaction/v1_0/messages/transaction_resend.py b/aries_cloudagent/protocols/endorse_transaction/v1_0/messages/transaction_resend.py index c38f7154f5..929ebdcd2a 100644 --- a/aries_cloudagent/protocols/endorse_transaction/v1_0/messages/transaction_resend.py +++ b/aries_cloudagent/protocols/endorse_transaction/v1_0/messages/transaction_resend.py @@ -33,6 +33,7 @@ def __init__( Args: state: State of the transaction record thread_id: Thread id of transaction record + kwargs: Additional keyword arguments for the message """ super().__init__(**kwargs) diff --git a/aries_cloudagent/protocols/introduction/v0_1/messages/forward_invitation.py b/aries_cloudagent/protocols/introduction/v0_1/messages/forward_invitation.py index 9a310eb506..3fd441e6be 100644 --- a/aries_cloudagent/protocols/introduction/v0_1/messages/forward_invitation.py +++ b/aries_cloudagent/protocols/introduction/v0_1/messages/forward_invitation.py @@ -32,6 +32,7 @@ def __init__( Args: invitation: The connection invitation message: Comments on the introduction + kwargs: Additional key word arguments for the message """ super().__init__(**kwargs) self.invitation = invitation diff --git a/aries_cloudagent/protocols/introduction/v0_1/messages/invitation.py b/aries_cloudagent/protocols/introduction/v0_1/messages/invitation.py index dae4a5e3a9..9f94e0fa7f 100644 --- a/aries_cloudagent/protocols/introduction/v0_1/messages/invitation.py +++ b/aries_cloudagent/protocols/introduction/v0_1/messages/invitation.py @@ -30,6 +30,7 @@ def __init__( Args: invitation: The connection invitation message: Comments on the introduction + kwargs: Additional key word arguments for the message """ super().__init__(**kwargs) self.invitation = invitation diff --git a/aries_cloudagent/protocols/introduction/v0_1/messages/invitation_request.py b/aries_cloudagent/protocols/introduction/v0_1/messages/invitation_request.py index d452219437..ec55ebddc3 100644 --- a/aries_cloudagent/protocols/introduction/v0_1/messages/invitation_request.py +++ b/aries_cloudagent/protocols/introduction/v0_1/messages/invitation_request.py @@ -26,6 +26,7 @@ def __init__(self, *, responder: str = None, message: str = None, **kwargs): Args: responder: The name of the agent initiating the introduction message: Comments on the introduction + kwargs: Additional key word arguments for the message """ super().__init__(**kwargs) self.responder = responder diff --git a/aries_cloudagent/protocols/issue_credential/v1_0/manager.py b/aries_cloudagent/protocols/issue_credential/v1_0/manager.py index 0122e898bf..3714efa0ea 100644 --- a/aries_cloudagent/protocols/issue_credential/v1_0/manager.py +++ b/aries_cloudagent/protocols/issue_credential/v1_0/manager.py @@ -97,6 +97,7 @@ async def prepare_send( connection_id: Connection to create offer for credential_proposal: The credential proposal with preview auto_remove: Flag to automatically remove the record on completion + comment: Optional human-readable comment to set in offer message Returns: A tuple of the new credential exchange record and credential offer message @@ -152,6 +153,7 @@ async def create_proposal( schema_version: Schema version for credential proposal cred_def_id: Credential definition id for credential proposal issuer_did: Issuer DID for credential proposal + trace: Whether to trace the operation Returns: Resulting credential exchange record including credential proposal @@ -229,6 +231,7 @@ async def create_offer( Args: cred_ex_record: Credential exchange to create offer for + counter_proposal: optional proposal to counter comment: optional human-readable comment to set in offer message Returns: @@ -512,10 +515,17 @@ async def receive_request( """Receive a credential request. Args: - credential_request_message: Credential request to receive + message (CredentialRequest): The credential request message to receive. + connection_record (Optional[ConnRecord]): The connection record associated + with the request. + oob_record (Optional[OobRecord]): The out-of-band record associated with the + request. Returns: - credential exchange record, retrieved and updated + V10CredentialExchange: The credential exchange record, retrieved and updated. + + Raises: + StorageNotFoundError: If the credential exchange record is not found. """ assert len(message.requests_attach or []) == 1 @@ -576,6 +586,7 @@ async def issue_credential( cred_ex_record: The credential exchange record for which to issue a credential comment: optional human-readable comment pertaining to credential issue + retries: how many times to retry on error Returns: Tuple: (Updated credential exchange record, credential message) diff --git a/aries_cloudagent/protocols/issue_credential/v1_0/messages/credential_issue.py b/aries_cloudagent/protocols/issue_credential/v1_0/messages/credential_issue.py index 45d2ac5561..88438ff030 100644 --- a/aries_cloudagent/protocols/issue_credential/v1_0/messages/credential_issue.py +++ b/aries_cloudagent/protocols/issue_credential/v1_0/messages/credential_issue.py @@ -39,6 +39,7 @@ def __init__( Args: comment: optional comment credentials_attach: credentials attachments + kwargs: additional key-value arguments to map into message class properties """ super().__init__(_id=_id, **kwargs) diff --git a/aries_cloudagent/protocols/issue_credential/v1_0/messages/credential_offer.py b/aries_cloudagent/protocols/issue_credential/v1_0/messages/credential_offer.py index 6077b7367e..c50ff498eb 100644 --- a/aries_cloudagent/protocols/issue_credential/v1_0/messages/credential_offer.py +++ b/aries_cloudagent/protocols/issue_credential/v1_0/messages/credential_offer.py @@ -42,6 +42,7 @@ def __init__( comment: optional human-readable comment credential_preview: credential preview offers_attach: list of offer attachments + kwargs: additional key-value arguments to map into message class properties """ super().__init__(_id=_id, **kwargs) diff --git a/aries_cloudagent/protocols/issue_credential/v1_0/messages/credential_problem_report.py b/aries_cloudagent/protocols/issue_credential/v1_0/messages/credential_problem_report.py index 7c7f912684..2c5372997e 100644 --- a/aries_cloudagent/protocols/issue_credential/v1_0/messages/credential_problem_report.py +++ b/aries_cloudagent/protocols/issue_credential/v1_0/messages/credential_problem_report.py @@ -1,13 +1,11 @@ """A problem report message.""" import logging - from enum import Enum -from marshmallow import EXCLUDE, validates_schema, ValidationError +from marshmallow import EXCLUDE, ValidationError, validates_schema from ....problem_report.v1_0.message import ProblemReport, ProblemReportSchema - from ..message_types import CREDENTIAL_PROBLEM_REPORT, PROTOCOL_PACKAGE HANDLER_CLASS = ( @@ -54,6 +52,7 @@ def validate_fields(self, data, **kwargs): Args: data: The data to validate + kwargs: Additional keyword arguments """ if not data.get("description", {}).get("code", ""): diff --git a/aries_cloudagent/protocols/issue_credential/v1_0/messages/credential_proposal.py b/aries_cloudagent/protocols/issue_credential/v1_0/messages/credential_proposal.py index d743764cca..75bf0b89a6 100644 --- a/aries_cloudagent/protocols/issue_credential/v1_0/messages/credential_proposal.py +++ b/aries_cloudagent/protocols/issue_credential/v1_0/messages/credential_proposal.py @@ -56,6 +56,7 @@ def __init__( schema_version: schema version cred_def_id: credential definition identifier issuer_did: credential issuer DID + kwargs: additional key-value arguments to map into message class properties """ super().__init__(_id, **kwargs) self.comment = comment diff --git a/aries_cloudagent/protocols/issue_credential/v1_0/messages/credential_request.py b/aries_cloudagent/protocols/issue_credential/v1_0/messages/credential_request.py index df7b98d5c2..b76ed8a7f0 100644 --- a/aries_cloudagent/protocols/issue_credential/v1_0/messages/credential_request.py +++ b/aries_cloudagent/protocols/issue_credential/v1_0/messages/credential_request.py @@ -37,8 +37,9 @@ def __init__( """Initialize credential request object. Args: - requests_attach: requests attachments comment: optional comment + requests_attach: requests attachments + kwargs: additional key-value arguments to map into message class properties """ super().__init__(_id=_id, **kwargs) diff --git a/aries_cloudagent/protocols/issue_credential/v1_0/messages/inner/credential_preview.py b/aries_cloudagent/protocols/issue_credential/v1_0/messages/inner/credential_preview.py index 0e9f011e11..f7afb52a6b 100644 --- a/aries_cloudagent/protocols/issue_credential/v1_0/messages/inner/credential_preview.py +++ b/aries_cloudagent/protocols/issue_credential/v1_0/messages/inner/credential_preview.py @@ -26,6 +26,7 @@ def __init__(self, *, name: str, value: str, mime_type: str = None, **kwargs): value: attribute value; caller must base64-encode for attributes with non-empty MIME type mime_type: MIME type (default null) + kwargs: additional keyword arguments to map into message class properties """ super().__init__(**kwargs) @@ -122,6 +123,7 @@ def __init__( "value": "cG90YXRv" } ] + kwargs: additional keyword arguments to map into message class properties """ super().__init__(**kwargs) diff --git a/aries_cloudagent/protocols/issue_credential/v1_0/models/credential_exchange.py b/aries_cloudagent/protocols/issue_credential/v1_0/models/credential_exchange.py index 2137d04986..9406bd4c82 100644 --- a/aries_cloudagent/protocols/issue_credential/v1_0/models/credential_exchange.py +++ b/aries_cloudagent/protocols/issue_credential/v1_0/models/credential_exchange.py @@ -202,9 +202,10 @@ async def save_error_state( Args: session: The profile session to use + state: The state to set reason: A reason to add to the log log_params: Additional parameters to log - override: Override configured logging regimen, print to stderr instead + log_override: Override configured logging regimen, print to stderr instead """ if self._last_state == state: # already done diff --git a/aries_cloudagent/protocols/issue_credential/v2_0/__init__.py b/aries_cloudagent/protocols/issue_credential/v2_0/__init__.py index 619b53cda5..c133f312d7 100644 --- a/aries_cloudagent/protocols/issue_credential/v2_0/__init__.py +++ b/aries_cloudagent/protocols/issue_credential/v2_0/__init__.py @@ -2,8 +2,7 @@ from ....connections.models.conn_record import ConnRecord from ....core.error import BaseError - -from .messages.cred_problem_report import V20CredProblemReport, ProblemReportReason +from .messages.cred_problem_report import ProblemReportReason, V20CredProblemReport from .models.cred_ex_record import V20CredExRecord @@ -17,6 +16,7 @@ def problem_report_for_record( Args: record: connection or exchange record desc_en: description text to include in problem report + thread_id: thread id to assign to problem report """ result = V20CredProblemReport( diff --git a/aries_cloudagent/protocols/issue_credential/v2_0/formats/vc_di/models/cred.py b/aries_cloudagent/protocols/issue_credential/v2_0/formats/vc_di/models/cred.py index 0a7eafeb27..76d4f46882 100644 --- a/aries_cloudagent/protocols/issue_credential/v2_0/formats/vc_di/models/cred.py +++ b/aries_cloudagent/protocols/issue_credential/v2_0/formats/vc_di/models/cred.py @@ -1,8 +1,9 @@ """Cred request artifacts to attach to RFC 453 messages.""" -from .......messaging.models.base import BaseModel, BaseModelSchema from marshmallow import EXCLUDE, fields +from .......messaging.models.base import BaseModel, BaseModelSchema + class VCDIIndyCredential(BaseModel): """VCDI Indy credential.""" @@ -20,10 +21,8 @@ def __init__( """Initialize vcdi cred abstract object. Args: - data_model_versions_supported: supported versions for data model - binding_required: boolean value - binding_methods: required if binding_required is true credential: credential object + kwargs: additional keyword arguments """ super().__init__(**kwargs) self.credential = credential diff --git a/aries_cloudagent/protocols/issue_credential/v2_0/formats/vc_di/models/cred_offer.py b/aries_cloudagent/protocols/issue_credential/v2_0/formats/vc_di/models/cred_offer.py index c42ba32174..caf6b7d9dc 100644 --- a/aries_cloudagent/protocols/issue_credential/v2_0/formats/vc_di/models/cred_offer.py +++ b/aries_cloudagent/protocols/issue_credential/v2_0/formats/vc_di/models/cred_offer.py @@ -1,20 +1,21 @@ """Cred request artifacts to attach to RFC 453 messages.""" from typing import Sequence, Union + +from marshmallow import EXCLUDE, fields + from .......indy.models.cred_abstract import IndyKeyCorrectnessProofSchema from .......messaging.models.base import BaseModel, BaseModelSchema -from .......vc.vc_ld.models.credential import ( - CredentialSchema, - VerifiableCredential, -) from .......messaging.valid import ( INDY_CRED_DEF_ID_EXAMPLE, INDY_CRED_DEF_ID_VALIDATE, NUM_STR_WHOLE_EXAMPLE, NUM_STR_WHOLE_VALIDATE, ) - -from marshmallow import EXCLUDE, fields +from .......vc.vc_ld.models.credential import ( + CredentialSchema, + VerifiableCredential, +) class AnoncredsLinkSecret(BaseModel): @@ -174,8 +175,9 @@ def __init__( Args: data_model_versions_supported: supported versions for data model binding_required: boolean value - binding_methods: required if binding_required is true + binding_method: required if binding_required is true credential: credential object + kwargs: additional key-value arguments to map into message class properties """ super().__init__(**kwargs) self.data_model_versions_supported = data_model_versions_supported diff --git a/aries_cloudagent/protocols/issue_credential/v2_0/manager.py b/aries_cloudagent/protocols/issue_credential/v2_0/manager.py index 4cf5bf9651..0bf492b7b9 100644 --- a/aries_cloudagent/protocols/issue_credential/v2_0/manager.py +++ b/aries_cloudagent/protocols/issue_credential/v2_0/manager.py @@ -1,21 +1,19 @@ """V2.0 issue-credential protocol manager.""" import logging - from typing import Mapping, Optional, Tuple from ....connections.models.conn_record import ConnRecord -from ....core.oob_processor import OobRecord from ....core.error import BaseError +from ....core.oob_processor import OobRecord from ....core.profile import Profile from ....messaging.responder import BaseResponder from ....storage.error import StorageError, StorageNotFoundError - from .messages.cred_ack import V20CredAck from .messages.cred_format import V20CredFormat from .messages.cred_issue import V20CredIssue from .messages.cred_offer import V20CredOffer -from .messages.cred_problem_report import V20CredProblemReport, ProblemReportReason +from .messages.cred_problem_report import ProblemReportReason, V20CredProblemReport from .messages.cred_proposal import V20CredProposal from .messages.cred_request import V20CredRequest from .messages.inner.cred_preview import V20CredPreview @@ -204,12 +202,22 @@ async def create_offer( """Create credential offer, update credential exchange record. Args: - cred_ex_record: credential exchange record for which to create offer - replacement_id: identifier to help coordinate credential replacement - comment: optional human-readable comment to set in offer message + cred_ex_record (V20CredExRecord): The credential exchange record for + which to create the offer. + counter_proposal (V20CredProposal, optional): The counter proposal for + the credential offer. Defaults to None. + replacement_id (str, optional): Identifier to help coordinate credential + replacement. Defaults to None. + comment (str, optional): Optional human-readable comment to set in the + offer message. Defaults to None. Returns: - A tuple (credential exchange record, credential offer message) + Tuple[V20CredExRecord, V20CredOffer]: A tuple containing the updated + credential exchange record and the credential offer message. + + Raises: + V20CredManagerError: If unable to create the credential offer due to no + supported formats. """ @@ -399,12 +407,20 @@ async def receive_request( ) -> V20CredExRecord: """Receive a credential request. + This method is called when a credential request is received from a connection. + It processes the request, updates the credential exchange record, and returns + the updated record. + Args: - cred_request_message: credential request to receive - connection_id: connection identifier + cred_request_message: The credential request to receive. + connection_record: The connection record associated with the request. + oob_record: The out-of-band record associated with the request. Returns: - credential exchange record, updated + The updated credential exchange record. + + Raises: + StorageNotFoundError: If the credential exchange record is not found. """ # connection_id is None in the record if this is in response to diff --git a/aries_cloudagent/protocols/issue_credential/v2_0/messages/cred_issue.py b/aries_cloudagent/protocols/issue_credential/v2_0/messages/cred_issue.py index 1154b4db07..f029b15d23 100644 --- a/aries_cloudagent/protocols/issue_credential/v2_0/messages/cred_issue.py +++ b/aries_cloudagent/protocols/issue_credential/v2_0/messages/cred_issue.py @@ -39,10 +39,13 @@ def __init__( """Initialize credential issue object. Args: + _id: The identifier for the credential issue. + replacement_id: unique to issuer, to coordinate credential replacement comment: optional comment - credentials_attach: credentials attachments formats: acceptable attachment formats filter_attach: list of credential attachments + credentials_attach: credentials attachments + kwargs: additional key-value arguments to map into message class properties """ super().__init__(_id=_id, **kwargs) diff --git a/aries_cloudagent/protocols/issue_credential/v2_0/messages/cred_offer.py b/aries_cloudagent/protocols/issue_credential/v2_0/messages/cred_offer.py index f6dd4d0de8..0ca4b3db29 100644 --- a/aries_cloudagent/protocols/issue_credential/v2_0/messages/cred_offer.py +++ b/aries_cloudagent/protocols/issue_credential/v2_0/messages/cred_offer.py @@ -46,6 +46,7 @@ def __init__( credential_preview: credential preview formats: acceptable attachment formats offers_attach: list of offer attachments + kwargs: additional key-value arguments to map into message class properties """ super().__init__(_id=_id, **kwargs) diff --git a/aries_cloudagent/protocols/issue_credential/v2_0/messages/cred_problem_report.py b/aries_cloudagent/protocols/issue_credential/v2_0/messages/cred_problem_report.py index efd80ee8d5..24df964170 100644 --- a/aries_cloudagent/protocols/issue_credential/v2_0/messages/cred_problem_report.py +++ b/aries_cloudagent/protocols/issue_credential/v2_0/messages/cred_problem_report.py @@ -1,13 +1,11 @@ """A problem report message.""" import logging - from enum import Enum from marshmallow import EXCLUDE, ValidationError, validates_schema from ....problem_report.v1_0.message import ProblemReport, ProblemReportSchema - from ..message_types import CRED_20_PROBLEM_REPORT, PROTOCOL_PACKAGE HANDLER_CLASS = ( @@ -54,6 +52,7 @@ def validate_fields(self, data, **kwargs): Args: data: The data to validate + kwargs: Additional keyword arguments """ if not data.get("description", {}).get("code", ""): diff --git a/aries_cloudagent/protocols/issue_credential/v2_0/messages/cred_proposal.py b/aries_cloudagent/protocols/issue_credential/v2_0/messages/cred_proposal.py index d09d71c6d1..4ad4898241 100644 --- a/aries_cloudagent/protocols/issue_credential/v2_0/messages/cred_proposal.py +++ b/aries_cloudagent/protocols/issue_credential/v2_0/messages/cred_proposal.py @@ -42,9 +42,10 @@ def __init__( Args: comment: optional human-readable comment - credential_proposal: proposed credential preview + credential_preview: proposed credential preview formats: acceptable attachment formats filters_attach: list of attachments filtering credential proposal + kwargs: additional key-value arguments to map into message class properties """ super().__init__(_id=_id, **kwargs) diff --git a/aries_cloudagent/protocols/issue_credential/v2_0/messages/cred_request.py b/aries_cloudagent/protocols/issue_credential/v2_0/messages/cred_request.py index 193638f2eb..87a575d160 100644 --- a/aries_cloudagent/protocols/issue_credential/v2_0/messages/cred_request.py +++ b/aries_cloudagent/protocols/issue_credential/v2_0/messages/cred_request.py @@ -39,10 +39,13 @@ def __init__( """Initialize credential request object. Args: - requests_attach: requests attachments - comment: optional comment - formats: acceptable attachment formats - requests_attach: list of request attachments + _id (str): The identifier for the credential request. + comment (str, optional): An optional comment for the credential request. + formats (Sequence[V20CredFormat], optional): A list of acceptable attachment + formats. + requests_attach (Sequence[AttachDecorator], optional): A list of request + attachments. + kwargs: Additional key-value arguments to map into message class properties. """ super().__init__(_id=_id, **kwargs) diff --git a/aries_cloudagent/protocols/issue_credential/v2_0/messages/inner/cred_preview.py b/aries_cloudagent/protocols/issue_credential/v2_0/messages/inner/cred_preview.py index 85256fc9f0..a8efb2363f 100644 --- a/aries_cloudagent/protocols/issue_credential/v2_0/messages/inner/cred_preview.py +++ b/aries_cloudagent/protocols/issue_credential/v2_0/messages/inner/cred_preview.py @@ -26,6 +26,7 @@ def __init__(self, *, name: str, value: str, mime_type: str = None, **kwargs): value: attribute value; caller must base64-encode for attributes with non-empty MIME type mime_type: MIME type (default null) + kwargs: additional keyword arguments """ super().__init__(**kwargs) @@ -126,6 +127,7 @@ def __init__( "value": "cG90YXRv" }, ] + kwargs: additional keyword arguments """ super().__init__(**kwargs) diff --git a/aries_cloudagent/protocols/issue_credential/v2_0/models/cred_ex_record.py b/aries_cloudagent/protocols/issue_credential/v2_0/models/cred_ex_record.py index 1eece14bac..5737375680 100644 --- a/aries_cloudagent/protocols/issue_credential/v2_0/models/cred_ex_record.py +++ b/aries_cloudagent/protocols/issue_credential/v2_0/models/cred_ex_record.py @@ -158,9 +158,10 @@ async def save_error_state( Args: session: The profile session to use + state: The state to set reason: A reason to add to the log log_params: Additional parameters to log - override: Override configured logging regimen, print to stderr instead + log_override: Override configured logging regimen, print to stderr instead """ if self._last_state == state: # already done diff --git a/aries_cloudagent/protocols/issue_credential/v2_0/routes.py b/aries_cloudagent/protocols/issue_credential/v2_0/routes.py index aecbb6778d..8803356ce9 100644 --- a/aries_cloudagent/protocols/issue_credential/v2_0/routes.py +++ b/aries_cloudagent/protocols/issue_credential/v2_0/routes.py @@ -239,6 +239,7 @@ def validate_fields(self, data, **kwargs): Args: data: The data to validate + kwargs: Additional keyword arguments Raises: ValidationError: if data has neither indy nor ld_proof diff --git a/aries_cloudagent/protocols/notification/v1_0/messages/ack.py b/aries_cloudagent/protocols/notification/v1_0/messages/ack.py index 3c3b3345fd..c5f3accf78 100644 --- a/aries_cloudagent/protocols/notification/v1_0/messages/ack.py +++ b/aries_cloudagent/protocols/notification/v1_0/messages/ack.py @@ -23,6 +23,7 @@ def __init__(self, status: str = None, **kwargs): Args: status: Status (default OK) + kwargs: Additional message keyword arguments """ super().__init__(**kwargs) diff --git a/aries_cloudagent/protocols/out_of_band/v1_0/manager.py b/aries_cloudagent/protocols/out_of_band/v1_0/manager.py index e1dff21923..236b5ef1e3 100644 --- a/aries_cloudagent/protocols/out_of_band/v1_0/manager.py +++ b/aries_cloudagent/protocols/out_of_band/v1_0/manager.py @@ -600,27 +600,40 @@ async def create_invitation( ) -> InvitationRecord: """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. + This method generates a new connection invitation, which 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. Args: - my_label: label for this connection - my_endpoint: endpoint where other party can reach me - auto_accept: auto-accept a corresponding connection request - (None to use config) - public: set to create an invitation from the public DID - hs_protos: list of handshake protocols to include - multi_use: set to True to create an invitation for multiple-use connection - alias: optional alias to apply to connection for later use - attachments: list of dicts in form of {"id": ..., "type": ...} - service_accept: Optional list of mime types in the order of preference of - the sender that the receiver can use in responding to the message - protocol_version: OOB protocol version [1.0, 1.1] - goal_code: Optional self-attested code for receiver logic - goal: Optional self-attested string for receiver logic + my_label (Optional[str]): Label for this connection. + my_endpoint (Optional[str]): Endpoint where the other party can reach me. + auto_accept (Optional[bool]): Auto-accept a corresponding connection request + (None to use config). + public (bool): Set to True to create an invitation from the public DID. + use_did (Optional[str]): DID to use for the invitation. + use_did_method (Optional[str]): DID method to use for the invitation. + hs_protos (Optional[Sequence[HSProto]]): List of handshake protocols to + include. + multi_use (bool): Set to True to create an invitation for multiple-use + connection. + create_unique_did (bool): Set to True to create a unique DID for the + invitation. + alias (Optional[str]): Optional alias to apply to the connection for later + use. + attachments (Optional[Sequence[Mapping]]): List of attachments in the form of + {"id": ..., "type": ...}. + metadata (Optional[dict]): Additional metadata for the invitation. + mediation_id (Optional[str]): Mediation ID for the invitation. + service_accept (Optional[Sequence[Text]]): Optional list of mime types in the + order of preference of the sender that the receiver can use in responding + to the message. + protocol_version (Optional[Text]): OOB protocol version [1.0, 1.1]. + goal_code (Optional[Text]): Optional self-attested code for receiver logic. + goal (Optional[Text]): Optional self-attested string for receiver logic. + Returns: - Invitation record + InvitationRecord: The generated invitation record. """ creator = InvitationCreator( @@ -1151,6 +1164,7 @@ async def _create_handshake_reuse_message( Args: oob_record: OOB Record conn_record: Connection record associated with the oob record + version: The version of the OOB protocol Returns: OobRecord: The oob record with updated state and reuse_msg_id. @@ -1238,6 +1252,7 @@ async def receive_reuse_message( Args: reuse_msg: The `HandshakeReuse` to process receipt: The message receipt + conn_rec: The connection record associated with the message Returns: None @@ -1313,6 +1328,7 @@ async def receive_reuse_accepted_message( Args: reuse_accepted_msg: The `HandshakeReuseAccept` to process receipt: The message receipt + conn_record: The connection record associated with the message Returns: None @@ -1392,6 +1408,7 @@ async def receive_problem_report( Args: problem_report: The `OOBProblemReport` to process receipt: The message receipt + conn_record: The connection record associated with the OOB record Returns: None diff --git a/aries_cloudagent/protocols/out_of_band/v1_0/messages/invitation.py b/aries_cloudagent/protocols/out_of_band/v1_0/messages/invitation.py index 80ebc284fe..252d26dfba 100644 --- a/aries_cloudagent/protocols/out_of_band/v1_0/messages/invitation.py +++ b/aries_cloudagent/protocols/out_of_band/v1_0/messages/invitation.py @@ -15,7 +15,8 @@ from .....wallet.util import b64_to_bytes, bytes_to_b64 from ....connections.v1_0.message_types import ARIES_PROTOCOL as CONN_PROTO from ....didcomm_prefix import DIDCommPrefix -from ....didexchange.v1_0.message_types import ARIES_PROTOCOL as DIDEX_1_1, DIDEX_1_0 +from ....didexchange.v1_0.message_types import ARIES_PROTOCOL as DIDEX_1_1 +from ....didexchange.v1_0.message_types import DIDEX_1_0 from ..message_types import DEFAULT_VERSION, INVITATION from .service import Service @@ -136,10 +137,22 @@ def __init__( """Initialize invitation message object. Args: - requests_attach: request attachments + label (Optional[str]): The label for the invitation. + image_url (Optional[str]): The URL of an image associated with the invitation. + handshake_protocols (Optional[Sequence[Text]]): The supported handshake + protocols. + requests_attach (Optional[Sequence[AttachDecorator]]): The request + attachments. + services (Optional[Sequence[Union[Service, Text]]]): The services associated + with the invitation. + accept (Optional[Sequence[Text]]): The accepted protocols. + version (str): The version of the invitation message. + msg_type (Optional[Text]): The type of the invitation message. + goal_code (Optional[Text]): The goal code. + goal (Optional[Text]): The goal. + kwargs: Additional keyword arguments. """ - # super().__init__(_id=_id, **kwargs) super().__init__(_type=msg_type, _version=version, **kwargs) self.label = label self.image_url = image_url @@ -304,6 +317,7 @@ def validate_fields(self, data, **kwargs): Args: data: The data to validate + kwargs: Additional keyword arguments Raises: ValidationError: If any of the fields do not validate """ diff --git a/aries_cloudagent/protocols/out_of_band/v1_0/messages/service.py b/aries_cloudagent/protocols/out_of_band/v1_0/messages/service.py index 92ac2a7b88..e1daaeb853 100644 --- a/aries_cloudagent/protocols/out_of_band/v1_0/messages/service.py +++ b/aries_cloudagent/protocols/out_of_band/v1_0/messages/service.py @@ -34,10 +34,10 @@ def __init__( """Initialize a Service instance. Args: - id: An identifier for this service block - type: A type for this service block + _id: An identifier for this service block + _type: A type for this service block did: A did for the connection - recipient_key: A list of recipient keys in W3C did:key format + recipient_keys: A list of recipient keys in W3C did:key format routing_keys: A list of routing keys in W3C did:key format service_endpoint: An endpoint for the connection """ diff --git a/aries_cloudagent/protocols/present_proof/dif/pres_exch_handler.py b/aries_cloudagent/protocols/present_proof/dif/pres_exch_handler.py index d46415abee..0a32d9b155 100644 --- a/aries_cloudagent/protocols/present_proof/dif/pres_exch_handler.py +++ b/aries_cloudagent/protocols/present_proof/dif/pres_exch_handler.py @@ -1047,6 +1047,7 @@ async def apply_requirements( Args: req: Requirement credentials: Sequence of credentials to check against + records_filter: dict of input_descriptor ID key to list of credential_json Return: dict of input_descriptor ID key to list of credential_json """ @@ -1202,10 +1203,14 @@ async def create_vp( """Create VerifiablePresentation. Args: - credentials: Sequence of VCRecords - pd: PresentationDefinition - Return: - VerifiablePresentation + credentials (Sequence[VCRecord]): Sequence of VCRecords. + pd (PresentationDefinition): PresentationDefinition. + challenge (str, optional): Challenge string. Defaults to None. + domain (str, optional): Domain string. Defaults to None. + records_filter (dict, optional): Records filter dictionary. Defaults to None. + + Returns: + Union[Sequence[dict], dict]: VerifiablePresentation. """ document_loader = self.profile.inject(DocumentLoader) req = await self.make_requirement( diff --git a/aries_cloudagent/protocols/present_proof/v1_0/manager.py b/aries_cloudagent/protocols/present_proof/v1_0/manager.py index 187842fde5..00f72b3b98 100644 --- a/aries_cloudagent/protocols/present_proof/v1_0/manager.py +++ b/aries_cloudagent/protocols/present_proof/v1_0/manager.py @@ -4,7 +4,6 @@ import logging from typing import Optional -from ...out_of_band.v1_0.models.oob_record import OobRecord from ....connections.models.conn_record import ConnRecord from ....core.error import BaseError from ....core.profile import Profile @@ -12,8 +11,10 @@ from ....messaging.decorators.attach_decorator import AttachDecorator from ....messaging.responder import BaseResponder from ....storage.error import StorageNotFoundError +from ...out_of_band.v1_0.models.oob_record import OobRecord from ..indy.pres_exch_handler import IndyPresExchHandler - +from .message_types import ATTACH_DECO_IDS, PRESENTATION, PRESENTATION_REQUEST +from .messages.presentation import Presentation from .messages.presentation_ack import PresentationAck from .messages.presentation_problem_report import ( PresentationProblemReport, @@ -21,8 +22,6 @@ ) from .messages.presentation_proposal import PresentationProposal from .messages.presentation_request import PresentationRequest -from .messages.presentation import Presentation -from .message_types import ATTACH_DECO_IDS, PRESENTATION, PRESENTATION_REQUEST from .models.presentation_exchange import V10PresentationExchange LOGGER = logging.getLogger(__name__) @@ -406,6 +405,7 @@ async def verify_presentation( Args: presentation_exchange_record: presentation exchange record with presentation request and presentation to verify + responder: responder to use Returns: presentation record, updated @@ -453,6 +453,7 @@ async def send_presentation_ack( Args: presentation_exchange_record: presentation exchange record with thread id + responder: Responder to use """ responder = responder or self._profile.inject_or(BaseResponder) diff --git a/aries_cloudagent/protocols/present_proof/v1_0/messages/presentation.py b/aries_cloudagent/protocols/present_proof/v1_0/messages/presentation.py index 46abf095bf..3458431dbf 100644 --- a/aries_cloudagent/protocols/present_proof/v1_0/messages/presentation.py +++ b/aries_cloudagent/protocols/present_proof/v1_0/messages/presentation.py @@ -35,8 +35,10 @@ def __init__( """Initialize presentation object. Args: - presentations_attach: attachments - comment: optional comment + _id (str): The ID of the presentation object. + comment (str, optional): An optional comment. + presentations_attach (Sequence[AttachDecorator], optional): Attachments. + kwargs: Additional keyword arguments for message. """ super().__init__(_id=_id, **kwargs) diff --git a/aries_cloudagent/protocols/present_proof/v1_0/messages/presentation_ack.py b/aries_cloudagent/protocols/present_proof/v1_0/messages/presentation_ack.py index f2abc1bc5d..6b9c2052a6 100644 --- a/aries_cloudagent/protocols/present_proof/v1_0/messages/presentation_ack.py +++ b/aries_cloudagent/protocols/present_proof/v1_0/messages/presentation_ack.py @@ -25,6 +25,8 @@ def __init__(self, status: str = None, verification_result: str = None, **kwargs Args: status: Status (default OK) + verification_result: Whether presentation is verified + kwargs: Additional keyword arguments for message construction """ super().__init__(status, **kwargs) diff --git a/aries_cloudagent/protocols/present_proof/v1_0/messages/presentation_problem_report.py b/aries_cloudagent/protocols/present_proof/v1_0/messages/presentation_problem_report.py index cc0653653a..558717fe7d 100644 --- a/aries_cloudagent/protocols/present_proof/v1_0/messages/presentation_problem_report.py +++ b/aries_cloudagent/protocols/present_proof/v1_0/messages/presentation_problem_report.py @@ -2,10 +2,9 @@ from enum import Enum -from marshmallow import EXCLUDE, validates_schema, ValidationError +from marshmallow import EXCLUDE, ValidationError, validates_schema from ....problem_report.v1_0.message import ProblemReport, ProblemReportSchema - from ..message_types import PRESENTATION_PROBLEM_REPORT, PROTOCOL_PACKAGE HANDLER_CLASS = ( @@ -50,6 +49,7 @@ def validate_fields(self, data, **kwargs): Args: data: The data to validate + kwargs: Additional keyword arguments """ if not data.get("description", {}).get("code", ""): diff --git a/aries_cloudagent/protocols/present_proof/v1_0/messages/presentation_proposal.py b/aries_cloudagent/protocols/present_proof/v1_0/messages/presentation_proposal.py index f5b6d53487..5f0061627e 100644 --- a/aries_cloudagent/protocols/present_proof/v1_0/messages/presentation_proposal.py +++ b/aries_cloudagent/protocols/present_proof/v1_0/messages/presentation_proposal.py @@ -35,6 +35,7 @@ def __init__( Args: comment: optional human-readable comment presentation_proposal: proposed presentation preview + kwargs: additional keyword arguments for message """ super().__init__(_id, **kwargs) self.comment = comment diff --git a/aries_cloudagent/protocols/present_proof/v1_0/messages/presentation_request.py b/aries_cloudagent/protocols/present_proof/v1_0/messages/presentation_request.py index 978fe46b23..4c8b563d5a 100644 --- a/aries_cloudagent/protocols/present_proof/v1_0/messages/presentation_request.py +++ b/aries_cloudagent/protocols/present_proof/v1_0/messages/presentation_request.py @@ -38,8 +38,9 @@ def __init__( """Initialize presentation request object. Args: - request_presentations_attach: proof request attachments comment: optional comment + request_presentations_attach: proof request attachments + kwargs: additional keyword arguments for message """ super().__init__(_id=_id, **kwargs) diff --git a/aries_cloudagent/protocols/present_proof/v1_0/models/presentation_exchange.py b/aries_cloudagent/protocols/present_proof/v1_0/models/presentation_exchange.py index a32c1355eb..9a3dac03f9 100644 --- a/aries_cloudagent/protocols/present_proof/v1_0/models/presentation_exchange.py +++ b/aries_cloudagent/protocols/present_proof/v1_0/models/presentation_exchange.py @@ -172,9 +172,10 @@ async def save_error_state( Args: session: The profile session to use + state: The state to set reason: A reason to add to the log log_params: Additional parameters to log - override: Override configured logging regimen, print to stderr instead + log_override: Override configured logging regimen, print to stderr instead """ if self._last_state == state: # already done diff --git a/aries_cloudagent/protocols/present_proof/v2_0/formats/dif/handler.py b/aries_cloudagent/protocols/present_proof/v2_0/formats/dif/handler.py index efee40fd18..be0e456b25 100644 --- a/aries_cloudagent/protocols/present_proof/v2_0/formats/dif/handler.py +++ b/aries_cloudagent/protocols/present_proof/v2_0/formats/dif/handler.py @@ -109,15 +109,16 @@ async def create_bound_request( """Create a presentation request bound to a proposal. Args: - pres_ex_record: Presentation exchange record for which + pres_ex_record (V20PresExRecord): Presentation exchange record for which to create presentation request - name: name to use in presentation request (None for default) - version: version to use in presentation request (None for default) - nonce: nonce to use in presentation request (None to generate) - comment: Optional human-readable comment pertaining to request creation + request_data (dict, optional): Additional data to include in the request Returns: - A tuple (updated presentation exchange record, presentation request message) + Tuple[V20PresFormat, AttachDecorator]: A tuple containing the updated + presentation exchange record and the presentation request message + + Raises: + SomeException: Description of the exception raised, if any """ dif_proof_request = {} diff --git a/aries_cloudagent/protocols/present_proof/v2_0/manager.py b/aries_cloudagent/protocols/present_proof/v2_0/manager.py index d42151f100..153a0cfdb9 100644 --- a/aries_cloudagent/protocols/present_proof/v2_0/manager.py +++ b/aries_cloudagent/protocols/present_proof/v2_0/manager.py @@ -115,6 +115,7 @@ async def create_bound_request( Args: pres_ex_record: Presentation exchange record for which to create presentation request + request_data: Formatted requested attributes and predicates comment: Optional human-readable comment pertaining to request creation Returns: @@ -227,36 +228,38 @@ async def create_pres( """Create a presentation. Args: - pres_ex_record: record to update - requested_credentials: indy formatted requested_credentials - comment: optional human-readable comment - format_: presentation format + pres_ex_record (V20PresExRecord): The record to update. + request_data (Optional[dict]): Optional indy formatted + requested_credentials. + comment (str): Optional human-readable comment. - Example `requested_credentials` format, mapping proof request referents (uuid) + Example `request_data` format, mapping proof request referents (uuid) to wallet referents (cred id): - :: - - { - "self_attested_attributes": { - "j233ffbc-bd35-49b1-934f-51e083106f6d": "value" - }, - "requested_attributes": { - "6253ffbb-bd35-49b3-934f-46e083106f6c": { - "cred_id": "5bfa40b7-062b-4ae0-a251-a86c87922c0e", - "revealed": true - } - }, - "requested_predicates": { - "bfc8a97d-60d3-4f21-b998-85eeabe5c8c0": { - "cred_id": "5bfa40b7-062b-4ae0-a251-a86c87922c0e" - } + { + "self_attested_attributes": { + "j233ffbc-bd35-49b1-934f-51e083106f6d": "value" + }, + "requested_attributes": { + "6253ffbb-bd35-49b3-934f-46e083106f6c": { + "cred_id": "5bfa40b7-062b-4ae0-a251-a86c87922c0e", + "revealed": true + } + }, + "requested_predicates": { + "bfc8a97d-60d3-4f21-b998-85eeabe5c8c0": { + "cred_id": "5bfa40b7-062b-4ae0-a251-a86c87922c0e" } } + } Returns: - A tuple (updated presentation exchange record, presentation message) + Tuple[V20PresExRecord, V20Pres]: A tuple containing the updated + presentation exchange record and the presentation message. + Raises: + V20PresManagerError: If unable to create the presentation or no supported + formats are available. """ proof_request = pres_ex_record.pres_request input_formats = proof_request.formats @@ -378,6 +381,7 @@ async def verify_pres( Args: pres_ex_record: presentation exchange record with presentation request and presentation to verify + responder: base responder Returns: presentation exchange record, updated @@ -414,6 +418,7 @@ async def send_pres_ack( Args: pres_ex_record: presentation exchange record with thread id + responder: base responder """ responder = responder or self._profile.inject_or(BaseResponder) diff --git a/aries_cloudagent/protocols/present_proof/v2_0/messages/pres.py b/aries_cloudagent/protocols/present_proof/v2_0/messages/pres.py index 6db821b4e3..e9dd2ca303 100644 --- a/aries_cloudagent/protocols/present_proof/v2_0/messages/pres.py +++ b/aries_cloudagent/protocols/present_proof/v2_0/messages/pres.py @@ -37,8 +37,13 @@ def __init__( """Initialize presentation object. Args: - presentations_attach: attachments - comment: optional comment + _id (str, optional): The ID of the presentation object. + comment (str, optional): An optional comment. + formats (Sequence[V20PresFormat], optional): A sequence of presentation + formats. + presentations_attach (Sequence[AttachDecorator], optional): A sequence of + attachments. + **kwargs: Additional keyword arguments. """ super().__init__(_id=_id, **kwargs) diff --git a/aries_cloudagent/protocols/present_proof/v2_0/messages/pres_ack.py b/aries_cloudagent/protocols/present_proof/v2_0/messages/pres_ack.py index 9abc71172a..c48e2f9bac 100644 --- a/aries_cloudagent/protocols/present_proof/v2_0/messages/pres_ack.py +++ b/aries_cloudagent/protocols/present_proof/v2_0/messages/pres_ack.py @@ -23,6 +23,8 @@ def __init__(self, status: str = None, verification_result: str = None, **kwargs Args: status: Status (default OK) + verification_result: Whether presentation is verified: true or false + kwargs: Additional keyword arguments for message """ super().__init__(status, **kwargs) diff --git a/aries_cloudagent/protocols/present_proof/v2_0/messages/pres_problem_report.py b/aries_cloudagent/protocols/present_proof/v2_0/messages/pres_problem_report.py index 96e76e5bb4..1cdc6b2a30 100644 --- a/aries_cloudagent/protocols/present_proof/v2_0/messages/pres_problem_report.py +++ b/aries_cloudagent/protocols/present_proof/v2_0/messages/pres_problem_report.py @@ -5,7 +5,6 @@ from marshmallow import EXCLUDE, ValidationError, validates_schema from ....problem_report.v1_0.message import ProblemReport, ProblemReportSchema - from ..message_types import PRES_20_PROBLEM_REPORT, PROTOCOL_PACKAGE HANDLER_CLASS = ( @@ -50,6 +49,7 @@ def validate_fields(self, data, **kwargs): Args: data: The data to validate + kwargs: Additional keyword arguments """ if not data.get("description", {}).get("code", ""): diff --git a/aries_cloudagent/protocols/present_proof/v2_0/messages/pres_proposal.py b/aries_cloudagent/protocols/present_proof/v2_0/messages/pres_proposal.py index f8075bee49..5bdb5885d2 100644 --- a/aries_cloudagent/protocols/present_proof/v2_0/messages/pres_proposal.py +++ b/aries_cloudagent/protocols/present_proof/v2_0/messages/pres_proposal.py @@ -42,6 +42,7 @@ def __init__( comment: optional human-readable comment formats: acceptable attachment formats proposals_attach: proposal attachments specifying criteria by format + kwargs: additional key-value arguments """ super().__init__(_id, **kwargs) self.comment = comment diff --git a/aries_cloudagent/protocols/present_proof/v2_0/messages/pres_request.py b/aries_cloudagent/protocols/present_proof/v2_0/messages/pres_request.py index f149299ce0..51e2d2dfb4 100644 --- a/aries_cloudagent/protocols/present_proof/v2_0/messages/pres_request.py +++ b/aries_cloudagent/protocols/present_proof/v2_0/messages/pres_request.py @@ -40,8 +40,15 @@ def __init__( """Initialize presentation request object. Args: - request_presentations_attach: proof request attachments - comment: optional comment + _id (str, optional): The ID of the presentation request. + comment (str, optional): An optional comment. + will_confirm (bool, optional): A flag indicating whether the presentation + request will be confirmed. + formats (Sequence[V20PresFormat], optional): A sequence of presentation + formats. + request_presentations_attach (Sequence[AttachDecorator], optional): A + sequence of proof request attachments. + kwargs: Additional keyword arguments. """ super().__init__(_id=_id, **kwargs) diff --git a/aries_cloudagent/protocols/present_proof/v2_0/models/pres_exchange.py b/aries_cloudagent/protocols/present_proof/v2_0/models/pres_exchange.py index 06f43036ea..356a1bc1d5 100644 --- a/aries_cloudagent/protocols/present_proof/v2_0/models/pres_exchange.py +++ b/aries_cloudagent/protocols/present_proof/v2_0/models/pres_exchange.py @@ -158,9 +158,10 @@ async def save_error_state( Args: session: The profile session to use + state: The state to set reason: A reason to add to the log log_params: Additional parameters to log - override: Override configured logging regimen, print to stderr instead + log_override: Override configured logging regimen, print to stderr instead """ if self._last_state == state: # already done diff --git a/aries_cloudagent/protocols/present_proof/v2_0/routes.py b/aries_cloudagent/protocols/present_proof/v2_0/routes.py index cb0f23fc2e..b18b6041dc 100644 --- a/aries_cloudagent/protocols/present_proof/v2_0/routes.py +++ b/aries_cloudagent/protocols/present_proof/v2_0/routes.py @@ -135,6 +135,7 @@ def validate_fields(self, data, **kwargs): Args: data: The data to validate + kwargs: Additional keyword arguments Raises: ValidationError: if data has no formats @@ -210,6 +211,7 @@ def validate_fields(self, data, **kwargs): Args: data: The data to validate + kwargs: Additional keyword arguments Raises: ValidationError: if data has no formats @@ -325,6 +327,7 @@ def validate_fields(self, data, **kwargs): Args: data: The data to validate + kwargs: Additional keyword arguments Raises: ValidationError: if data does not have exactly one format. diff --git a/aries_cloudagent/protocols/problem_report/v1_0/message.py b/aries_cloudagent/protocols/problem_report/v1_0/message.py index 8f7ab5d08c..56847eadef 100644 --- a/aries_cloudagent/protocols/problem_report/v1_0/message.py +++ b/aries_cloudagent/protocols/problem_report/v1_0/message.py @@ -47,6 +47,7 @@ def __init__( noticed_time: Datetime when the problem was noticed tracking_uri: URI for tracking the problem escalation_uri: URI for escalating the problem + kwargs: Additional keyword arguments for message """ super().__init__(**kwargs) self.description = description if description else None @@ -159,6 +160,7 @@ def validate_fields(self, data, **kwargs): Args: data: The data to validate + kwargs: Additional keyword arguments Raises: ValidationError: if data has neither indy nor ld_proof diff --git a/aries_cloudagent/protocols/routing/v1_0/messages/forward.py b/aries_cloudagent/protocols/routing/v1_0/messages/forward.py index 9e822414d3..36afa7da7d 100644 --- a/aries_cloudagent/protocols/routing/v1_0/messages/forward.py +++ b/aries_cloudagent/protocols/routing/v1_0/messages/forward.py @@ -1,13 +1,11 @@ """Represents a forward message.""" import json - from typing import Union from marshmallow import EXCLUDE, fields, pre_load from .....messaging.agent_message import AgentMessage, AgentMessageSchema - from ..message_types import FORWARD, PROTOCOL_PACKAGE HANDLER_CLASS = f"{PROTOCOL_PACKAGE}.handlers.forward_handler.ForwardHandler" @@ -29,6 +27,7 @@ def __init__(self, *, to: str = None, msg: Union[dict, str] = None, **kwargs): Args: to (str): Recipient DID msg (str): Message content + kwargs: Additional keyword arguments """ super().__init__(**kwargs) self.to = to diff --git a/aries_cloudagent/protocols/routing/v1_0/models/route_record.py b/aries_cloudagent/protocols/routing/v1_0/models/route_record.py index 94545e8d70..2f7c3d3778 100644 --- a/aries_cloudagent/protocols/routing/v1_0/models/route_record.py +++ b/aries_cloudagent/protocols/routing/v1_0/models/route_record.py @@ -1,6 +1,6 @@ """An object for containing information on an individual route.""" -from marshmallow import EXCLUDE, fields, validates_schema, ValidationError +from marshmallow import EXCLUDE, ValidationError, fields, validates_schema from .....core.profile import ProfileSession from .....messaging.models.base_record import BaseRecord, BaseRecordSchema @@ -129,6 +129,7 @@ def validate_fields(self, data, **kwargs): Args: data: The data to validate + kwargs: Additional keyword arguments Raises: ValidationError: If any of the fields do not validate diff --git a/aries_cloudagent/protocols/trustping/v1_0/messages/ping.py b/aries_cloudagent/protocols/trustping/v1_0/messages/ping.py index 7685b7b1b6..9313646ba2 100644 --- a/aries_cloudagent/protocols/trustping/v1_0/messages/ping.py +++ b/aries_cloudagent/protocols/trustping/v1_0/messages/ping.py @@ -27,6 +27,7 @@ def __init__( response_requested: A flag indicating that a response is requested (defaults to True for the recipient if not included) comment: An optional comment string + kwargs: Keyword arguments for message construction """ super().__init__(**kwargs) diff --git a/aries_cloudagent/protocols/trustping/v1_0/messages/ping_response.py b/aries_cloudagent/protocols/trustping/v1_0/messages/ping_response.py index 9135ba4b84..f8e1a4b608 100644 --- a/aries_cloudagent/protocols/trustping/v1_0/messages/ping_response.py +++ b/aries_cloudagent/protocols/trustping/v1_0/messages/ping_response.py @@ -23,6 +23,7 @@ def __init__(self, *, comment: str = None, **kwargs): Args: comment: An optional comment string to include in the message + kwargs: Keyword arguments for message construction """ super().__init__(**kwargs) diff --git a/aries_cloudagent/resolver/base.py b/aries_cloudagent/resolver/base.py index 2591c1900c..b279968b8a 100644 --- a/aries_cloudagent/resolver/base.py +++ b/aries_cloudagent/resolver/base.py @@ -1,10 +1,10 @@ """Base Class for DID Resolvers.""" +import re +import warnings from abc import ABC, abstractmethod from enum import Enum -import re from typing import NamedTuple, Optional, Pattern, Sequence, Text, Union -import warnings from pydid import DID @@ -53,8 +53,8 @@ def __init__(self, did_document: dict, metadata: ResolutionMetadata): """Initialize Resolution. Args: - did_doc: DID Document resolved - resolver_metadata: Resolving details + did_document: DID Document resolved + metadata: Resolving details """ self.did_document = did_document self.metadata = metadata diff --git a/aries_cloudagent/revocation/indy.py b/aries_cloudagent/revocation/indy.py index f22b4fefb3..5067713722 100644 --- a/aries_cloudagent/revocation/indy.py +++ b/aries_cloudagent/revocation/indy.py @@ -208,7 +208,14 @@ async def get_issuer_rev_reg_delta( """Check ledger for revocation status for a given revocation registry. Args: - rev_reg_id: ID of the revocation registry + rev_reg_id (str): ID of the revocation registry + fro (int, optional): The sequence number to start from (exclusive). + Defaults to None. + to (int, optional): The sequence number to end at (inclusive). + Defaults to None. + + Returns: + dict: The revocation registry delta. """ ledger = await self.get_ledger_for_registry(rev_reg_id) diff --git a/aries_cloudagent/revocation/manager.py b/aries_cloudagent/revocation/manager.py index 1d32cc3af6..e5505ea37f 100644 --- a/aries_cloudagent/revocation/manager.py +++ b/aries_cloudagent/revocation/manager.py @@ -35,7 +35,7 @@ def __init__(self, profile: Profile): """Initialize a RevocationManager. Args: - context: The context for this revocation manager + profile: The profile instance for this revocation manager """ self._profile = profile self._logger = logging.getLogger(__name__) @@ -57,9 +57,31 @@ async def revoke_credential_by_cred_ex_id( Optionally, publish the corresponding revocation registry delta to the ledger. Args: - cred_ex_id: credential exchange identifier - publish: whether to publish the resulting revocation registry delta, - along with any revocations pending against it + cred_ex_id (str): The credential exchange identifier. + publish (bool, optional): Whether to publish the resulting revocation + registry delta, along with any revocations pending against it. + Defaults to False. + notify (bool, optional): Whether to notify the affected parties about the + revocation. Defaults to False. + notify_version (str, optional): The version of the notification to use. + Defaults to None. + thread_id (str, optional): The thread identifier for the revocation process. + Defaults to None. + connection_id (str, optional): The connection identifier for the revocation + process. Defaults to None. + endorser_conn_id (str, optional): The endorser connection identifier for the + revocation process. Defaults to None. + comment (str, optional): Additional comment or reason for the revocation. + Defaults to None. + write_ledger (bool, optional): Whether to write the revocation to the ledger. + Defaults to True. + + Raises: + RevocationManagerError: If no issuer credential revocation record is found + for the given credential exchange identifier. + + Returns: + The result of the `revoke_credential` method. """ try: @@ -105,11 +127,29 @@ async def revoke_credential( Optionally, publish the corresponding revocation registry delta to the ledger. Args: - rev_reg_id: revocation registry id - cred_rev_id: credential revocation id - publish: whether to publish the resulting revocation registry delta, - along with any revocations pending against it + rev_reg_id (str): The revocation registry id. + cred_rev_id (str): The credential revocation id. + publish (bool, optional): Whether to publish the resulting revocation + registry delta, along with any revocations pending against it. + Defaults to False. + notify (bool, optional): Whether to send a revocation notification. + Defaults to False. + notify_version (str, optional): The version of the revocation notification. + Defaults to None. + thread_id (str, optional): The thread id for the revocation notification. + Defaults to None. + connection_id (str, optional): The connection id for the revocation + notification. Defaults to None. + endorser_conn_id (str, optional): The endorser connection id. + Defaults to None. + comment (str, optional): Additional comment for the revocation notification. + Defaults to None. + write_ledger (bool, optional): Whether to write the revocation entry to the + ledger. Defaults to True. + Returns: + Optional[dict]: The revocation entry response if publish is True and + write_ledger is True, otherwise None. """ issuer = self._profile.inject(IndyIssuer) @@ -196,11 +236,13 @@ async def update_rev_reg_revoked_state( """Request handler to fix ledger entry of credentials revoked against registry. Args: - rev_reg_id: revocation registry id - apply_ledger_update: whether to apply an update to the ledger + apply_ledger_update (bool): Whether to apply an update to the ledger. + rev_reg_record (IssuerRevRegRecord): The revocation registry record. + genesis_transactions (dict): The genesis transactions. Returns: - Number of credentials posted to ledger + Tuple[dict, dict, dict]: A tuple containing the number of credentials posted + to the ledger. """ return await rev_reg_record.fix_ledger_entry( @@ -234,6 +276,7 @@ async def publish_pending_revocations( - all pending revocations from all revocation registry tagged 0 - pending ["1", "2"] from revocation registry tagged 1 - no pending revocations from any other revocation registries. + write_ledger: whether to write the revocation registry entry to the ledger connection_id: connection identifier for endorser connection to use Returns: mapping from each revocation registry id to its cred rev ids published. diff --git a/aries_cloudagent/revocation/models/indy.py b/aries_cloudagent/revocation/models/indy.py index 5f98a69809..9504208468 100644 --- a/aries_cloudagent/revocation/models/indy.py +++ b/aries_cloudagent/revocation/models/indy.py @@ -22,6 +22,7 @@ def __init__(self, fro: int = None, to: int = None, **kwargs): Args: fro: earliest time of interest to: latest time of interest + kwargs: additional keyword arguments """ super().__init__(**kwargs) diff --git a/aries_cloudagent/revocation/models/issuer_rev_reg_record.py b/aries_cloudagent/revocation/models/issuer_rev_reg_record.py index 174c950324..dfd38a95a0 100644 --- a/aries_cloudagent/revocation/models/issuer_rev_reg_record.py +++ b/aries_cloudagent/revocation/models/issuer_rev_reg_record.py @@ -537,6 +537,8 @@ async def query_by_cred_def_id( session: The profile session to use cred_def_id: The credential definition ID to filter by state: A state value to filter by + negative_state: A state value to exclude + limit: The maximum number of records to return """ tag_filter = dict( filter( diff --git a/aries_cloudagent/revocation_anoncreds/manager.py b/aries_cloudagent/revocation_anoncreds/manager.py index 52e914ed23..bc8fce9d49 100644 --- a/aries_cloudagent/revocation_anoncreds/manager.py +++ b/aries_cloudagent/revocation_anoncreds/manager.py @@ -32,7 +32,7 @@ def __init__(self, profile: Profile): """Initialize a RevocationManager. Args: - context: The context for this revocation manager + profile: The profile instance for this revocation manager """ self._profile = profile self._logger = logging.getLogger(__name__) @@ -53,9 +53,28 @@ async def revoke_credential_by_cred_ex_id( Optionally, publish the corresponding revocation registry delta to the ledger. Args: - cred_ex_id: credential exchange identifier - publish: whether to publish the resulting revocation registry delta, - along with any revocations pending against it + cred_ex_id (str): The credential exchange identifier. + publish (bool, optional): Whether to publish the resulting revocation + registry delta, along with any revocations pending against it. + Defaults to False. + notify (bool, optional): Whether to notify the issuer of the revocation. + Defaults to False. + notify_version (str, optional): The version of the revocation notification to + use. Defaults to None. + thread_id (str, optional): The thread identifier for the revocation. + Defaults to None. + connection_id (str, optional): The connection identifier for the revocation. + Defaults to None. + comment (str, optional): A comment for the revocation. Defaults to None. + options (dict, optional): Additional options for the revocation. Defaults to + None. + + Raises: + RevocationManagerError: If no issuer credential revocation record is found + for the given credential exchange id. + + Returns: + dict: The result of the credential revocation operation. """ try: @@ -99,10 +118,26 @@ async def revoke_credential( Optionally, publish the corresponding revocation registry delta to the ledger. Args: - rev_reg_id: revocation registry id - cred_rev_id: credential revocation id - publish: whether to publish the resulting revocation registry delta, - along with any revocations pending against it + rev_reg_id (str): The revocation registry id. + cred_rev_id (str): The credential revocation id. + publish (bool, optional): Whether to publish the resulting revocation + registry delta, along with any revocations pending against it. + Defaults to False. + notify (bool, optional): Whether to send a revocation notification. + Defaults to False. + notify_version (str, optional): The version of the revocation notification. + Defaults to None. + thread_id (str, optional): The thread id for the revocation notification. + Defaults to None. + connection_id (str, optional): The connection id for the revocation + notification. Defaults to None. + comment (str, optional): A comment for the revocation notification. + Defaults to None. + options (dict, optional): Additional options for revocation. Defaults to None. + + Raises: + RevocationManagerError: If no revocation registry record is found for the + given rev_reg_id. """ revoc = AnonCredsRevocation(self._profile) @@ -155,8 +190,9 @@ async def update_rev_reg_revoked_state( This is an indy registry specific operation. Args: - rev_reg_id: revocation registry id + rev_reg_def_id: revocation registry definition id apply_ledger_update: whether to apply an update to the ledger + genesis_transactions: genesis transactions for the ledger Returns: Number of credentials posted to ledger @@ -208,6 +244,7 @@ async def publish_pending_revocations( - all pending revocations from all revocation registry tagged 0 - pending ["1", "2"] from revocation registry tagged 1 - no pending revocations from any other revocation registries. + options: Additional options for the revocation registry publish Returns: mapping from each revocation registry id to its cred rev ids published. """ diff --git a/aries_cloudagent/storage/askar.py b/aries_cloudagent/storage/askar.py index 6f1b62ab8e..03061cca32 100644 --- a/aries_cloudagent/storage/askar.py +++ b/aries_cloudagent/storage/askar.py @@ -286,6 +286,7 @@ def __init__( type_filter: Filter string tag_query: Tags to search page_size: Size of page to return + options: Dictionary of backend-specific options """ self.tag_query = tag_query diff --git a/aries_cloudagent/storage/vc_holder/askar.py b/aries_cloudagent/storage/vc_holder/askar.py index 2cc8df2ff9..d19bebe7fb 100644 --- a/aries_cloudagent/storage/vc_holder/askar.py +++ b/aries_cloudagent/storage/vc_holder/askar.py @@ -1,16 +1,14 @@ """Askar storage implementation of VC holder interface.""" import json +from typing import Mapping, Sequence -from dateutil.parser import parse as dateutil_parser from dateutil.parser import ParserError -from typing import Mapping, Sequence +from dateutil.parser import parse as dateutil_parser from ...askar.profile import AskarProfile - from ..askar import AskarStorage, AskarStorageSearch, AskarStorageSearchSession from ..record import StorageRecord - from .base import VCHolder, VCRecordSearch from .vc_record import VCRecord from .xform import VC_CRED_RECORD_TYPE @@ -108,6 +106,7 @@ def search_credentials( proof_types: The signature suite types used for the proof objects. given_id: The given id of the credential tag_query: A tag filter clause + pd_uri_list: A list of presentation definition URIs to match """ diff --git a/aries_cloudagent/storage/vc_holder/in_memory.py b/aries_cloudagent/storage/vc_holder/in_memory.py index 4c94f63adf..66e5a05df0 100644 --- a/aries_cloudagent/storage/vc_holder/in_memory.py +++ b/aries_cloudagent/storage/vc_holder/in_memory.py @@ -1,16 +1,15 @@ """Basic in-memory storage implementation of VC holder interface.""" -from dateutil.parser import parse as dateutil_parser -from dateutil.parser import ParserError from typing import Mapping, Sequence -from ...core.in_memory import InMemoryProfile +from dateutil.parser import ParserError +from dateutil.parser import parse as dateutil_parser +from ...core.in_memory import InMemoryProfile from ..in_memory import InMemoryStorage, InMemoryStorageSearch - from .base import VCHolder, VCRecordSearch from .vc_record import VCRecord -from .xform import storage_to_vc_record, vc_to_storage_record, VC_CRED_RECORD_TYPE +from .xform import VC_CRED_RECORD_TYPE, storage_to_vc_record, vc_to_storage_record class InMemoryVCHolder(VCHolder): @@ -89,14 +88,25 @@ def search_credentials( """Start a new VC record search. Args: - contexts: An inclusive list of JSON-LD contexts to match - types: An inclusive list of JSON-LD types to match - schema_ids: An inclusive list of credential schema identifiers - issuer_id: The ID of the credential issuer - subject_ids: The IDs of credential subjects all of which to match - proof_types: The signature suite types used for the proof objects. - given_id: The given id of the credential - tag_query: A tag filter clause + contexts (Sequence[str], optional): An inclusive list of JSON-LD contexts + to match. + types (Sequence[str], optional): An inclusive list of JSON-LD types to + match. + schema_ids (str, optional): An inclusive list of credential schema + identifiers. + issuer_id (str, optional): The ID of the credential issuer. + subject_ids (str, optional): The IDs of credential subjects all of which + to match. + proof_types (Sequence[str], optional): The signature suite types used for + the proof objects. + given_id (str, optional): The given id of the credential. + tag_query (Mapping, optional): A tag filter clause. + pd_uri_list (Sequence[str], optional): A list of presentation definition + URIs. + + Returns: + VCRecordSearch: An instance of VCRecordSearch representing the search + query. """ query = {} diff --git a/aries_cloudagent/tails/base.py b/aries_cloudagent/tails/base.py index a5aa4c6f0d..afb89efa77 100644 --- a/aries_cloudagent/tails/base.py +++ b/aries_cloudagent/tails/base.py @@ -1,6 +1,6 @@ """Tails server interface base class.""" -from abc import ABC, abstractmethod, ABCMeta +from abc import ABC, ABCMeta, abstractmethod from typing import Tuple from ..config.injection_context import InjectionContext @@ -24,7 +24,7 @@ async def upload_tails_file( Args: context: context with configuration settings filename: file name given to tails server - tails_file: The path to the tails file to upload + tails_file_path: path to tails file to upload interval: initial interval between attempts backoff: exponential backoff in retry interval max_attempts: maximum number of attempts to make diff --git a/aries_cloudagent/transport/inbound/base.py b/aries_cloudagent/transport/inbound/base.py index c89c71879d..012ec0be45 100644 --- a/aries_cloudagent/transport/inbound/base.py +++ b/aries_cloudagent/transport/inbound/base.py @@ -26,10 +26,17 @@ def __init__( """Initialize the inbound transport instance. Args: - scheme: The transport scheme identifier - create_session: Method to create a new inbound session + scheme (str): The transport scheme identifier. + create_session (Callable): Method to create a new inbound session. + max_message_size (int, optional): The maximum size of a message. + Defaults to 0. + is_external (bool, optional): Indicates if the transport is external. + Defaults to False. + wire_format (BaseWireFormat, optional): The wire format used for message + serialization. Defaults to None. + root_profile (Profile, optional): The root profile for the transport. + Defaults to None. """ - self._create_session = create_session self._max_message_size = max_message_size self._scheme = scheme diff --git a/aries_cloudagent/transport/inbound/http.py b/aries_cloudagent/transport/inbound/http.py index 028bc6a174..f4a29ba3e7 100644 --- a/aries_cloudagent/transport/inbound/http.py +++ b/aries_cloudagent/transport/inbound/http.py @@ -22,6 +22,7 @@ def __init__(self, host: str, port: int, create_session, **kwargs) -> None: host: Host to listen on port: Port to listen on create_session: Method to create a new inbound session + kwargs: Additional keyword arguments """ super().__init__("http", create_session, **kwargs) diff --git a/aries_cloudagent/transport/inbound/receipt.py b/aries_cloudagent/transport/inbound/receipt.py index c084fb0a30..116ab4dfa6 100644 --- a/aries_cloudagent/transport/inbound/receipt.py +++ b/aries_cloudagent/transport/inbound/receipt.py @@ -204,7 +204,7 @@ def sender_did(self, did: str): """Setter for the sender DID which corresponds with the verkey. Args: - The new sender did + did (str): The new sender DID. """ self._sender_did = did diff --git a/aries_cloudagent/transport/inbound/ws.py b/aries_cloudagent/transport/inbound/ws.py index 4188cd4206..358659179c 100644 --- a/aries_cloudagent/transport/inbound/ws.py +++ b/aries_cloudagent/transport/inbound/ws.py @@ -10,7 +10,6 @@ from ..error import WireFormatParseError from .base import BaseInboundTransport, InboundTransportSetupError - LOGGER = logging.getLogger(__name__) @@ -24,6 +23,7 @@ def __init__(self, host: str, port: int, create_session, **kwargs) -> None: host: Host to listen on port: Port to listen on create_session: Method to create a new inbound session + kwargs: Additional keyword arguments """ super().__init__("ws", create_session, **kwargs) diff --git a/aries_cloudagent/transport/outbound/base.py b/aries_cloudagent/transport/outbound/base.py index 0c6f7c1cf5..0a1c50ffec 100644 --- a/aries_cloudagent/transport/outbound/base.py +++ b/aries_cloudagent/transport/outbound/base.py @@ -1,7 +1,7 @@ """Base outbound transport.""" -from abc import ABC, abstractmethod import asyncio +from abc import ABC, abstractmethod from typing import Union from ...connections.models.connection_target import ConnectionTarget @@ -108,7 +108,7 @@ async def handle_message( Args: profile: the profile that produced the message - payload: message payload in string or byte format + outbound_message: the outbound message to handle endpoint: URI endpoint for delivery metadata: Additional metadata associated with the payload """ diff --git a/aries_cloudagent/transport/outbound/http.py b/aries_cloudagent/transport/outbound/http.py index 7a8532518d..60d9bb8896 100644 --- a/aries_cloudagent/transport/outbound/http.py +++ b/aries_cloudagent/transport/outbound/http.py @@ -6,10 +6,8 @@ from aiohttp import ClientSession, DummyCookieJar, TCPConnector from ...core.profile import Profile - from ..stats import StatsTracer from ..wire_format import DIDCOMM_V0_MIME_TYPE, DIDCOMM_V1_MIME_TYPE - from .base import BaseOutboundTransport, OutboundTransportError @@ -61,6 +59,7 @@ async def handle_message( payload: message payload in string or byte format endpoint: URI endpoint for delivery metadata: Additional metadata associated with the payload + api_key: API key for the endpoint """ if not endpoint: raise OutboundTransportError("No endpoint provided") diff --git a/aries_cloudagent/transport/outbound/manager.py b/aries_cloudagent/transport/outbound/manager.py index ab028f450f..e83f54e352 100644 --- a/aries_cloudagent/transport/outbound/manager.py +++ b/aries_cloudagent/transport/outbound/manager.py @@ -4,20 +4,16 @@ import json import logging import time - from typing import Callable, Type from urllib.parse import urlparse from ...connections.models.connection_target import ConnectionTarget from ...core.profile import Profile -from ...utils.classloader import ClassLoader, ModuleLoadError, ClassNotFoundError +from ...utils.classloader import ClassLoader, ClassNotFoundError, ModuleLoadError from ...utils.stats import Collector from ...utils.task_queue import CompletedTask, TaskQueue, task_exc_info - -from ...utils.tracing import trace_event, get_timer - +from ...utils.tracing import get_timer, trace_event from ..wire_format import BaseWireFormat - from .base import ( BaseOutboundTransport, OutboundDeliveryError, @@ -39,7 +35,7 @@ def __init__(self, profile: Profile, handle_not_delivered: Callable = None): """Initialize a `OutboundTransportManager` instance. Args: - root_profile: The application root profile + profile: The active profile for the request handle_not_delivered: An optional handler for undelivered messages """ @@ -105,13 +101,18 @@ def register_class( """Register a new outbound transport class. Args: - transport_class: Transport class to register + transport_class (Type[BaseOutboundTransport]): The transport class to + register. + transport_id (str, optional): The ID of the transport. If not provided, the + qualified name of the transport class will be used as the ID. + + Returns: + str: The ID of the registered transport. Raises: - OutboundTransportRegistrationError: If the imported class does not - specify a schemes attribute - OutboundTransportRegistrationError: If the scheme has already been - registered + OutboundTransportRegistrationError: If the imported class does not specify + a `schemes` attribute. + OutboundTransportRegistrationError: If the scheme has already been registered. """ try: diff --git a/aries_cloudagent/transport/outbound/ws.py b/aries_cloudagent/transport/outbound/ws.py index 6510905631..e3a7c25576 100644 --- a/aries_cloudagent/transport/outbound/ws.py +++ b/aries_cloudagent/transport/outbound/ws.py @@ -6,7 +6,6 @@ from aiohttp import ClientSession, DummyCookieJar from ...core.profile import Profile - from .base import BaseOutboundTransport @@ -46,6 +45,7 @@ async def handle_message( payload: message payload in string or byte format endpoint: URI endpoint for delivery metadata: Additional metadata associated with the payload + api_key: API key for the endpoint """ # aiohttp should automatically handle websocket sessions async with self.client_session.ws_connect(endpoint, headers=metadata) as ws: diff --git a/aries_cloudagent/utils/tracing.py b/aries_cloudagent/utils/tracing.py index fddf91b7a7..c3ce84e0a4 100644 --- a/aries_cloudagent/utils/tracing.py +++ b/aries_cloudagent/utils/tracing.py @@ -6,7 +6,6 @@ import time import requests - from marshmallow import fields from ..messaging.agent_message import AgentMessage @@ -127,7 +126,22 @@ def trace_event( context["trace.tag"]: Tag to be included in trace output message: the current message, can be an AgentMessage, InboundMessage, OutboundMessage or Exchange record - event: Dict that will be converted to json and posted to the target + handler (optional): The handler name for the trace event. If not provided, + it defaults to "aca-py.agent". + outcome (optional): The outcome of the trace event. + perf_counter (optional): The performance counter value for the trace event. + force_trace (optional): If True, forces the trace event to be logged even if + tracing is not enabled. + raise_errors (optional): If True, raises an exception if there is an error + logging the trace event. + + Returns: + float: The value of the performance counter. + + Raises: + Exception: If there is an error logging the trace event and `raise_errors` is + True. + """ ret = time.perf_counter() diff --git a/aries_cloudagent/vc/ld_proofs/check.py b/aries_cloudagent/vc/ld_proofs/check.py index 84012f06b5..20b3c508d6 100644 --- a/aries_cloudagent/vc/ld_proofs/check.py +++ b/aries_cloudagent/vc/ld_proofs/check.py @@ -1,8 +1,8 @@ """Validator methods to check for properties without a context.""" from typing import Sequence, Tuple, Union -from pyld import jsonld +from pyld import jsonld from .document_loader import DocumentLoaderMethod @@ -23,6 +23,8 @@ def diff_dict_keys( full (dict): The full dict with all keys present with_missing (dict): The dict with possibly keys missing prefix (str, optional): The prefix. Mostly used for internal recursion. + document_loader (DocumentLoaderMethod): The document loader method + context: The context of the document Returns: Sequence[str]: List of missing property names in with_missing diff --git a/aries_cloudagent/wallet/askar.py b/aries_cloudagent/wallet/askar.py index 6150adc6d3..2b346e0fb6 100644 --- a/aries_cloudagent/wallet/askar.py +++ b/aries_cloudagent/wallet/askar.py @@ -3,7 +3,6 @@ import asyncio import json import logging - from typing import List, Optional, Sequence, Tuple, Union from aries_askar import ( @@ -15,16 +14,14 @@ SeedMethod, ) -from .did_parameters_validation import DIDParametersValidation from ..askar.didcomm.v1 import pack_message, unpack_message from ..askar.profile import AskarProfileSession from ..ledger.base import BaseLedger from ..ledger.endpoint_type import EndpointType from ..ledger.error import LedgerConfigError from ..storage.askar import AskarStorage -from ..storage.base import StorageRecord, StorageDuplicateError, StorageNotFoundError - -from .base import BaseWallet, KeyInfo, DIDInfo +from ..storage.base import StorageDuplicateError, StorageNotFoundError, StorageRecord +from .base import BaseWallet, DIDInfo, KeyInfo from .crypto import ( sign_message, validate_seed, @@ -32,7 +29,8 @@ ) from .did_info import INVITATION_REUSE_KEY from .did_method import SOV, DIDMethod, DIDMethods -from .error import WalletError, WalletDuplicateError, WalletNotFoundError +from .did_parameters_validation import DIDParametersValidation +from .error import WalletDuplicateError, WalletError, WalletNotFoundError from .key_type import BLS12381G2, ED25519, KeyType, KeyTypes from .util import b58_to_bytes, bytes_to_b58 @@ -510,12 +508,25 @@ async def set_did_endpoint( """Update the endpoint for a DID in the wallet, send to ledger if posted. Args: - did: DID for which to set endpoint - endpoint: the endpoint to set, None to clear - ledger: the ledger to which to send endpoint update if - DID is public or posted - endpoint_type: the type of the endpoint/service. Only endpoint_type - 'endpoint' affects local wallet + did (str): The DID for which to set the endpoint. + endpoint (str): The endpoint to set. Use None to clear the endpoint. + ledger (BaseLedger): The ledger to which to send the endpoint update if the + DID is public or posted. + endpoint_type (EndpointType, optional): The type of the endpoint/service. + Only endpoint_type 'endpoint' affects the local wallet. Defaults to None. + write_ledger (bool, optional): Whether to write the endpoint update to the + ledger. Defaults to True. + endorser_did (str, optional): The DID of the endorser. Defaults to None. + routing_keys (List[str], optional): The routing keys to be used. + Defaults to None. + + Raises: + WalletError: If the DID is not of type 'did:sov'. + LedgerConfigError: If no ledger is available but the DID is public. + + Returns: + dict: The attribute definition if write_ledger is False, otherwise None. + """ did_info = await self.get_local_did(did) if did_info.method != SOV: diff --git a/aries_cloudagent/wallet/base.py b/aries_cloudagent/wallet/base.py index 75f164412d..9468155220 100644 --- a/aries_cloudagent/wallet/base.py +++ b/aries_cloudagent/wallet/base.py @@ -153,13 +153,22 @@ async def create_public_did( ) -> DIDInfo: """Create and store a new public DID. + This method creates a new public DID using the specified DID method and key type. + The optional `seed` parameter can be used to provide a seed for the DID + generation. + If a `did` is provided, it will be used as the DID instead of generating a new + one. + The `metadata` parameter can be used to store additional metadata with the DID. + Args: - seed: Optional seed to use for DID - did: The DID to use - metadata: Metadata to store with DID + method: The DID method to use for creating the DID. + key_type: The key type to use for the DID. + seed: Optional seed to use for DID generation. + did: The DID to use instead of generating a new one. + metadata: Optional metadata to store with the DID. Returns: - The created `DIDInfo` + The created `DIDInfo` object. """ metadata = metadata or {} @@ -256,12 +265,21 @@ async def set_did_endpoint( """Update the endpoint for a DID in the wallet, send to ledger if posted. Args: - did: DID for which to set endpoint - endpoint: the endpoint to set, None to clear - ledger: the ledger to which to send endpoint update if - DID is public or posted - endpoint_type: the type of the endpoint/service. Only endpoint_type - 'endpoint' affects local wallet + did (str): The DID for which to set the endpoint. + endpoint (str): The endpoint to set. Use None to clear the endpoint. + _ledger (BaseLedger): The ledger to which to send the endpoint update if the + DID is public or posted. + endpoint_type (EndpointType, optional): The type of the endpoint/service. + Only endpoint_type 'endpoint' affects the local wallet. + write_ledger (bool, optional): Whether to write the endpoint update to the + ledger. Defaults to True. + endorser_did (str, optional): The DID of the endorser. Defaults to None. + routing_keys (List[str], optional): The list of routing keys. + Defaults to None. + + Raises: + WalletError: If the DID method is not 'did:sov'. + """ did_info = await self.get_local_did(did) diff --git a/aries_cloudagent/wallet/bbs.py b/aries_cloudagent/wallet/bbs.py index 396e371442..582c08d943 100644 --- a/aries_cloudagent/wallet/bbs.py +++ b/aries_cloudagent/wallet/bbs.py @@ -2,21 +2,27 @@ from typing import List, Tuple +from ..core.error import BaseError from ..utils.dependencies import ( assert_ursa_bbs_signatures_installed, is_ursa_bbs_signatures_module_installed, ) -from ..core.error import BaseError from ..wallet.util import random_seed if is_ursa_bbs_signatures_module_installed(): from ursa_bbs_signatures import ( + BbsException as NativeBbsException, + ) + from ursa_bbs_signatures import ( + BlsKeyPair, SignRequest, VerifyRequest, - BlsKeyPair, + ) + from ursa_bbs_signatures import ( sign as bbs_sign, + ) + from ursa_bbs_signatures import ( verify as bbs_verify, - BbsException as NativeBbsException, ) from ursa_bbs_signatures._ffi.FfiException import FfiException @@ -57,11 +63,15 @@ def verify_signed_messages_bls12381g2( """Verify an ed25519 signed message according to a public verification key. Args: - signed: The signed messages - public_key: The public key to use in verification + messages (List[bytes]): The signed messages to verify. + signature (bytes): The signature to verify. + public_key (bytes): The public key to use in verification. Returns: - True if verified, else False + bool: True if the signature is verified, else False. + + Raises: + BbsException: If unable to verify the BBS+ signature. """ assert_ursa_bbs_signatures_installed() @@ -78,7 +88,7 @@ def verify_signed_messages_bls12381g2( except ( FfiException, NativeBbsException, - ) as error: # would be nice to be able to distinct between false and error + ) as error: raise BbsException("Unable to verify BBS+ signature") from error diff --git a/aries_cloudagent/wallet/crypto.py b/aries_cloudagent/wallet/crypto.py index 52a325e514..82834c0c82 100644 --- a/aries_cloudagent/wallet/crypto.py +++ b/aries_cloudagent/wallet/crypto.py @@ -1,26 +1,24 @@ """Cryptography functions used by BasicWallet.""" import re - from collections import OrderedDict -from typing import Callable, Optional, Sequence, Tuple, Union, List +from typing import Callable, List, Optional, Sequence, Tuple, Union import nacl.bindings import nacl.exceptions import nacl.utils - from marshmallow import ValidationError -from ..utils.jwe import JweRecipient, b64url, JweEnvelope, from_b64url -from .error import WalletError -from .util import bytes_to_b58, b64_to_bytes, b58_to_bytes, random_seed -from .key_type import ED25519, BLS12381G2, KeyType +from ..utils.jwe import JweEnvelope, JweRecipient, b64url, from_b64url from .bbs import ( - create_bls12381g2_keypair, - verify_signed_messages_bls12381g2, BbsException, + create_bls12381g2_keypair, sign_messages_bls12381g2, + verify_signed_messages_bls12381g2, ) +from .error import WalletError +from .key_type import BLS12381G2, ED25519, KeyType +from .util import b58_to_bytes, b64_to_bytes, bytes_to_b58, random_seed def create_keypair(key_type: KeyType, seed: bytes = None) -> Tuple[bytes, bytes]: @@ -158,14 +156,17 @@ def sign_message( def sign_message_ed25519(message: bytes, secret: bytes) -> bytes: - """Sign message using a ed25519 private signing key. + """Sign message using an ed25519 private signing key. + + This function takes a message and a private signing key as input and returns the + signature of the message using the ed25519 algorithm. Args: - messages (bytes): The message to sign - secret (bytes): The private signing key + message (bytes): The message to sign. + secret (bytes): The private signing key. Returns: - bytes: The signature + bytes: The signature of the message. """ result = nacl.bindings.crypto_sign(message, secret) @@ -295,12 +296,12 @@ def encrypt_plaintext( """Encrypt the payload of a packed message. Args: - message: Message to encrypt - add_data: - key: Key used for encryption + message (str): The message to encrypt. + add_data (bytes): Additional data to include in the encryption. + key (bytes): The key used for encryption. Returns: - A tuple of (ciphertext, nonce, tag) + Tuple[bytes, bytes, bytes]: A tuple containing the ciphertext, nonce, and tag. """ nonce = nacl.utils.random(nacl.bindings.crypto_aead_chacha20poly1305_ietf_NPUBBYTES) @@ -320,13 +321,13 @@ def decrypt_plaintext( """Decrypt the payload of a packed message. Args: - ciphertext: - recips_bin: - nonce: - key: + ciphertext (bytes): The encrypted payload to be decrypted. + recips_bin (bytes): The binary representation of the recipients' public keys. + nonce (bytes): The nonce used for encryption. + key (bytes): The secret key used for encryption. Returns: - The decrypted string + str: The decrypted string. """ output = nacl.bindings.crypto_aead_chacha20poly1305_ietf_decrypt( diff --git a/aries_cloudagent/wallet/routes.py b/aries_cloudagent/wallet/routes.py index 7fb9c75ea5..bbc3cb7a2f 100644 --- a/aries_cloudagent/wallet/routes.py +++ b/aries_cloudagent/wallet/routes.py @@ -1066,11 +1066,21 @@ async def wallet_jwt_sign(request: web.BaseRequest): """Request handler for jws creation using did. Args: - "headers": { ... }, - "payload": { ... }, - "did": "did:example:123", - "verificationMethod": "did:example:123#keys-1" - with did and verification being mutually exclusive. + request (web.BaseRequest): The HTTP request object. + "headers": { ... }, + "payload": { ... }, + "did": "did:example:123", + "verificationMethod": "did:example:123#keys-1" + with did and verification being mutually exclusive. + + Returns: + web.Response: The HTTP response containing the signed JWS. + + Raises: + web.HTTPBadRequest: If the provided DID or verification method is invalid. + web.HTTPNotFound: If the wallet is not found. + web.HTTPBadRequest: If there is an error with the wallet. + """ context: AdminRequestContext = request["context"] body = await request.json() @@ -1103,12 +1113,24 @@ async def wallet_sd_jwt_sign(request: web.BaseRequest): """Request handler for sd-jws creation using did. Args: - "headers": { ... }, - "payload": { ... }, - "did": "did:example:123", - "verificationMethod": "did:example:123#keys-1" - with did and verification being mutually exclusive. - "non_sd_list": [] + request (web.BaseRequest): The HTTP request object. + Contains the request context and payload. + "headers": { ... }, + "payload": { ... }, + "did": "did:example:123", + "verificationMethod": "did:example:123#keys-1" + with did and verification being mutually exclusive. + "non_sd_list": [] + + Returns: + web.Response: The HTTP response object. + Contains the signed sd-jws. + + Raises: + web.HTTPBadRequest: If the provided did or verification method is invalid. + web.HTTPNotFound: If the wallet is not found. + web.HTTPBadRequest: If there is an error with the wallet. + """ context: AdminRequestContext = request["context"] body = await request.json() @@ -1140,7 +1162,17 @@ async def wallet_jwt_verify(request: web.BaseRequest): """Request handler for jws validation using did. Args: - "jwt": { ... } + request (web.BaseRequest): The HTTP request object. + "jwt": { ... } + + Returns: + web.Response: The HTTP response containing the validation result. + + Raises: + web.HTTPBadRequest: If there is an error with the JWS header or verification + method. + web.HTTPNotFound: If there is an error resolving the JWS. + """ context: AdminRequestContext = request["context"] body = await request.json() @@ -1174,7 +1206,16 @@ async def wallet_sd_jwt_verify(request: web.BaseRequest): """Request handler for sd-jws validation using did. Args: - "sd-jwt": { ... } + request: The web request object. + "sd-jwt": { ... } + + Returns: + A JSON response containing the result of the sd-jwt verification. + + Raises: + web.HTTPBadRequest: If there is an error with the JWS header or verification + method. + web.HTTPNotFound: If there is an error resolving the verification method. """ context: AdminRequestContext = request["context"] body = await request.json() diff --git a/pyproject.toml b/pyproject.toml index 96278614d7..e3a62fd19a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -104,7 +104,7 @@ lint.ignore = [ "D202", # Allow blank line after docstring "D104", # Don't require docstring in public package # Things that we should fix, but are too much work right now - "D417", "C901", + "C901", ] include = ["aries_cloudagent/**/*.py"]