Skip to content

Commit

Permalink
Merge pull request #53 from Indicio-tech/fix/didcomm-accept-field
Browse files Browse the repository at this point in the history
fix: didcomm service accepts "accept"
  • Loading branch information
dbluhm committed Aug 24, 2022
2 parents 1e68ae9 + 078423b commit 357a92f
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
10 changes: 6 additions & 4 deletions pydid/doc/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,12 @@ def add_didcomm(
self,
service_endpoint: str,
recipient_keys: List[VerificationMethod],
routing_keys: List[VerificationMethod] = None,
routing_keys: Optional[List[VerificationMethod]] = None,
*,
priority: int = None,
type_: str = None,
ident: Optional[str] = None
priority: Optional[int] = None,
type_: Optional[str] = None,
ident: Optional[str] = None,
accept: Optional[List[str]] = None
):
"""Add DIDComm Service."""
ident = ident or next(self._id_generator)
Expand All @@ -155,6 +156,7 @@ def add_didcomm(
routing_keys=[vmethod.id for vmethod in routing_keys],
type=type_,
priority=priority,
accept=accept,
)
self.services.append(service)
return service
Expand Down
3 changes: 2 additions & 1 deletion pydid/service.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""DID Doc Service."""

from typing import List, Union
from typing import List, Optional, Union

from pydantic import Extra, AnyUrl
from typing_extensions import Literal
Expand Down Expand Up @@ -34,6 +34,7 @@ class Config:
type: Literal["IndyAgent", "did-communication"] = "did-communication"
recipient_keys: List[DIDUrl]
routing_keys: List[DIDUrl] = []
accept: Optional[List[str]] = None
priority: int = 0


Expand Down
15 changes: 15 additions & 0 deletions tests/doc/test_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,12 @@ def test_programmatic_construction_didcomm():
route = builder.verification_method.add(
ExampleVerificationMethod, public_key_example="abcd"
)
builder.service.add_didcomm(
service_endpoint="https://example.com",
recipient_keys=[key],
routing_keys=[route],
accept=["didcomm/aip2;env=rfc19"],
)
builder.service.add_didcomm(
service_endpoint="https://example.com",
recipient_keys=[key],
Expand Down Expand Up @@ -449,6 +455,15 @@ def test_programmatic_construction_didcomm():
"recipientKeys": ["did:example:123#key-0"],
"routingKeys": ["did:example:123#key-1"],
"priority": 0,
"accept": ["didcomm/aip2;env=rfc19"],
},
{
"id": "did:example:123#service-1",
"type": "did-communication",
"serviceEndpoint": "https://example.com",
"recipientKeys": ["did:example:123#key-0"],
"routingKeys": ["did:example:123#key-1"],
"priority": 1,
}
],
}
Expand Down
1 change: 1 addition & 0 deletions tests/test_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ def test_serialization(service_raw):
"recipientKeys": ["did:example:123#keys-1"],
"routingKeys": [],
"priority": 0,
"accept": ["didcomm/aip2;env=rfc19"]
}

DIDCOMM_SERVICES = [DIDCOMM_SERVICE0, DIDCOMM_SERVICE1, DIDCOMM_SERVICE2]
Expand Down

0 comments on commit 357a92f

Please sign in to comment.