diff --git a/site/docs/web5/build/verifiable-credentials/presentation-exchange.mdx b/site/docs/web5/build/verifiable-credentials/presentation-exchange.mdx
index e4e151275..3a42d3830 100644
--- a/site/docs/web5/build/verifiable-credentials/presentation-exchange.mdx
+++ b/site/docs/web5/build/verifiable-credentials/presentation-exchange.mdx
@@ -17,7 +17,8 @@ import getLoanAppPresentationDefinitionKt from '!!raw-loader!@site/snippets/test
import satisfiesPresentationDefinitionForPexKt from '!!raw-loader!@site/snippets/testsuite-kotlin/src/test/kotlin/docs/web5/build/verifiablecredentials/satisfiesPresentationDefinitionForPexKt.snippet.kt'
import selectCredentialsForPexKt from '!!raw-loader!@site/snippets/testsuite-kotlin/src/test/kotlin/docs/web5/build/verifiablecredentials/selectCredentialsForPexKt.snippet.kt'
import createPresentationFromCredentialsForPexKt from '!!raw-loader!@site/snippets/testsuite-kotlin/src/test/kotlin/docs/web5/build/verifiablecredentials/createPresentationFromCredentialsForPexKt.snippet.kt'
-import validVerifiablePresentationForPexKt from '!!raw-loader!@site/snippets/testsuite-kotlin/src/test/kotlin/docs/web5/build/verifiablecredentials/validVerifiablePresentationForPexKt.snippet.kt'
+import validatePresentationSubmissionForPexKt from '!!raw-loader!@site/snippets/testsuite-kotlin/src/test/kotlin/docs/web5/build/verifiablecredentials/validatePresentationSubmissionForPexKt.snippet.kt'
+import signVpForPexKt from '!!raw-loader!@site/snippets/testsuite-kotlin/src/test/kotlin/docs/web5/build/verifiablecredentials/signVpForPexKt.snippet.kt'
@@ -71,6 +72,7 @@ import { PresentationExchange } from '@web5/credentials';
code: `
import web5.sdk.credentials.PresentationExchange
import web5.sdk.credentials.VerifiablePresentation
+import web5.sdk.credentials.model.PresentationSubmission
import web5.sdk.credentials.model.*
`,
language: 'Kotlin',
@@ -110,8 +112,13 @@ Once you've confirmed that the VCs successfully satisfy the Presentation Definit
@@ -215,20 +222,34 @@ Before submitting the presentation to a lender, you can validate the Presentatio
+
+:::note
+The information regarding `Checked` objects is only applicable to the JavaScript SDK.
+:::
+
+
+
-This method checks the presentation submission for any errors, returns an array of `Checked` objects representing the validation checks performed on the presentation submission:
-
-```js
-[ Checked { tag: 'root', status: 'info', message: 'ok' } ]
-```
Each `Checked` object contains:
@@ -236,14 +257,18 @@ Each `Checked` object contains:
- **status**: the result of the check, which is `info` for successful checks or `error` for failed checks
- **message**: shows `ok` if successful, and if unsuccessful this is where you'll find error messages
-## Verifiable Presentation
-
+## Verifiable Presentation
-
+/>
\ No newline at end of file
diff --git a/site/testsuites/testsuite-kotlin/src/test/kotlin/docs/web5/build/verifiablecredentials/PresentationExchangeTest.kt b/site/testsuites/testsuite-kotlin/src/test/kotlin/docs/web5/build/verifiablecredentials/PresentationExchangeTest.kt
index f75804024..697e6f91c 100644
--- a/site/testsuites/testsuite-kotlin/src/test/kotlin/docs/web5/build/verifiablecredentials/PresentationExchangeTest.kt
+++ b/site/testsuites/testsuite-kotlin/src/test/kotlin/docs/web5/build/verifiablecredentials/PresentationExchangeTest.kt
@@ -1,11 +1,13 @@
-package website.tbd.developer.site.docs.web5.build.decentralizedidentifiers;
+package website.tbd.developer.site.docs.web5.build.verifiablecredentials;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Assertions.*
import web5.sdk.crypto.InMemoryKeyManager
+import web5.sdk.dids.methods.dht.DidDht
import web5.sdk.credentials.PresentationExchange
import web5.sdk.credentials.VerifiableCredential
import web5.sdk.credentials.VerifiablePresentation
+import web5.sdk.credentials.model.PresentationSubmission
import web5.sdk.credentials.model.*
/**
@@ -121,47 +123,44 @@ internal class PresentationExchangeTest {
// :snippet-end:
}
}
-
- @Test
- fun `createPresentationFromCredentialsForPexKt creates a presentation result`() {
- val holderDid = "did:key:zQ3shXrAnbgfytQYQjifUm2EcBBbRAeAeGfgC4TZrjw4X71iZ"
- val selectedCredentials = allCredentials
- // :snippet-start: createPresentationFromCredentialsForPexKt
- val presentationResult = PresentationExchange.createPresentationFromCredentials(
- vcJwts = selectedCredentials,
- presentationDefinition = presentationDefinition
- )
-
- val verifiablePresentation = VerifiablePresentation.create(
- vcJwts = selectedCredentials,
- holder = holderDid,
- additionalData = mapOf("presentation_submission" to presentationResult)
- )
- // :snippet-end:
- assertNotNull(verifiablePresentation, "Verifiable Presentation should not be null")
- assertEquals(holderDid, verifiablePresentation.holder, "Holder DID should match")
- }
@Test
- fun `validVerifiablePresentationForPexKt creates a valid VP`() {
- val holderDid = "did:key:zQ3shXrAnbgfytQYQjifUm2EcBBbRAeAeGfgC4TZrjw4X71iZ"
+ fun `createPresentationForPexKt creates a presentation result, a valid VP, and validates submission`() {
+ val holderDid = DidDht.create(InMemoryKeyManager())
val selectedCredentials = allCredentials
+ // :snippet-start: createPresentationFromCredentialsForPexKt
val presentationResult = PresentationExchange.createPresentationFromCredentials(
vcJwts = selectedCredentials,
presentationDefinition = presentationDefinition
)
+
val verifiablePresentation = VerifiablePresentation.create(
vcJwts = selectedCredentials,
- holder = holderDid,
+ holder = holderDid.uri,
additionalData = mapOf("presentation_submission" to presentationResult)
)
- // :snippet-start: validVerifiablePresentationForPexKt
- val verifiablePresentationDataModelMap = verifiablePresentation.vpDataModel.toMap()
- val mappedPresentationSubmission = verifiablePresentationDataModelMap["presentation_submission"] as? PresentationSubmission
+ // :snippet-end:
+ assertDoesNotThrow {
+ // :snippet-start: validatePresentationSubmissionForPexKt
+ val vpDataMap = verifiablePresentation.vpDataModel.toMap()
+ val presentationSubmission = vpDataMap["presentation_submission"] as PresentationSubmission
+
+ try {
+ PresentationExchange.validateSubmission(presentationSubmission)
+ } catch (e: Exception) {
+ println("Invalid Presentation Submission: ${e.message}")
+ }
+ // :snippet-end:
+ }
+
+ // :snippet-start: signVpForPexKt
+ val vpJwt = verifiablePresentation.sign(holderDid)
// :snippet-end:
- assertNotNull(mappedPresentationSubmission, "Mapped Presentation Submission should not be null")
- assertEquals(presentationResult.definitionId, mappedPresentationSubmission?.definitionId, "Definition ID should match")
+ assertNotNull(verifiablePresentation, "Verifiable Presentation should not be null")
+ assertEquals(holderDid.uri, verifiablePresentation.holder, "Holder DID should match")
+ assertNotNull(vpJwt, "Verifiable Presentation JWT should not be null")
+ assertTrue(vpJwt is String, "Verifiable Presentation JWT should be a string")
}
}