diff --git a/package.json b/package.json index 35d7302..07ec54b 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "@digitalcredentials/vc-status-list": "^9.0.0", "@digitalcredentials/vpqr": "^2.2.1", "axios": "^1.7.7", + "credential-handler-polyfill": "^4.0.0", "jsonld-signatures": "^11.3.0", "luxon": "^3.0.1", "material-icons": "^1.11.4", diff --git a/pages/index.tsx b/pages/index.tsx index fc99a45..170a397 100755 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -1,7 +1,8 @@ import type { NextPage } from 'next' +import * as polyfill from 'credential-handler-polyfill' import styles from './index.module.css' import { Button } from 'components/Button/Button' -import { useEffect, useState, } from 'react' +import { useEffect, useState } from 'react' import { ScanModal } from 'components/ScanModal/ScanModal' import { CredentialCard } from 'components/CredentialCard/CredentialCard' import { Container } from 'components/Container/Container' @@ -33,8 +34,13 @@ const Home: NextPage = () => { useEffect(() => { document.documentElement.lang = "en"; document.title = "VerifierPlus Home page"; + + polyfill.loadOnce() + .then(_ => { console.log('CHAPI polyfill loaded.') }) + .catch(e => { console.error('Error loading CHAPI polyfill:', e) }) + const handlePopstate = () => { - if (window.location.hash === '/') { + if (window.location.hash === '/') { setCredential(undefined); setWasMulti(false); } else { @@ -99,6 +105,33 @@ const Home: NextPage = () => { setIsOpen(!isOpen); } + async function requestVcOnClick() { + const credentialQuery = { + web: { + VerifiablePresentation: { + query: [ + { + type: 'QueryByExample', + reason: 'VerifierPlus is requesting any credential for verification.', + type: ['VerifiableCredential'] + } + ] + } + } + } as CredentialRequestOptions + + const chapiResult = await navigator.credentials.get(credentialQuery) as any + + if(!chapiResult?.data) { + console.log('no credentials received'); + } + + console.log(chapiResult); + + const { data: vp } = chapiResult + setCredential(vp) + } + async function getJSONFromURL(url: string) { try { let response = await fetch(url); @@ -185,19 +218,14 @@ const Home: NextPage = () => {

- VerifierPlus allows users to verify any supported digital academic credential. + VerifierPlus allows users to verify any supported digital academic + credential. This site is hosted by - the Digital Credentials Consortium - , a network of leading international universities designing an open - infrastructure for digital academic credentials. Why trust us? + the Digital Credentials Consortium + , a network of leading international universities designing an open + infrastructure for digital academic credentials. Why trust us?

-