From 2fc08341ddc78ec5a16bf6715749b0d6aa2d2d23 Mon Sep 17 00:00:00 2001 From: sander Date: Sun, 1 Oct 2023 23:29:18 +0200 Subject: [PATCH 01/11] updated lockfile --- yarn.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yarn.lock b/yarn.lock index 16342eb8..a62bc008 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4614,7 +4614,7 @@ "@urql/core" ">=2.3.1" wonka "^4.0.14" -"@veramo-community/lds-ecdsa-secp256k1-recovery2020@github:uport-project/EcdsaSecp256k1RecoverySignature2020", "@veramo-community/lds-ecdsa-secp256k1-recovery2020@uport-project/EcdsaSecp256k1RecoverySignature2020": +"@veramo-community/lds-ecdsa-secp256k1-recovery2020@uport-project/EcdsaSecp256k1RecoverySignature2020": version "0.0.8" resolved "https://codeload.github.com/uport-project/EcdsaSecp256k1RecoverySignature2020/tar.gz/ab0db52de6f4e6663ef271a48009ba26e688ef9b" dependencies: From 1019a35463121c82e1a213b2b02c2bdb71a23232 Mon Sep 17 00:00:00 2001 From: sander Date: Fri, 20 Oct 2023 13:48:52 +0200 Subject: [PATCH 02/11] WAL-660: fixed AvailableCredentials when pex.selectFrom() returns errors --- .../SSICredentialsRequiredScreen/index.tsx | 45 ++++++++++++------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/src/screens/SSICredentialsRequiredScreen/index.tsx b/src/screens/SSICredentialsRequiredScreen/index.tsx index 15ed0265..19548db7 100644 --- a/src/screens/SSICredentialsRequiredScreen/index.tsx +++ b/src/screens/SSICredentialsRequiredScreen/index.tsx @@ -50,12 +50,17 @@ const SSICredentialsRequiredScreen: FC = (props: Props): JSX.Element => { restrictToFormats: format, restrictToDIDMethods: subjectSyntaxTypesSupported, }); - const matchedVCs: Array = selectResult.verifiableCredential - ? selectResult.verifiableCredential - .map((matchedVC: IVerifiableCredential) => getMatchingUniqueVerifiableCredential(uniqueVCs, matchedVC)) - .filter((matchedVC): matchedVC is UniqueVerifiableCredential => !!matchedVC) // filter out the undefined (should not happen) - : []; - availableVCs.set(inputDescriptor.id, matchedVCs); + if (selectResult.areRequiredCredentialsPresent === "error") { + console.error(JSON.stringify(selectResult.errors)); + availableVCs.set(inputDescriptor.id, []); + } else { + const matchedVCs: Array = selectResult.verifiableCredential + ? selectResult.verifiableCredential + .map((matchedVC: IVerifiableCredential) => getMatchingUniqueVerifiableCredential(uniqueVCs, matchedVC)) + .filter((matchedVC): matchedVC is UniqueVerifiableCredential => !!matchedVC) // filter out the undefined (should not happen) + : []; + availableVCs.set(inputDescriptor.id, matchedVCs); + } }); setAvailableCredentials(availableVCs); }); @@ -151,6 +156,22 @@ const SSICredentialsRequiredScreen: FC = (props: Props): JSX.Element => { ? undefined : () => onItemPress(itemInfo.item.id, availableCredentials.get(itemInfo.item.id)!, itemInfo.item.purpose); + const checkIsMatching = (itemInfo: any, selectedCredentials: any, pex: any, getOriginalVerifiableCredential: any) => { + if (!selectedCredentials.has(itemInfo.item.id)) { + return false; + } + + const credentials = selectedCredentials.get(itemInfo.item.id)!.map((uniqueVC: any) => getOriginalVerifiableCredential(uniqueVC.verifiableCredential)); + + return pex.evaluateCredentials( + { + id: itemInfo.item.id, + input_descriptors: [itemInfo.item], + }, + credentials + ).areRequiredCredentialsPresent === Status.INFO; + }; + return ( = (props: Props): JSX.Element => { purpose={itemInfo.item.purpose} available={availableCredentials.has(itemInfo.item.id) ? availableCredentials.get(itemInfo.item.id)! : undefined} selected={selectedCredentials.has(itemInfo.item.id) ? selectedCredentials.get(itemInfo.item.id)! : []} - isMatching={ - selectedCredentials.has(itemInfo.item.id) - ? pex.evaluateCredentials( - { - id: itemInfo.item.id, - input_descriptors: [itemInfo.item], - }, - selectedCredentials.get(itemInfo.item.id)!.map(uniqueVC => getOriginalVerifiableCredential(uniqueVC.verifiableCredential)), - ).areRequiredCredentialsPresent === Status.INFO - : false - } + isMatching={checkIsMatching(itemInfo, selectedCredentials, pex, getOriginalVerifiableCredential)} listIndex={itemInfo.index} onPress={onPress} /> From 7818e16a6cfbadabbf26c63e21835debb84b2789 Mon Sep 17 00:00:00 2001 From: sander Date: Fri, 20 Oct 2023 13:57:01 +0200 Subject: [PATCH 03/11] WAL-660: fixed AvailableCredentials when pex.selectFrom() returns errors --- src/screens/SSICredentialsRequiredScreen/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/screens/SSICredentialsRequiredScreen/index.tsx b/src/screens/SSICredentialsRequiredScreen/index.tsx index 19548db7..26d4a6d9 100644 --- a/src/screens/SSICredentialsRequiredScreen/index.tsx +++ b/src/screens/SSICredentialsRequiredScreen/index.tsx @@ -51,7 +51,7 @@ const SSICredentialsRequiredScreen: FC = (props: Props): JSX.Element => { restrictToDIDMethods: subjectSyntaxTypesSupported, }); if (selectResult.areRequiredCredentialsPresent === "error") { - console.error(JSON.stringify(selectResult.errors)); + console.info('pex.selectFrom returned errors:\n', JSON.stringify(selectResult.errors)); availableVCs.set(inputDescriptor.id, []); } else { const matchedVCs: Array = selectResult.verifiableCredential From 34b6e7ddb447f7c87c674238e053ebd15be44f84 Mon Sep 17 00:00:00 2001 From: sander Date: Fri, 20 Oct 2023 14:32:10 +0200 Subject: [PATCH 04/11] WAL-660: fixed AvailableCredentials to properly match from vc_path --- .../SSICredentialsRequiredScreen/index.tsx | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/screens/SSICredentialsRequiredScreen/index.tsx b/src/screens/SSICredentialsRequiredScreen/index.tsx index 26d4a6d9..3dbb77a6 100644 --- a/src/screens/SSICredentialsRequiredScreen/index.tsx +++ b/src/screens/SSICredentialsRequiredScreen/index.tsx @@ -9,6 +9,7 @@ import React, {FC, useEffect, useState} from 'react'; import {ListRenderItemInfo} from 'react-native'; import {SwipeListView} from 'react-native-swipe-list-view'; + import {OVERVIEW_INITIAL_NUMBER_TO_RENDER} from '../../@config/constants'; import {ibGetCredentialBranding} from '../../agent'; import SSIButtonsContainer from '../../components/containers/SSIButtonsContainer'; @@ -23,6 +24,8 @@ import { import {ScreenRoutesEnum, StackParamList} from '../../types'; import {getMatchingUniqueVerifiableCredential, getOriginalVerifiableCredential} from '../../utils/CredentialUtils'; import {toCredentialSummary} from '../../utils/mappers/credential/CredentialMapper'; +import { SubmissionRequirementMatch } from "@sphereon/pex/dist/main/lib/evaluation/core/submissionRequirementMatch"; +import { JSONPath } from "@astronautlabs/jsonpath/src/jsonpath"; type Props = NativeStackScreenProps; @@ -52,15 +55,17 @@ const SSICredentialsRequiredScreen: FC = (props: Props): JSX.Element => { }); if (selectResult.areRequiredCredentialsPresent === "error") { console.info('pex.selectFrom returned errors:\n', JSON.stringify(selectResult.errors)); - availableVCs.set(inputDescriptor.id, []); - } else { - const matchedVCs: Array = selectResult.verifiableCredential - ? selectResult.verifiableCredential - .map((matchedVC: IVerifiableCredential) => getMatchingUniqueVerifiableCredential(uniqueVCs, matchedVC)) - .filter((matchedVC): matchedVC is UniqueVerifiableCredential => !!matchedVC) // filter out the undefined (should not happen) - : []; - availableVCs.set(inputDescriptor.id, matchedVCs); } + const matchedVCs: Array = selectResult.matches && selectResult.verifiableCredential + ? selectResult.matches.map((match: SubmissionRequirementMatch) => { + const matchedVC = JSONPath.query(selectResult, match.vc_path[0]) + if(matchedVC && matchedVC.length > 0) { + return getMatchingUniqueVerifiableCredential(uniqueVCs, matchedVC[0]); + } + }) + .filter((matchedVC): matchedVC is UniqueVerifiableCredential => !!matchedVC) // filter out the undefined (should not happen) + : []; + availableVCs.set(inputDescriptor.id, matchedVCs); }); setAvailableCredentials(availableVCs); }); From ffa6dc87f5dab9d8f53908c9cff315cee8e74a02 Mon Sep 17 00:00:00 2001 From: sander Date: Fri, 20 Oct 2023 14:38:32 +0200 Subject: [PATCH 05/11] WAL-660: fixed AvailableCredentials to properly match from vc_path --- src/screens/SSICredentialsRequiredScreen/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/screens/SSICredentialsRequiredScreen/index.tsx b/src/screens/SSICredentialsRequiredScreen/index.tsx index 3dbb77a6..1b3ed557 100644 --- a/src/screens/SSICredentialsRequiredScreen/index.tsx +++ b/src/screens/SSICredentialsRequiredScreen/index.tsx @@ -59,7 +59,7 @@ const SSICredentialsRequiredScreen: FC = (props: Props): JSX.Element => { const matchedVCs: Array = selectResult.matches && selectResult.verifiableCredential ? selectResult.matches.map((match: SubmissionRequirementMatch) => { const matchedVC = JSONPath.query(selectResult, match.vc_path[0]) - if(matchedVC && matchedVC.length > 0) { + if(matchedVC && matchedVC.length) { return getMatchingUniqueVerifiableCredential(uniqueVCs, matchedVC[0]); } }) From bc5fadd0c2df55d0012b09c6b8318fb428653d44 Mon Sep 17 00:00:00 2001 From: sander Date: Fri, 20 Oct 2023 14:51:31 +0200 Subject: [PATCH 06/11] WAL-660: fixed checkIsMatching --- src/screens/SSICredentialsRequiredScreen/index.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/screens/SSICredentialsRequiredScreen/index.tsx b/src/screens/SSICredentialsRequiredScreen/index.tsx index 1b3ed557..d4b525d4 100644 --- a/src/screens/SSICredentialsRequiredScreen/index.tsx +++ b/src/screens/SSICredentialsRequiredScreen/index.tsx @@ -161,17 +161,19 @@ const SSICredentialsRequiredScreen: FC = (props: Props): JSX.Element => { ? undefined : () => onItemPress(itemInfo.item.id, availableCredentials.get(itemInfo.item.id)!, itemInfo.item.purpose); - const checkIsMatching = (itemInfo: any, selectedCredentials: any, pex: any, getOriginalVerifiableCredential: any) => { + const checkIsMatching = (itemInfo: ListRenderItemInfo, + selectedCredentials: Map>) => { if (!selectedCredentials.has(itemInfo.item.id)) { return false; } - const credentials = selectedCredentials.get(itemInfo.item.id)!.map((uniqueVC: any) => getOriginalVerifiableCredential(uniqueVC.verifiableCredential)); + const credentials = selectedCredentials.get(itemInfo.item.id)!.map((uniqueVC: UniqueVerifiableCredential) => + getOriginalVerifiableCredential(uniqueVC.verifiableCredential)); return pex.evaluateCredentials( { id: itemInfo.item.id, - input_descriptors: [itemInfo.item], + input_descriptors: [itemInfo.item] }, credentials ).areRequiredCredentialsPresent === Status.INFO; @@ -184,7 +186,7 @@ const SSICredentialsRequiredScreen: FC = (props: Props): JSX.Element => { purpose={itemInfo.item.purpose} available={availableCredentials.has(itemInfo.item.id) ? availableCredentials.get(itemInfo.item.id)! : undefined} selected={selectedCredentials.has(itemInfo.item.id) ? selectedCredentials.get(itemInfo.item.id)! : []} - isMatching={checkIsMatching(itemInfo, selectedCredentials, pex, getOriginalVerifiableCredential)} + isMatching={checkIsMatching(itemInfo, selectedCredentials)} listIndex={itemInfo.index} onPress={onPress} /> From 777e87126cf5e111dcbd9e66f6c5ae875ab8310e Mon Sep 17 00:00:00 2001 From: sander Date: Fri, 20 Oct 2023 14:53:01 +0200 Subject: [PATCH 07/11] WAL-660: console.debug --- src/screens/SSICredentialsRequiredScreen/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/screens/SSICredentialsRequiredScreen/index.tsx b/src/screens/SSICredentialsRequiredScreen/index.tsx index d4b525d4..f65ee228 100644 --- a/src/screens/SSICredentialsRequiredScreen/index.tsx +++ b/src/screens/SSICredentialsRequiredScreen/index.tsx @@ -54,7 +54,7 @@ const SSICredentialsRequiredScreen: FC = (props: Props): JSX.Element => { restrictToDIDMethods: subjectSyntaxTypesSupported, }); if (selectResult.areRequiredCredentialsPresent === "error") { - console.info('pex.selectFrom returned errors:\n', JSON.stringify(selectResult.errors)); + console.debug('pex.selectFrom returned errors:\n', JSON.stringify(selectResult.errors)); } const matchedVCs: Array = selectResult.matches && selectResult.verifiableCredential ? selectResult.matches.map((match: SubmissionRequirementMatch) => { From 5c25a0471faf5fc105806129edbedacabe676d94 Mon Sep 17 00:00:00 2001 From: sander Date: Fri, 20 Oct 2023 14:56:25 +0200 Subject: [PATCH 08/11] WAL-660: if (matchedVC?.lenght) --- src/screens/SSICredentialsRequiredScreen/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/screens/SSICredentialsRequiredScreen/index.tsx b/src/screens/SSICredentialsRequiredScreen/index.tsx index f65ee228..37134aa1 100644 --- a/src/screens/SSICredentialsRequiredScreen/index.tsx +++ b/src/screens/SSICredentialsRequiredScreen/index.tsx @@ -59,7 +59,7 @@ const SSICredentialsRequiredScreen: FC = (props: Props): JSX.Element => { const matchedVCs: Array = selectResult.matches && selectResult.verifiableCredential ? selectResult.matches.map((match: SubmissionRequirementMatch) => { const matchedVC = JSONPath.query(selectResult, match.vc_path[0]) - if(matchedVC && matchedVC.length) { + if (matchedVC?.length) { return getMatchingUniqueVerifiableCredential(uniqueVCs, matchedVC[0]); } }) From 3f29e73f9561e9a9d3319a51484a97a4d2707392 Mon Sep 17 00:00:00 2001 From: sander Date: Fri, 20 Oct 2023 15:26:33 +0200 Subject: [PATCH 09/11] WAL-660: PR feedback --- src/screens/SSICredentialsRequiredScreen/index.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/screens/SSICredentialsRequiredScreen/index.tsx b/src/screens/SSICredentialsRequiredScreen/index.tsx index 37134aa1..e8bec268 100644 --- a/src/screens/SSICredentialsRequiredScreen/index.tsx +++ b/src/screens/SSICredentialsRequiredScreen/index.tsx @@ -53,17 +53,17 @@ const SSICredentialsRequiredScreen: FC = (props: Props): JSX.Element => { restrictToFormats: format, restrictToDIDMethods: subjectSyntaxTypesSupported, }); - if (selectResult.areRequiredCredentialsPresent === "error") { + if (selectResult.areRequiredCredentialsPresent === Status.ERROR) { console.debug('pex.selectFrom returned errors:\n', JSON.stringify(selectResult.errors)); } const matchedVCs: Array = selectResult.matches && selectResult.verifiableCredential ? selectResult.matches.map((match: SubmissionRequirementMatch) => { - const matchedVC = JSONPath.query(selectResult, match.vc_path[0]) - if (matchedVC?.length) { + const matchedVC = JSONPath.query(selectResult, match.vc_path[0]) // TODO Can we have multiple vc_path elements for a single match? + if (matchedVC?.length > 0) { return getMatchingUniqueVerifiableCredential(uniqueVCs, matchedVC[0]); } }) - .filter((matchedVC): matchedVC is UniqueVerifiableCredential => !!matchedVC) // filter out the undefined (should not happen) + .filter((matchedVC : UniqueVerifiableCredential | undefined): matchedVC is UniqueVerifiableCredential => !!matchedVC) // filter out the undefined (should not happen) : []; availableVCs.set(inputDescriptor.id, matchedVCs); }); From c166e5000057e321d441a188ea610af2f62a5dc5 Mon Sep 17 00:00:00 2001 From: sander Date: Fri, 20 Oct 2023 15:35:58 +0200 Subject: [PATCH 10/11] WAL-660: PR feedback --- src/screens/SSICredentialsRequiredScreen/index.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/screens/SSICredentialsRequiredScreen/index.tsx b/src/screens/SSICredentialsRequiredScreen/index.tsx index e8bec268..ab65b80b 100644 --- a/src/screens/SSICredentialsRequiredScreen/index.tsx +++ b/src/screens/SSICredentialsRequiredScreen/index.tsx @@ -162,14 +162,17 @@ const SSICredentialsRequiredScreen: FC = (props: Props): JSX.Element => { : () => onItemPress(itemInfo.item.id, availableCredentials.get(itemInfo.item.id)!, itemInfo.item.purpose); const checkIsMatching = (itemInfo: ListRenderItemInfo, - selectedCredentials: Map>) => { + selectedCredentials: Map>) : boolean => { if (!selectedCredentials.has(itemInfo.item.id)) { return false; } + const selectedCredential: Array | undefined = selectedCredentials.get(itemInfo.item.id); + if(!selectedCredential) { + return false + } - const credentials = selectedCredentials.get(itemInfo.item.id)!.map((uniqueVC: UniqueVerifiableCredential) => + const credentials : Array = selectedCredential.map((uniqueVC: UniqueVerifiableCredential) => getOriginalVerifiableCredential(uniqueVC.verifiableCredential)); - return pex.evaluateCredentials( { id: itemInfo.item.id, From 4c334202c1cbd562d04610441064586f72aa95e7 Mon Sep 17 00:00:00 2001 From: sander Date: Fri, 20 Oct 2023 16:08:41 +0200 Subject: [PATCH 11/11] WAL-660: PR feedback --- src/screens/SSICredentialsRequiredScreen/index.tsx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/screens/SSICredentialsRequiredScreen/index.tsx b/src/screens/SSICredentialsRequiredScreen/index.tsx index ab65b80b..621c6bd6 100644 --- a/src/screens/SSICredentialsRequiredScreen/index.tsx +++ b/src/screens/SSICredentialsRequiredScreen/index.tsx @@ -1,9 +1,9 @@ import {NativeStackScreenProps} from '@react-navigation/native-stack'; -import {PEX, SelectResults} from '@sphereon/pex'; +import { PEX, SelectResults, SubmissionRequirementMatch } from "@sphereon/pex"; import {Status} from '@sphereon/pex/dist/main/lib/ConstraintUtils'; import {InputDescriptorV1, InputDescriptorV2} from '@sphereon/pex-models'; import {ICredentialBranding} from '@sphereon/ssi-sdk.data-store'; -import {CredentialMapper, IVerifiableCredential, OriginalVerifiableCredential, W3CVerifiableCredential} from '@sphereon/ssi-types'; +import {CredentialMapper, OriginalVerifiableCredential} from '@sphereon/ssi-types'; import {UniqueVerifiableCredential} from '@veramo/core'; import React, {FC, useEffect, useState} from 'react'; import {ListRenderItemInfo} from 'react-native'; @@ -24,7 +24,6 @@ import { import {ScreenRoutesEnum, StackParamList} from '../../types'; import {getMatchingUniqueVerifiableCredential, getOriginalVerifiableCredential} from '../../utils/CredentialUtils'; import {toCredentialSummary} from '../../utils/mappers/credential/CredentialMapper'; -import { SubmissionRequirementMatch } from "@sphereon/pex/dist/main/lib/evaluation/core/submissionRequirementMatch"; import { JSONPath } from "@astronautlabs/jsonpath/src/jsonpath"; type Props = NativeStackScreenProps; @@ -59,7 +58,7 @@ const SSICredentialsRequiredScreen: FC = (props: Props): JSX.Element => { const matchedVCs: Array = selectResult.matches && selectResult.verifiableCredential ? selectResult.matches.map((match: SubmissionRequirementMatch) => { const matchedVC = JSONPath.query(selectResult, match.vc_path[0]) // TODO Can we have multiple vc_path elements for a single match? - if (matchedVC?.length > 0) { + if (matchedVC && matchedVC.length > 0) { return getMatchingUniqueVerifiableCredential(uniqueVCs, matchedVC[0]); } })