Exemplo n.º 1
0
    async def resolve(self, profile: Profile, did: Union[str, DID]) -> dict:
        """Resolve a DID using this resolver."""
        if isinstance(did, DID):
            did = str(did)
        else:
            DID.validate(did)
        if not await self.supports(profile, did):
            raise DIDMethodNotSupported(
                f"{self.__class__.__name__} does not support DID method for: {did}"
            )

        return await self._resolve(profile, did)
Exemplo n.º 2
0
    async def _resolve(self, profile: Profile,
                       did: Union[str, DID]) -> Tuple[BaseDIDResolver, dict]:
        """Retrieve doc and return with resolver."""
        # TODO Cache results
        if isinstance(did, DID):
            did = str(did)
        else:
            DID.validate(did)
        for resolver in await self._match_did_to_resolver(profile, did):
            try:
                LOGGER.debug("Resolving DID %s with %s", did, resolver)
                document = await resolver.resolve(
                    profile,
                    did,
                )
                return resolver, document
            except DIDNotFound:
                LOGGER.debug("DID %s not found by resolver %s", did, resolver)

        raise DIDNotFound(f"DID {did} could not be resolved")
Exemplo n.º 3
0
    async def resolve(self, profile: Profile, did: Union[str,
                                                         DID]) -> DIDDocument:
        """Resolve a DID using this resolver."""
        if isinstance(did, DID):
            did = str(did)
        else:
            DID.validate(did)
        if not await self.supports(profile, did):
            raise DIDMethodNotSupported(
                f"{self.__class__.__name__} does not support DID method for: {did}"
            )

        doc_dict = await self._resolve(profile, did)
        return DIDDocument.deserialize(
            doc_dict,
            options={
                doc_insert_missing_ids,
                doc_allow_public_key,
                vm_allow_controller_list,
                vm_allow_missing_controller,
                vm_allow_type_list,
            },
        )
Exemplo n.º 4
0
def test_validate_x(bad_did):
    with pytest.raises(InvalidDIDError):
        DID.validate(bad_did)
Exemplo n.º 5
0
def test_validate(did):
    DID.validate(did)