Skip to content

Commit

Permalink
chore: propose official deprecations
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Bluhm <[email protected]>
  • Loading branch information
dbluhm committed Mar 22, 2024
1 parent a79c5c7 commit c5c26af
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 5 deletions.
21 changes: 16 additions & 5 deletions aries_cloudagent/config/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,15 +327,26 @@ def print_banner(
@classmethod
def print_notices(cls, settings: Settings):
"""Print notices and warnings."""
if settings.get("wallet.type", "in_memory").lower() == "indy":
with Banner(border=":", length=80, file=sys.stderr) as banner:
banner.centered("⚠ DEPRECATION NOTICE: ⚠")
banner.hr()
with Banner(border=":", length=80, file=sys.stderr) as banner:
banner.centered("⚠ DEPRECATION NOTICE: ⚠")
banner.hr()
if settings.get("wallet.type", "in_memory").lower() == "indy":
banner.print(
"The Indy wallet type is deprecated, use Askar instead; see: "
"https://aca-py.org/main/deploying/IndySDKtoAskarMigration/",
)
print()
banner.hr()
banner.print(
"Aries RFC 0160: Connection Protocol is deprecated and support will be "
"removed in a future version; use RFC 0023: DID Exchange instead."
)
banner.hr()
banner.print(
"Using `did:sov:BzCbsNYhMrjHiqZDTUASHg;spec` in protocols is deprecated "
"and support will be removed in a future version; use "
"https://didcomm.org/ instead."
)
print()


######################################################################
Expand Down
14 changes: 14 additions & 0 deletions aries_cloudagent/core/dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,20 @@ async def make_message(

if not message_type:
raise MessageParseError("Message does not contain '@type' parameter")

if message_type.startswith("did:sov"):
warnings.warn(
"Using `did:sov:BzCbsNYhMrjHiqZDTUASHg;spec` in protocols is deprecated "
"and support will be removed in a future version; use "
"https://didcomm.org/ instead.",
DeprecationWarning,
)
self.logger.warning(
"Using `did:sov:BzCbsNYhMrjHiqZDTUASHg;spec` in protocols is deprecated "
"and support will be removed in a future version; use "
"https://didcomm.org/ instead.",
)

message_type_rec_version = get_version_from_message_type(message_type)

registry: ProtocolRegistry = self.profile.inject(ProtocolRegistry)
Expand Down
20 changes: 20 additions & 0 deletions aries_cloudagent/protocols/connections/v1_0/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import logging
from typing import Optional, Sequence, Tuple, Union, cast
import warnings

from ....connections.base_manager import BaseConnectionManager
from ....connections.models.conn_record import ConnRecord
Expand Down Expand Up @@ -52,6 +53,18 @@ def profile(self) -> Profile:
"""
return self._profile

def deprecation_warning(self):
"""Log a deprecation warning."""
warnings.warn(
"Aries RFC 0160: Connection Protocol is deprecated and support will be "
"removed in a future version; use RFC 0023: DID Exchange instead.",
DeprecationWarning,
)
self._logger.warning(
"Aries RFC 0160: Connection Protocol is deprecated and support will be "
"removed in a future version; use RFC 0023: DID Exchange instead."
)

async def create_invitation(
self,
my_label: Optional[str] = None,
Expand Down Expand Up @@ -107,6 +120,7 @@ async def create_invitation(
A tuple of the new `ConnRecord` and `ConnectionInvitation` instances
"""
self.deprecation_warning()
# Mediation Record can still be None after this operation if no
# mediation id passed and no default
mediation_record = await self._route_manager.mediation_record_if_id(
Expand Down Expand Up @@ -257,6 +271,7 @@ async def receive_invitation(
The new `ConnRecord` instance
"""
self.deprecation_warning()
if not invitation.did:
if not invitation.recipient_keys:
raise ConnectionManagerError(
Expand Down Expand Up @@ -338,6 +353,7 @@ async def create_request(
A new `ConnectionRequest` message to send to the other agent
"""
self.deprecation_warning()

mediation_records = await self._route_manager.mediation_records_for_connection(
self.profile,
Expand Down Expand Up @@ -411,6 +427,7 @@ async def receive_request(
The new or updated `ConnRecord` instance
"""
self.deprecation_warning()
ConnRecord.log_state(
"Receiving connection request",
{"request": request},
Expand Down Expand Up @@ -575,6 +592,7 @@ async def create_response(
A tuple of the updated `ConnRecord` new `ConnectionResponse` message
"""
self.deprecation_warning()
ConnRecord.log_state(
"Creating connection response",
{"connection_id": connection.connection_id},
Expand Down Expand Up @@ -686,6 +704,7 @@ async def accept_response(
at the request or response stage
"""
self.deprecation_warning()
connection = None
if response._thread:
# identify the request by the thread ID
Expand Down Expand Up @@ -765,6 +784,7 @@ async def receive_problem_report(
report: ConnectionProblemReport,
):
"""Receive problem report."""
self.deprecation_warning()
if not report.description:
raise ConnectionManagerError("Missing description in problem report")

Expand Down
4 changes: 4 additions & 0 deletions aries_cloudagent/protocols/connections/v1_0/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,7 @@ async def connections_metadata_set(request: web.BaseRequest):
@docs(
tags=["connection"],
summary="Create a new connection invitation",
deprecated=True,
)
@querystring_schema(CreateInvitationQueryStringSchema())
@request_schema(CreateInvitationRequestSchema())
Expand Down Expand Up @@ -667,6 +668,7 @@ async def connections_create_invitation(request: web.BaseRequest):
@docs(
tags=["connection"],
summary="Receive a new connection invitation",
deprecated=True,
)
@querystring_schema(ReceiveInvitationQueryStringSchema())
@request_schema(ReceiveInvitationRequestSchema())
Expand Down Expand Up @@ -708,6 +710,7 @@ async def connections_receive_invitation(request: web.BaseRequest):
@docs(
tags=["connection"],
summary="Accept a stored connection invitation",
deprecated=True,
)
@match_info_schema(ConnectionsConnIdMatchInfoSchema())
@querystring_schema(AcceptInvitationQueryStringSchema())
Expand Down Expand Up @@ -758,6 +761,7 @@ async def connections_accept_invitation(request: web.BaseRequest):
@docs(
tags=["connection"],
summary="Accept a stored connection request",
deprecated=True,
)
@match_info_schema(ConnectionsConnIdMatchInfoSchema())
@querystring_schema(AcceptRequestQueryStringSchema())
Expand Down

0 comments on commit c5c26af

Please sign in to comment.