From 042103afa351fdfba4ee4a28dae3d960d541ea24 Mon Sep 17 00:00:00 2001 From: gregory1996 Date: Thu, 20 Jun 2024 13:14:06 +0300 Subject: [PATCH 1/3] Improve style of ribbons on verifier detailed presentation --- views/verifier/detailed-presentation.pug | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/verifier/detailed-presentation.pug b/views/verifier/detailed-presentation.pug index f85ce95..06362e5 100644 --- a/views/verifier/detailed-presentation.pug +++ b/views/verifier/detailed-presentation.pug @@ -10,7 +10,7 @@ block layout-content each credential, index in credentialPayloads - const branding = credential.credentialBranding || { backgroundColor: 'red', textColor: 'black' } - const imageUrl = credential.credentialBranding.image.url // Get the corresponding image URL - .credential-box(style=`display: flex; flex-direction: column; justify-content: flex-start; align-items: flex-start; position: relative; padding: 10px;`, id=`credential-box-${index}`) + .credential-box(style=`position:relative;overflow:hidden;display: flex; flex-direction: column; justify-content: flex-start; align-items: flex-start; position: relative; margin: 10px;border-radius:10px;`, id=`credential-box-${index}`) img(style="width: 240px; height: 150px; border-radius: 10px;")(src=imageUrl) h3 Requested claims extracted from credentials From 06273f1372db4cdf7bdc81fe1577b4a9fc79a8ec Mon Sep 17 00:00:00 2001 From: gregory1996 Date: Fri, 28 Jun 2024 16:22:07 +0300 Subject: [PATCH 2/3] Add dynamic table display for claims --- views/verifier/detailed-presentation.pug | 18 ++++++++++++++---- views/verifier/presentations.pug | 16 ++++++++++++++-- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/views/verifier/detailed-presentation.pug b/views/verifier/detailed-presentation.pug index 06362e5..6eea022 100644 --- a/views/verifier/detailed-presentation.pug +++ b/views/verifier/detailed-presentation.pug @@ -15,10 +15,20 @@ block layout-content h3 Requested claims extracted from credentials - // Text area to display claims - textarea#json-textarea.wide - //- Display the 'credentialPayloads' JSON object - | #{JSON.stringify(presentationClaims, null, 2)} + .claims-tables + each claimType in Object.keys(presentationClaims) + h4= claimType + .table-container(style="overflow-x: auto;") + table + thead + tr + th Name + th Value + tbody + each claim in presentationClaims[claimType] + tr + td= claim.name + td= claim.value h3 Credentials diff --git a/views/verifier/presentations.pug b/views/verifier/presentations.pug index 2a1aa50..8835c5d 100644 --- a/views/verifier/presentations.pug +++ b/views/verifier/presentations.pug @@ -10,8 +10,20 @@ block layout-content p .card-text Date: #{vp.date} .card-text Claims: - textarea#json-textarea.wide - | #{JSON.stringify(vp.claims, null, 2)} + + .claims-tables(style="align-items: start;") + each claimType in Object.keys(vp.claims) + .table-container(style="overflow-x: auto;") + table + thead + tr + th Name + th Value + tbody + each claim in vp.claims[claimType] + tr + td= claim.name + td= claim.value .card-text Holder Info: #{vp.holderInfo} .card-buttons button.btn.btn-primary(onclick=`window.location.href = "/verifier-panel/presentation/${vp.id}"`) Inspect details From 905f567548bae147e24cbe1ed962310e3e95ff57 Mon Sep 17 00:00:00 2001 From: kkmanos Date: Fri, 28 Jun 2024 17:50:45 +0300 Subject: [PATCH 3/3] added name attribue in input descriptor field --- .../OpenidForPresentationReceivingService.ts | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/services/OpenidForPresentationReceivingService.ts b/src/services/OpenidForPresentationReceivingService.ts index f59dae8..f234e96 100644 --- a/src/services/OpenidForPresentationReceivingService.ts +++ b/src/services/OpenidForPresentationReceivingService.ts @@ -19,6 +19,14 @@ import config from "../../config"; import { DidKeyResolverService } from "./DidKeyResolverService"; import { HasherAlgorithm, HasherAndAlgorithm, SdJwt, SignatureAndEncryptionAlgorithm, Verifier } from "@sd-jwt/core"; +// https://identity.foundation/presentation-exchange/ +// The fields object MAY contain a name property. If present, its value MUST be a string, and SHOULD be a human-friendly name that describes what the target field represents. +type CustomInputDescriptorConstraintFieldType = { + name?: string; + path: string[]; + filter?: any; +}; + const hasherAndAlgorithm: HasherAndAlgorithm = { hasher: (input: string) => createHash('sha256').update(input).digest(), algorithm: HasherAlgorithm.Sha256 @@ -392,10 +400,11 @@ export class OpenidForPresentationsReceivingService implements OpenidForPresenta presentationClaims[desc.id] = []; // initialize } const fieldPath = field.path[0]; // get first path + const fieldName = (field as CustomInputDescriptorConstraintFieldType).name; const value = String(JSONPath({ path: fieldPath, json: prettyClaims.vc as any })[0]); const splittedPath = fieldPath.split('.'); - const claimName = splittedPath[splittedPath.length - 1]; - presentationClaims[desc.id].push({ name: claimName, value: value } as ClaimRecord); + const claimName = fieldName ? fieldName : splittedPath[splittedPath.length - 1]; + presentationClaims[desc.id].push({ name: claimName, value: typeof value == 'object' ? JSON.stringify(value) : value } as ClaimRecord); }); console.log("Verification result = ", verificationResult) if (!verificationResult.isSignatureValid || !verificationResult.areRequiredClaimsIncluded) { @@ -416,10 +425,11 @@ export class OpenidForPresentationsReceivingService implements OpenidForPresenta presentationClaims[desc.id] = []; // initialize } const fieldPath = field.path[0]; // get first path + const fieldName = (field as CustomInputDescriptorConstraintFieldType).name; const value = String(JSONPath({ path: fieldPath, json: jwtPayload.vc })[0]); const splittedPath = fieldPath.split('.'); - const claimName = splittedPath[splittedPath.length - 1]; - presentationClaims[desc.id].push({ name: claimName, value: value } as ClaimRecord); + const claimName = fieldName ? fieldName : splittedPath; + presentationClaims[desc.id].push({ name: claimName, value: typeof value == 'object' ? JSON.stringify(value) : value } as ClaimRecord); }); } }