Skip to content
This repository has been archived by the owner on Jan 9, 2024. It is now read-only.

Commit

Permalink
Add parse disclosure composable
Browse files Browse the repository at this point in the history
  • Loading branch information
waltkb committed Nov 22, 2023
1 parent 7213a6f commit a597db9
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/main/kotlin/id/walt/service/SSIKit2WalletService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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!!)
Expand Down
10 changes: 10 additions & 0 deletions web/src/composables/disclosures.ts
Original file line number Diff line number Diff line change
@@ -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 [];
}
}
8 changes: 2 additions & 6 deletions web/src/pages/wallet/[wallet]/credentials/[credentialId].vue
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
});
Expand Down
3 changes: 3 additions & 0 deletions web/src/pages/wallet/[wallet]/exchange/presentation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@
:show-id="true"
/>

<div v-if="credential.disclosures">Debug: SD Disclosures = {{ parseDisclosures(credential.disclosures) }}</div>

</label>
</div>
</div>
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit a597db9

Please sign in to comment.