Skip to content

Commit

Permalink
Merge pull request #478 from wwWallet/multi-presentation-view
Browse files Browse the repository at this point in the history
Fix: multi presentation view
  • Loading branch information
kkmanos authored Dec 3, 2024
2 parents e1dedd1 + 7951ef0 commit 5adafcc
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/components/History/HistoryList.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import useScreenType from '../../hooks/useScreenType';
import { formatDate } from '../../functions/DateFormat';
import { H3 } from '../Shared/Heading';
import HistoryDetailPopup from '../Popups/HistoryDetailPopup';
import { fromBase64 } from '../../util';

const HistoryList = ({ credentialId = null, history, title = '', limit = null }) => {

Expand All @@ -21,7 +22,7 @@ const HistoryList = ({ credentialId = null, history, title = '', limit = null })
}, [history, credentialId, limit]);

const handleHistoryItemClick = async (item) => {
setMatchingCredentials([item.presentation]);
setMatchingCredentials(item.presentation.startsWith("b64:") ? JSON.parse(new TextDecoder().decode(fromBase64(item.presentation.replace("b64:", "")))) : [ item.presentation ] );
if (screenType === 'mobile') {
navigate(`/history/${item.id}`);
}
Expand Down
4 changes: 3 additions & 1 deletion src/lib/services/OpenID4VPRelyingParty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { extractSAN, getPublicKeyFromB64Cert } from "../utils/pki";
import axios from "axios";
import { BACKEND_URL, OPENID4VP_SAN_DNS_CHECK_SSL_CERTS, OPENID4VP_SAN_DNS_CHECK } from "../../config";
import { CredentialBatchHelper } from "./CredentialBatchHelper";
import { toBase64 } from "../../util";

export class OpenID4VPRelyingParty implements IOpenID4VPRelyingParty {

Expand Down Expand Up @@ -354,7 +355,8 @@ export class OpenID4VPRelyingParty implements IOpenID4VPRelyingParty {

const credentialIdentifiers = originalVCs.map((vc) => vc.credentialIdentifier);

const storePresentationPromise = this.storeVerifiablePresentation(generatedVPs[0], presentationSubmission.descriptor_map[0].format, credentialIdentifiers, presentationSubmission, client_id);
const presentations = "b64:" + toBase64(new TextEncoder().encode(generatedVPs.length == 1 ? generatedVPs[0] : JSON.stringify(generatedVPs)));
const storePresentationPromise = this.storeVerifiablePresentation(presentations, "", credentialIdentifiers, presentationSubmission, client_id);
const updateCredentialPromise = filteredVCEntities.map(async (cred) => this.credentialBatchHelper.useCredential(cred))

const updateRepositoryPromise = this.openID4VPRelyingPartyStateRepository.store(S);
Expand Down
4 changes: 2 additions & 2 deletions src/pages/History/HistoryDetail.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import SessionContext from '../../context/SessionContext';

// Utility functions
import { formatDate } from '../../functions/DateFormat';
import { fromBase64 } from '../../util';

// Hooks
import useFetchPresentations from '../../hooks/useFetchPresentations';
Expand All @@ -28,8 +29,7 @@ const HistoryDetail = () => {

useEffect(() => {
if (history.length > 0) {
const verifiableCredentials = [history[0].presentation];
setMatchingCredentials(verifiableCredentials);
setMatchingCredentials(history[0].startsWith("b64:") ? JSON.parse(new TextDecoder().decode(fromBase64(history[0].replace("b64:", "")))) : [ history[0] ] );
}
}, [history]);

Expand Down

0 comments on commit 5adafcc

Please sign in to comment.