Skip to content
This repository has been archived by the owner on Apr 11, 2023. It is now read-only.

Commit

Permalink
feat(sdk): added signature verification for issued with openid4ci cre…
Browse files Browse the repository at this point in the history
…dential

Signed-off-by: Anton Biriukov <[email protected]>
  • Loading branch information
birtony committed Jan 17, 2023
1 parent 975e94e commit 83c0184
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions cmd/wallet-js-sdk/src/oidc/issuance/openid4ci.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ async function getCredential(
},
};

const credentialResponse = await axios
const { credential, format } = await axios
.post(
transactionData.issuerMetadata.credential_endpoint,
credentialRequest,
Expand All @@ -337,9 +337,20 @@ async function getCredential(
});
// TODO deferred flow implementation deferred

const jwtVerificationStatus = await jwtManager.verifyJWT(authToken, {
jwt: credential,
});

if (!jwtVerificationStatus.verified) {
throw new Error(
"Error issuing a credential through OpenID4CI: failed to verify signature on the issued credential:",
jwtVerificationStatus.error
);
}

return {
format: credentialResponse.format,
credential: credentialResponse.credential,
format,
credential,
};
}

Expand Down

0 comments on commit 83c0184

Please sign in to comment.