Skip to content

Commit

Permalink
fix: sdmap from json paths and rest docu example (#321)
Browse files Browse the repository at this point in the history
  • Loading branch information
severinstampler authored Jun 19, 2023
2 parents 6a6ebee + f98a869 commit b91ac52
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 31 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ dependencies {
implementation("com.microsoft.azure:azure-client-authentication:1.7.14")
implementation("com.nimbusds:nimbus-jose-jwt:9.30.2")
implementation("com.nimbusds:oauth2-oidc-sdk:10.7")
implementation("id.walt:waltid-sd-jwt-jvm:1.2306160840.0")
implementation("id.walt:waltid-sd-jwt-jvm:1.2306191408.0")

implementation("org.bouncycastle:bcprov-jdk15to18:1.72")
implementation("org.bouncycastle:bcpkix-jdk15to18:1.72")
Expand Down
7 changes: 4 additions & 3 deletions src/main/kotlin/id/walt/signatory/rest/SignatoryController.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import id.walt.credentials.w3c.VerifiableCredential
import id.walt.credentials.w3c.builder.W3CCredentialBuilder
import id.walt.credentials.w3c.toVerifiableCredential
import id.walt.sdjwt.SDMap
import id.walt.sdjwt.SDMapBuilder
import id.walt.signatory.ProofConfig
import id.walt.signatory.ProofType
import id.walt.signatory.Signatory
Expand Down Expand Up @@ -110,9 +111,9 @@ object SignatoryController {

fun issueCredentialDocs() = document().operation {
it.summary("Issue a credential").operationId("issue").addTagsItem("Credentials").description(
"Based on a template (maintained in the VcLib), this call creates a W3C Verifiable Credential. Note that the '<b>templateId</b>, <b>issuerDid</b>, and the <b>subjectDid</b>, are mandatory parameters. All other parameters are optional. <br><br> This is a example request, that also demonstrates how to populate the credential with custom data: the <br><br>{<br>" + " \"templateId\": \"VerifiableId\",<br>" + " \"config\": {<br>" + " &nbsp;&nbsp;&nbsp;&nbsp; \"issuerDid\": \"did:ebsi:zuathxHtXTV8psijTjtuZD7\",<br>" + " &nbsp;&nbsp;&nbsp;&nbsp; \"subjectDid\": \"did:key:z6MkwfgBDSMRqXaJtw5DjhkJdDsDmRNSrvrM1L6UMBDtvaSX\",<br>" + " &nbsp;&nbsp;&nbsp;&nbsp; \"selectiveDisclosure\": {\n" +
" \"credentialSubject\": { \"sd\": true, \"nestedMap\": { \"firstName\": { \"sd\": true }}}\n" +
"}<br>},<br>" + " \"credentialData\": {<br>" + " &nbsp;&nbsp;&nbsp;&nbsp; \"credentialSubject\": {<br>" + " &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \"firstName\": \"Severin\"<br>" + " &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>" + " &nbsp;&nbsp;&nbsp;&nbsp; }<br>" + "}<br>"
"Based on a template (maintained in the VcLib), this call creates a W3C Verifiable Credential. Note that the '<b>templateId</b>, <b>issuerDid</b>, and the <b>subjectDid</b>, are mandatory parameters. All other parameters are optional. <br><br> This is a example request, that also demonstrates how to populate the credential with custom data: the <br><br>{<br>" + " \"templateId\": \"VerifiableId\",<br>" + " \"config\": {<br>" + " &nbsp;&nbsp;&nbsp;&nbsp; \"issuerDid\": \"did:ebsi:zuathxHtXTV8psijTjtuZD7\",<br>" + " &nbsp;&nbsp;&nbsp;&nbsp; \"subjectDid\": \"did:key:z6MkwfgBDSMRqXaJtw5DjhkJdDsDmRNSrvrM1L6UMBDtvaSX\",<br>" + " &nbsp;&nbsp;&nbsp;&nbsp; \"selectiveDisclosure\": \n" +
SDMapBuilder().addField("credentialSubject", false, SDMapBuilder().addField("firstName", true).build()).build().toJSON().toString() + "\n" +
"<br>},<br>" + " \"credentialData\": {<br>" + " &nbsp;&nbsp;&nbsp;&nbsp; \"credentialSubject\": {<br>" + " &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \"firstName\": \"Severin\"<br>" + " &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>" + " &nbsp;&nbsp;&nbsp;&nbsp; }<br>" + "}<br>"
)
}.body<String>()
{ it.description("IssueCredentialRequest: templateId: String, config: ProofConfig, credentialData: JsonObject") }.json<String>("200")
Expand Down
27 changes: 0 additions & 27 deletions src/test/kotlin/id/walt/signatory/SignatoryApiTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -342,33 +342,6 @@ class SignatoryApiTest : AnnotationSpec() {
})
}
)
val request = "{\n" +
" \"templateId\": \"VerifiableId\",\n" +
" \"config\": {\n" +
" \"issuerDid\": \"$did\",\n" +
" \"subjectDid\": \"$did\",\n" +
" \"proofType\": \"SD_JWT\",\n" +
" \"selectiveDisclosure\": {\n" +
" \"fields\": {\n" +
" \"credentialSubject\": {\n" +
" \"sd\": true,\n" +
" \"children\": {\n" +
" \"fields\": {\n" +
" \"firstName\": {\n" +
" \"sd\": true\n" +
" }\n" +
" }\n" +
" }\n" +
" }\n" +
" }\n" +
" }\n" +
" },\n" +
" \"credentialData\": {\n" +
" \"credentialSubject\": {\n" +
" \"firstName\": \"Severin\"\n" +
" }\n" +
" }\n" +
"}"
val vc = httpPost("/v1/credentials/issue", KlaxonWithConverters().toJsonString(reqObj))
println(vc)
val parsedVc = vc?.toVerifiableCredential()
Expand Down

0 comments on commit b91ac52

Please sign in to comment.