Add public registration cancellation
This commit is contained in:
parent
8170373148
commit
d5a5fed69a
7 changed files with 174 additions and 8 deletions
|
|
@ -45,12 +45,24 @@ class HTTPRegistrationVerificationAdapter:
|
|||
)
|
||||
|
||||
def consume(self, opaque_handle: str) -> VerifiedRegistrationApplicant:
|
||||
return self._resolve(
|
||||
opaque_handle, "/v1/registration-verifications/consume",
|
||||
"public-registration",
|
||||
)
|
||||
|
||||
def cancel(self, opaque_handle: str) -> VerifiedRegistrationApplicant:
|
||||
return self._resolve(
|
||||
opaque_handle, "/v1/registration-verifications/cancel",
|
||||
"public-registration-cancel",
|
||||
)
|
||||
|
||||
def _resolve(
|
||||
self, opaque_handle: str, path: str, expected_purpose: str
|
||||
) -> VerifiedRegistrationApplicant:
|
||||
if len(opaque_handle) < 32:
|
||||
raise ValueError("verification handle is invalid")
|
||||
result = self._post(
|
||||
"/v1/registration-verifications/consume", {"handle": opaque_handle}
|
||||
)
|
||||
if result.get("purpose") != "public-registration":
|
||||
result = self._post(path, {"handle": opaque_handle})
|
||||
if result.get("purpose") != expected_purpose:
|
||||
raise RuntimeError("verification evidence has the wrong purpose")
|
||||
return VerifiedRegistrationApplicant(
|
||||
verification_id=str(result["verification_id"]),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue