diff --git a/oid4vci/demo/frontend/src/QRCodePage.js b/oid4vci/demo/frontend/src/QRCodePage.js index 0efa6ec0c..54a3c2d51 100644 --- a/oid4vci/demo/frontend/src/QRCodePage.js +++ b/oid4vci/demo/frontend/src/QRCodePage.js @@ -23,7 +23,7 @@ const QRCodePage = () => { .get(`http://localhost:3001/oid4vci/exchange/records`, {exchange_id: exchange_id}) .then((response) => { console.log(response.data); - if(response.data.state === "completed"){ + if(response.data.state === "issued"){ navigate(`/`); } }) diff --git a/oid4vci/int/oid4vci_client/did.py b/oid4vci/int/oid4vci_client/did.py index c15eca330..17c69bbdf 100644 --- a/oid4vci/int/oid4vci_client/did.py +++ b/oid4vci/int/oid4vci_client/did.py @@ -1,6 +1,7 @@ """DID Registration.""" import base64 +import json from typing import Literal, Tuple from aries_askar import Key, KeyAlg @@ -17,8 +18,9 @@ def generate(key_type: Literal["ed25519", "secp256k1"]) -> Tuple[str, AskarKey]: else: raise ValueError(f"Unknown key type: {key_type}") - jwk = vk.get_jwk_public() - encoded = base64.urlsafe_b64encode(jwk.encode()).rstrip(b"=").decode() + jwk = json.loads(vk.get_jwk_public()) + jwk["use"] = "sig" + encoded = base64.urlsafe_b64encode(json.dumps(jwk).encode()).rstrip(b"=").decode() did = f"did:jwk:{encoded}" key = AskarKey(vk, f"{did}#0") return did, key diff --git a/oid4vci/oid4vci/models/exchange.py b/oid4vci/oid4vci/models/exchange.py index 7454e0ac1..e70acc136 100644 --- a/oid4vci/oid4vci/models/exchange.py +++ b/oid4vci/oid4vci/models/exchange.py @@ -25,7 +25,8 @@ class Meta: STATE_CREATED = "created" STATE_OFFER_CREATED = "offer" STATE_ISSUED = "issued" - STATES = (STATE_CREATED, STATE_OFFER_CREATED, STATE_ISSUED) + STATE_FAILED = "failed" + STATES = (STATE_CREATED, STATE_OFFER_CREATED, STATE_ISSUED, STATE_FAILED) TAG_NAMES = {"state", "supported_cred_id", "code"} def __init__( diff --git a/oid4vci/oid4vci/public_routes.py b/oid4vci/oid4vci/public_routes.py index 42b13ff7e..9d2f6721e 100644 --- a/oid4vci/oid4vci/public_routes.py +++ b/oid4vci/oid4vci/public_routes.py @@ -235,9 +235,7 @@ async def handle_proof_of_posession( profile: Profile, proof: Dict[str, Any], nonce: str ): """Handle proof of posession.""" - breakpoint() - LOGGER.info(f"proof: {proof}") - encoded_headers, encoded_payload, encoded_signiture = proof["jwt"].split(".", 3) + encoded_headers, encoded_payload, encoded_signature = proof["jwt"].split(".", 3) headers = b64_to_dict(encoded_headers) if headers.get("typ") != "openid4vci-proof+jwt": @@ -259,7 +257,7 @@ async def handle_proof_of_posession( reason="Invalid proof: wrong nonce.", ) - decoded_signature = b64_to_bytes(encoded_signiture, urlsafe=True) + decoded_signature = b64_to_bytes(encoded_signature, urlsafe=True) verified = key.verify_signature( f"{encoded_headers}.{encoded_payload}".encode(), decoded_signature, @@ -377,8 +375,9 @@ async def issue_cred(request: web.Request): ex_record.state = OID4VCIExchangeRecord.STATE_ISSUED # Cause webhook to be emitted await ex_record.save(session, reason="Credential issued") - # Exchange is completed, delete record - await ex_record.delete_record(session) + # Exchange is completed, record can be cleaned up + # But we'll leave it to the controller + # await ex_record.delete_record(session) return web.json_response( {