Skip to content

Commit

Permalink
fix: small fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Bluhm <[email protected]>
  • Loading branch information
dbluhm committed Nov 29, 2023
1 parent cc238b0 commit 9104072
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion oid4vci/demo/frontend/src/QRCodePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(`/`);
}
})
Expand Down
6 changes: 4 additions & 2 deletions oid4vci/int/oid4vci_client/did.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""DID Registration."""

import base64
import json
from typing import Literal, Tuple

from aries_askar import Key, KeyAlg
Expand All @@ -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
3 changes: 2 additions & 1 deletion oid4vci/oid4vci/models/exchange.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__(
Expand Down
11 changes: 5 additions & 6 deletions oid4vci/oid4vci/public_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand All @@ -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,
Expand Down Expand Up @@ -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(
{
Expand Down

0 comments on commit 9104072

Please sign in to comment.