Skip to content

Commit

Permalink
OID4VCI demo page no auth flow
Browse files Browse the repository at this point in the history
  • Loading branch information
cykoder committed Sep 21, 2024
1 parent 799fa81 commit 5058882
Showing 1 changed file with 43 additions and 2 deletions.
45 changes: 43 additions & 2 deletions pages/openid.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ function OID4VPProofRequest({ title, desc, proofRequestSetupObject }) {
export default function Home() {
const [ebsiURLS, setEBSIUrls] = useState();
const [credentialOffer, setCredentialOffer] = useState();
const [credentialOfferNoAuth, setCredentialOfferNoAuth] = useState();

async function createCredentialOffer() {
const { data: oidcIssuer } = await postRequest(`${dockUrl}/openid/issuers`, {
Expand All @@ -264,6 +265,24 @@ export default function Home() {
setCredentialOffer(credentialOffer);
}

async function createCredentialOfferNoAuth() {
const { data: oidcIssuer } = await postRequest(`${dockUrl}/openid/issuers`, {
credentialOptions: {
credential: {
...credential,
issuer: process.env.NEXT_PUBLIC_QUOTIENT_ISSUER_ID,
},
},
singleUse: true,
});

const { data: credentialOffer } = await postRequest(`${dockUrl}/openid/credential-offers`, {
id: oidcIssuer.id,
});

setCredentialOfferNoAuth(credentialOffer);
}

async function generateEBSIUrls() {
const { data: proofRequest } = await postRequest(`${dockUrl}/proof-requests`, {
did: process.env.NEXT_PUBLIC_QUOTIENT_ISSUER_ID,
Expand All @@ -276,8 +295,9 @@ export default function Home() {
}

useEffect(() => {
if (!credentialOffer) {
if (!credentialOffer && !credentialOfferNoAuth) {
createCredentialOffer();
createCredentialOfferNoAuth();
}
}, []);

Expand All @@ -295,7 +315,7 @@ export default function Home() {
</div>
</div>
<div className="pt-5 grid xl:grid-cols-3 lg:grid-cols-3 md:grid-cols-3 sm:grid-cols-2 sm:grid-cols-1 gap-4 text-center">
<div>
<div>
<div className="orgCard">
<div className="cardImg valign-middle m-auto">
<p className="font-bold mb-5">OID4VCI</p>
Expand All @@ -317,6 +337,27 @@ export default function Home() {
</div>
</div>

<div>
<div className="orgCard">
<div className="cardImg valign-middle m-auto">
<p className="font-bold mb-5">OID4VCI (no auth)</p>
<div>
{credentialOfferNoAuth ? (
<QRCodeGenerator url={credentialOfferNoAuth.url} />
) : (
<>Loading...</>
)}
</div>
</div>
<hr />
<div className="pt-5 min-h-28">
<p className="text-sm">
Scan this QR code to initiate an OID4VCI import flow and instantly get a credential.
</p>
</div>
</div>
</div>

<OID4VPProofRequest
proofRequestSetupObject={dockProofRequest}
title="OID4VP"
Expand Down

0 comments on commit 5058882

Please sign in to comment.