Skip to content

Commit 0409f81

Browse files
authored
Merge pull request #77 from Indicio-tech/fix/didcomm-2.1-service
fix: align with DIDComm v2.1 spec for service endpoints
2 parents c790b7c + efb6dff commit 0409f81

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

Diff for: pydid/service.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class Config:
6363
extra = Extra.forbid
6464

6565
type: Literal["DIDCommMessaging"] = "DIDCommMessaging"
66-
service_endpoint: List[DIDCommV2ServiceEndpoint]
66+
service_endpoint: Union[List[DIDCommV2ServiceEndpoint], DIDCommV2ServiceEndpoint]
6767

6868

6969
class UnknownService(Service):

Diff for: tests/test_service.py

+18
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,15 @@
5454
}
5555
],
5656
},
57+
{
58+
"id": "did:example:123456789abcdefghi#didcomm-1",
59+
"type": "DIDCommMessaging",
60+
"serviceEndpoint": {
61+
"uri": "https://example.com/path",
62+
"accept": ["didcomm/v2", "didcomm/aip2;env=rfc587"],
63+
"routingKeys": ["did:example:somemediator#somekey"],
64+
},
65+
},
5766
]
5867

5968
INVALID_SERVICES = [
@@ -172,6 +181,15 @@ def test_serialization(service_raw):
172181
}
173182
],
174183
},
184+
{
185+
"id": "did:example:123456789abcdefghi#didcomm-1",
186+
"type": "DIDCommMessaging",
187+
"serviceEndpoint": {
188+
"uri": "https://example.com/path",
189+
"accept": ["didcomm/v2", "didcomm/aip2;env=rfc587"],
190+
"routingKeys": ["did:example:somemediator#somekey"],
191+
},
192+
},
175193
]
176194

177195
DIDCOMM_INVALID_SERVICES = [

Diff for: tests/test_verification_method.py

+8
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,14 @@ def test_validator_allow_missing_controller():
162162
"publicKeyBase58": "12345",
163163
},
164164
)
165+
with pytest.raises(ValueError):
166+
vmethod = VerificationMethod.deserialize(
167+
{
168+
"id": "hi",
169+
"type": "Ed25519Signature2018",
170+
"publicKeyBase58": "12345",
171+
},
172+
)
165173

166174

167175
def test_make():

0 commit comments

Comments
 (0)