Basically add DID support

Changed files
+39 -1
docs
src
atpasser
+1 -1
docs/roadmap.md
···
|OAuth||
|Event Stream||
|Sync||
-
|DID||
+
|DID|Only implements data model part.|
|Handle||
|NSID||
|TID|`tid` Done, however not implemented to Data Model and Lexicon|
+38
src/atpasser/did/__init__.py
···
+
import re
+
+
+
class DID:
+
"""
+
A class representing a DID.
+
+
Attributes:
+
uri (str): The DID URI.
+
"""
+
def __init__(self, uri: str) -> None:
+
"""
+
Initalizes an DID object.
+
+
Parameters:
+
uri (str): The DID URI.
+
"""
+
pattern = re.compile("^did:[a-z]+:[a-zA-Z0-9._:%-]*[a-zA-Z0-9._-]$")
+
patternMatch = pattern.match(uri)
+
if patternMatch and len(uri) <= 2048:
+
self.uri = patternMatch[0]
+
else:
+
raise ValueError
+
+
def __str__(self) -> str:
+
"""
+
Convert the TID to a string by given the URI.
+
"""
+
return self.uri
+
+
def __eq__(self, value: object, /) -> bool:
+
"""
+
Check if the 2 values are exactly the same.
+
"""
+
if isinstance(value, DID):
+
return str(self) == str(value)
+
else:
+
raise TypeError