Skip to content

Commit

Permalink
feat: issue credential endpoint with app succuss
Browse files Browse the repository at this point in the history
Signed-off-by: Adam Burdett <[email protected]>
  • Loading branch information
burdettadam committed Nov 21, 2023
1 parent 1107d16 commit 249b025
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
16 changes: 8 additions & 8 deletions oid4vci/oid4vci/v1_0/public_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,18 +144,17 @@ async def issue_cred(request: web.Request):
async with context.profile.session() as session:
ex_record = await OID4VCIExchangeRecord.retrieve_by_id(session, exchange_id)
assert ex_record.supported_cred_id
LOGGER.info(f"record: {ex_record}")
LOGGER.info(f"ex record: {ex_record}")
LOGGER.info(f"supported_cred_id: {ex_record.supported_cred_id}")
supported = await SupportedCredential.retrieve_by_id(
session, ex_record.supported_cred_id
)
LOGGER.info(f"sup record: {supported}")
except (StorageError, BaseModelError, StorageNotFoundError) as err:
raise web.HTTPBadRequest(reason=err.roll_up) from err

if supported.format_data and supported.format_data.get("types") != body.get(
"types"
):
raise web.HTTPBadRequest(reason="Requested types does not match offer.")
# TODO: improve types checking
# if supported.format_data and body.get("types")[0] in supported.format_data.get("types"):
# raise web.HTTPBadRequest(reason="Requested types does not match offer.")
if supported.format != body.get("format"):
raise web.HTTPBadRequest(reason="Requested format does not match offer.")
if supported.format != "jwt_vc_json":
Expand All @@ -168,11 +167,12 @@ async def issue_cred(request: web.Request):
cred_id = str(uuid.uuid4())
kid = None
if proof := body.get("proof"):
LOGGER.info(f"proof: {proof}")
try:
header = JWT.get_unverified_header(proof.jwt)
header = JWT.get_unverified_header(proof["jwt"])
kid = header.get("kid")
decoded_payload = JWT.decode(
proof.jwt, options={"verify_signature": False}
proof["jwt"], options={"verify_signature": False}
) # TODO: verify proof
nonce = decoded_payload.get("nonce") # TODO: why is this not c_nonce?
if ex_record.nonce != nonce:
Expand Down
6 changes: 5 additions & 1 deletion oid4vci/oid4vci/v1_0/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,12 +336,16 @@ async def get_cred_offer(request: web.BaseRequest):
record.code = code
# Save the code to the exchange record
await record.save(session, reason="New cred offer code")
sup_record = await SupportedCredential.retrieve_by_id(
session, record.supported_cred_id
)

except (StorageError, BaseModelError) as err:
raise web.HTTPBadRequest(reason=err.roll_up) from err
# Create offer object
offer = {
"credential_issuer": issuer_url,
"credentials": [record.supported_cred_id],
"credentials": [sup_record.identifier],
"grants": {
# "authorization_code": {
# "issuer_state": 'previously-created-state',
Expand Down

0 comments on commit 249b025

Please sign in to comment.