From a597db992dca2c44a9b3114c24515142cc18c487 Mon Sep 17 00:00:00 2001 From: waltkb <68587968+waltkb@users.noreply.github.com> Date: Wed, 22 Nov 2023 15:11:17 +0100 Subject: [PATCH] Add parse disclosure composable --- .../kotlin/id/walt/service/SSIKit2WalletService.kt | 1 + web/src/composables/disclosures.ts | 10 ++++++++++ .../wallet/[wallet]/credentials/[credentialId].vue | 8 ++------ .../pages/wallet/[wallet]/exchange/presentation.vue | 3 +++ 4 files changed, 16 insertions(+), 6 deletions(-) create mode 100644 web/src/composables/disclosures.ts diff --git a/src/main/kotlin/id/walt/service/SSIKit2WalletService.kt b/src/main/kotlin/id/walt/service/SSIKit2WalletService.kt index e35301f..d26ce81 100644 --- a/src/main/kotlin/id/walt/service/SSIKit2WalletService.kt +++ b/src/main/kotlin/id/walt/service/SSIKit2WalletService.kt @@ -191,6 +191,7 @@ class SSIKit2WalletService(accountId: UUID, walletId: UUID) : WalletService(acco val presentationSession = credentialWallet.initializeAuthorization(authReq, 60.seconds) .copy(selectedCredentialIds = selectedCredentialIds.toSet()) + println("Resolved presentation definition: ${presentationSession.authorizationRequest!!.presentationDefinition!!.toJSONString()}") val tokenResponse = credentialWallet.processImplicitFlowAuthorization(presentationSession.authorizationRequest!!) diff --git a/web/src/composables/disclosures.ts b/web/src/composables/disclosures.ts new file mode 100644 index 0000000..b1a2fbd --- /dev/null +++ b/web/src/composables/disclosures.ts @@ -0,0 +1,10 @@ +import { decodeBase64ToUtf8 } from "~/composables/base64"; + +export function parseDisclosures(disclosureString: string) { + try { + return disclosureString.split("~").map((elem) => JSON.parse(decodeBase64ToUtf8(elem))); + } catch (e) { + console.error("Error parsing disclosures:", e); + return []; + } +} diff --git a/web/src/pages/wallet/[wallet]/credentials/[credentialId].vue b/web/src/pages/wallet/[wallet]/credentials/[credentialId].vue index 3a5757d..6624044 100644 --- a/web/src/pages/wallet/[wallet]/credentials/[credentialId].vue +++ b/web/src/pages/wallet/[wallet]/credentials/[credentialId].vue @@ -303,6 +303,7 @@ import BackButton from "~/components/buttons/BackButton.vue"; import { ref } from "vue"; import { decodeBase64ToUtf8 } from "~/composables/base64"; import VerifiableCredentialCard from "~/components/credentials/VerifiableCredentialCard.vue"; +import { parseDisclosures } from "~/composables/disclosures"; const route = useRoute(); const credentialId = route.params.credentialId as string; @@ -330,12 +331,7 @@ const jwtJson = computed(() => { const disclosures = computed(() => { if (credential.value && credential.value.disclosures) { - try { - return credential.value.disclosures.split("~").map((elem) => JSON.parse(decodeBase64ToUtf8(elem))); - } catch (e) { - console.error(e); - return []; - } + return parseDisclosures(credential.value.disclosures) } else return null; }); diff --git a/web/src/pages/wallet/[wallet]/exchange/presentation.vue b/web/src/pages/wallet/[wallet]/exchange/presentation.vue index 653622f..b5c4d45 100644 --- a/web/src/pages/wallet/[wallet]/exchange/presentation.vue +++ b/web/src/pages/wallet/[wallet]/exchange/presentation.vue @@ -84,6 +84,8 @@ :show-id="true" /> +
Debug: SD Disclosures = {{ parseDisclosures(credential.disclosures) }}
+ @@ -138,6 +140,7 @@ import { useTitle } from "@vueuse/core"; import VerifiableCredentialCard from "~/components/credentials/VerifiableCredentialCard.vue"; import { Disclosure, DisclosureButton, DisclosurePanel } from "@headlessui/vue"; +import { parseDisclosures } from "../../../../composables/disclosures"; const currentWallet = useCurrentWallet();