Basically add DID support

Changed files
+39 -1
docs
src
atpasser
+1 -1
docs/roadmap.md
··· 15 15 |OAuth|| 16 16 |Event Stream|| 17 17 |Sync|| 18 - |DID|| 18 + |DID|Only implements data model part.| 19 19 |Handle|| 20 20 |NSID|| 21 21 |TID|`tid` Done, however not implemented to Data Model and Lexicon|
+38
src/atpasser/did/__init__.py
··· 1 + import re 2 + 3 + 4 + class DID: 5 + """ 6 + A class representing a DID. 7 + 8 + Attributes: 9 + uri (str): The DID URI. 10 + """ 11 + def __init__(self, uri: str) -> None: 12 + """ 13 + Initalizes an DID object. 14 + 15 + Parameters: 16 + uri (str): The DID URI. 17 + """ 18 + pattern = re.compile("^did:[a-z]+:[a-zA-Z0-9._:%-]*[a-zA-Z0-9._-]$") 19 + patternMatch = pattern.match(uri) 20 + if patternMatch and len(uri) <= 2048: 21 + self.uri = patternMatch[0] 22 + else: 23 + raise ValueError 24 + 25 + def __str__(self) -> str: 26 + """ 27 + Convert the TID to a string by given the URI. 28 + """ 29 + return self.uri 30 + 31 + def __eq__(self, value: object, /) -> bool: 32 + """ 33 + Check if the 2 values are exactly the same. 34 + """ 35 + if isinstance(value, DID): 36 + return str(self) == str(value) 37 + else: 38 + raise TypeError