|
26 | 26 | import dag_cbor |
27 | 27 | from multiformats import multibase, multicodec |
28 | 28 | import requests |
| 29 | +from webutil.util import session |
29 | 30 |
|
30 | 31 | from . import util |
31 | 32 |
|
@@ -71,7 +72,7 @@ def resolve(did, **kwargs): |
71 | 72 |
|
72 | 73 | @cached(TTLCache(maxsize=CACHE_SIZE, ttl=CACHE_TTL.total_seconds()), |
73 | 74 | lock=threading.Lock()) |
74 | | -def resolve_plc(did, get_fn=util.session.get): |
| 75 | +def resolve_plc(did, get_fn=session.get): |
75 | 76 | """Resolves a ``did:plc`` by fetching its DID document from a PLC directory. |
76 | 77 |
|
77 | 78 | The PLC directory hostname is specified in the ``PLC_HOST`` environment |
@@ -111,7 +112,7 @@ def create_plc(handle, **kwargs): |
111 | 112 | return write_plc(handle=handle, **kwargs) |
112 | 113 |
|
113 | 114 |
|
114 | | -def update_plc(did, handle=None, get_fn=util.session.get, **kwargs): |
| 115 | +def update_plc(did, handle=None, get_fn=session.get, **kwargs): |
115 | 116 | """Updates an existing ``did:plc`` in a PLC directory. |
116 | 117 |
|
117 | 118 | Args are documented in :func:`write_plc`. |
@@ -140,7 +141,7 @@ def update_plc(did, handle=None, get_fn=util.session.get, **kwargs): |
140 | 141 |
|
141 | 142 | def write_plc(did=None, handle=None, signing_key=None, rotation_key=None, |
142 | 143 | new_rotation_key=None, pds_url=None, also_known_as=None, |
143 | | - prev=None, get_fn=util.session.get, post_fn=util.session.post): |
| 144 | + prev=None, get_fn=session.get, post_fn=session.post): |
144 | 145 | """Writes a PLC operation to a PLC directory. |
145 | 146 |
|
146 | 147 | Generally used to create a new ``did:plc`` or update an existing one. |
@@ -245,7 +246,7 @@ def _encode_key(key): |
245 | 246 | return did_plc._replace(signing_key=signing_key, rotation_key=rotation_key) |
246 | 247 |
|
247 | 248 |
|
248 | | -def write_plc_operation(op, rotation_key, did=None, post_fn=util.session.post): |
| 249 | +def write_plc_operation(op, rotation_key, did=None, post_fn=session.post): |
249 | 250 | """Signs and sends a PLC operation to the directory. |
250 | 251 |
|
251 | 252 | Args: |
@@ -282,7 +283,7 @@ def write_plc_operation(op, rotation_key, did=None, post_fn=util.session.post): |
282 | 283 |
|
283 | 284 |
|
284 | 285 | def rollback_plc(did, rotation_key, num_operations=1, |
285 | | - get_fn=util.session.get, post_fn=util.session.post): |
| 286 | + get_fn=session.get, post_fn=session.post): |
286 | 287 | """Reverts a DID PLC document to its last version. |
287 | 288 |
|
288 | 289 | Reads a did:plc's audit log from the directory, extracts its *previous* |
@@ -451,7 +452,7 @@ def plc_operation_to_did_doc(op): |
451 | 452 |
|
452 | 453 | @cached(TTLCache(maxsize=CACHE_SIZE, ttl=CACHE_TTL.total_seconds()), |
453 | 454 | lock=threading.Lock()) |
454 | | -def resolve_web(did, get_fn=util.session.get): |
| 455 | +def resolve_web(did, get_fn=session.get): |
455 | 456 | """Resolves a ``did:web`` by fetching its DID document. |
456 | 457 |
|
457 | 458 | ``did:web`` spec: https://w3c-ccg.github.io/did-method-web/ |
@@ -483,7 +484,7 @@ def resolve_web(did, get_fn=util.session.get): |
483 | 484 |
|
484 | 485 | @cached(TTLCache(maxsize=CACHE_SIZE, ttl=CACHE_TTL.total_seconds()), |
485 | 486 | lock=threading.Lock()) |
486 | | -def resolve_handle(handle, get_fn=util.session.get): |
| 487 | +def resolve_handle(handle, get_fn=session.get): |
487 | 488 | """Resolves an ATProto handle to a DID. |
488 | 489 |
|
489 | 490 | Supports the DNS TXT record and HTTPS well-known methods. |
|
0 commit comments