diff --git a/.github/workflows/self-test.yaml b/.github/workflows/self-test.yaml index 58df3de..cd608be 100644 --- a/.github/workflows/self-test.yaml +++ b/.github/workflows/self-test.yaml @@ -9,7 +9,7 @@ jobs: matrix: SDK: - web5-js - # - web5-kt + - web5-kt steps: - uses: actions/checkout@v3 - uses: actions/setup-go@v4 diff --git a/openapi/openapi.go b/openapi/openapi.go index 17e24bd..892a1e6 100644 --- a/openapi/openapi.go +++ b/openapi/openapi.go @@ -64,7 +64,7 @@ type CredentialIssuanceRequestCredential struct { ExpirationDate string `json:"expirationDate"` Id string `json:"id"` IssuanceDate string `json:"issuanceDate"` - Issuer CredentialIssuer `json:"issuer"` + Issuer interface{} `json:"issuer"` Type []string `json:"type"` } diff --git a/sdks/web5-kt/README.md b/sdks/web5-kt/README.md new file mode 100644 index 0000000..826694d --- /dev/null +++ b/sdks/web5-kt/README.md @@ -0,0 +1,18 @@ +# Web5-kt Local Testing and Model Generation + +## Running Tests Locally + +To run the web5-kt tests on your local machine, execute the following command: + +```bash +go run ./cmd/web5-spec-test sdks/web5-kt +``` + +## Generating Model Files +To generate the model files, use the openapi-generator with the following command: + +```bash +openapi-generator generate -i openapi.yaml -g kotlin-server -o ./kotlin-server-generated-server --skip-validate-spec +``` + +Note: After running the above command, you will need to manually copy the generated model files into the correct directory in the sdk/web5-kt models directory. \ No newline at end of file diff --git a/sdks/web5-kt/src/main/kotlin/com/web5/models/CredentialIssuanceRequest.kt b/sdks/web5-kt/src/main/kotlin/com/web5/models/CredentialIssuanceRequest.kt index eb00ee1..f414ab5 100644 --- a/sdks/web5-kt/src/main/kotlin/com/web5/models/CredentialIssuanceRequest.kt +++ b/sdks/web5-kt/src/main/kotlin/com/web5/models/CredentialIssuanceRequest.kt @@ -9,7 +9,7 @@ * https://openapi-generator.tech * Do not edit the class manually. */ -package models +package com.web5.models /** * diff --git a/sdks/web5-kt/src/main/kotlin/com/web5/models/CredentialIssuanceRequestCredential.kt b/sdks/web5-kt/src/main/kotlin/com/web5/models/CredentialIssuanceRequestCredential.kt index cff65f8..81379f0 100644 --- a/sdks/web5-kt/src/main/kotlin/com/web5/models/CredentialIssuanceRequestCredential.kt +++ b/sdks/web5-kt/src/main/kotlin/com/web5/models/CredentialIssuanceRequestCredential.kt @@ -9,11 +9,13 @@ * https://openapi-generator.tech * Do not edit the class manually. */ -package models +package com.web5.models + +import com.fasterxml.jackson.annotation.JsonProperty /** * - * @param atContext + * @param @context * @param id * @param type * @param issuer @@ -22,12 +24,13 @@ package models * @param credentialSubject */ data class CredentialIssuanceRequestCredential( - val atContext: kotlin.collections.List, + @JsonProperty("@context") + val `@context`: List?, val id: kotlin.String, val type: kotlin.collections.List, val issuer: CredentialIssuer, - val issuanceDate: kotlin.String, - val expirationDate: kotlin.String, + val issuanceDate: kotlin.String?, + val expirationDate: kotlin.String?, val credentialSubject: kotlin.collections.Map ) diff --git a/sdks/web5-kt/src/main/kotlin/com/web5/models/CredentialIssuanceRequestOptions.kt b/sdks/web5-kt/src/main/kotlin/com/web5/models/CredentialIssuanceRequestOptions.kt index 669ef6f..685a2cf 100644 --- a/sdks/web5-kt/src/main/kotlin/com/web5/models/CredentialIssuanceRequestOptions.kt +++ b/sdks/web5-kt/src/main/kotlin/com/web5/models/CredentialIssuanceRequestOptions.kt @@ -9,7 +9,7 @@ * https://openapi-generator.tech * Do not edit the class manually. */ -package models +package com.web5.models /** * diff --git a/sdks/web5-kt/src/main/kotlin/com/web5/models/CredentialIssuanceResponse.kt b/sdks/web5-kt/src/main/kotlin/com/web5/models/CredentialIssuanceResponse.kt index 87fd5f0..7bc64a1 100644 --- a/sdks/web5-kt/src/main/kotlin/com/web5/models/CredentialIssuanceResponse.kt +++ b/sdks/web5-kt/src/main/kotlin/com/web5/models/CredentialIssuanceResponse.kt @@ -9,7 +9,8 @@ * https://openapi-generator.tech * Do not edit the class manually. */ -package models +package com.web5.models + /** * diff --git a/sdks/web5-kt/src/main/kotlin/com/web5/models/CredentialIssuer.kt b/sdks/web5-kt/src/main/kotlin/com/web5/models/CredentialIssuer.kt index df89517..a3af327 100644 --- a/sdks/web5-kt/src/main/kotlin/com/web5/models/CredentialIssuer.kt +++ b/sdks/web5-kt/src/main/kotlin/com/web5/models/CredentialIssuer.kt @@ -9,7 +9,7 @@ * https://openapi-generator.tech * Do not edit the class manually. */ -package models +package com.web5.models /** diff --git a/sdks/web5-kt/src/main/kotlin/com/web5/models/CredentialProof.kt b/sdks/web5-kt/src/main/kotlin/com/web5/models/CredentialProof.kt index 25b97e5..07bbdd0 100644 --- a/sdks/web5-kt/src/main/kotlin/com/web5/models/CredentialProof.kt +++ b/sdks/web5-kt/src/main/kotlin/com/web5/models/CredentialProof.kt @@ -9,7 +9,7 @@ * https://openapi-generator.tech * Do not edit the class manually. */ -package models +package com.web5.models /** diff --git a/sdks/web5-kt/src/main/kotlin/com/web5/models/CredentialStatus.kt b/sdks/web5-kt/src/main/kotlin/com/web5/models/CredentialStatus.kt index 8266f40..19e0025 100644 --- a/sdks/web5-kt/src/main/kotlin/com/web5/models/CredentialStatus.kt +++ b/sdks/web5-kt/src/main/kotlin/com/web5/models/CredentialStatus.kt @@ -9,7 +9,7 @@ * https://openapi-generator.tech * Do not edit the class manually. */ -package models +package com.web5.models /** diff --git a/sdks/web5-kt/src/main/kotlin/com/web5/models/DIDIonCreateResponse.kt b/sdks/web5-kt/src/main/kotlin/com/web5/models/DIDIonCreateResponse.kt index 4c25d71..c33b5ab 100644 --- a/sdks/web5-kt/src/main/kotlin/com/web5/models/DIDIonCreateResponse.kt +++ b/sdks/web5-kt/src/main/kotlin/com/web5/models/DIDIonCreateResponse.kt @@ -9,7 +9,7 @@ * https://openapi-generator.tech * Do not edit the class manually. */ -package models +package com.web5.models /** diff --git a/sdks/web5-kt/src/main/kotlin/com/web5/models/PresentationDefinition.kt b/sdks/web5-kt/src/main/kotlin/com/web5/models/PresentationDefinition.kt new file mode 100644 index 0000000..056e7eb --- /dev/null +++ b/sdks/web5-kt/src/main/kotlin/com/web5/models/PresentationDefinition.kt @@ -0,0 +1,30 @@ +/** +* web5 SDK test server +* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) +* +* The version of the OpenAPI document: 0.2.0 +* +* +* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). +* https://openapi-generator.tech +* Do not edit the class manually. +*/ +package com.web5.models + + +/** + * + * @param name + * @param inputDescriptors + * @param id + * @param purpose + * @param submissionRequirements + */ +data class PresentationDefinition( + val name: kotlin.String, + val inputDescriptors: kotlin.collections.List, + val id: kotlin.String? = null, + val purpose: kotlin.String? = null, + val submissionRequirements: kotlin.collections.List? = null +) + diff --git a/sdks/web5-kt/src/main/kotlin/com/web5/models/PresentationDefinitionConstraints.kt b/sdks/web5-kt/src/main/kotlin/com/web5/models/PresentationDefinitionConstraints.kt new file mode 100644 index 0000000..5e2a82a --- /dev/null +++ b/sdks/web5-kt/src/main/kotlin/com/web5/models/PresentationDefinitionConstraints.kt @@ -0,0 +1,50 @@ +/** +* web5 SDK test server +* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) +* +* The version of the OpenAPI document: 0.2.0 +* +* +* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). +* https://openapi-generator.tech +* Do not edit the class manually. +*/ +package com.web5.models + + +/** + * + * @param limitDisclosure + * @param statuses + * @param fields + * @param subjectIsIssuer + * @param isHolder + * @param sameSubject + */ +data class PresentationDefinitionConstraints( + val limitDisclosure: PresentationDefinitionConstraints.LimitDisclosure? = null, + val statuses: PresentationDefinitionStatuses? = null, + val fields: kotlin.collections.List? = null, + val subjectIsIssuer: PresentationDefinitionConstraints.SubjectIsIssuer? = null, + val isHolder: kotlin.collections.List? = null, + val sameSubject: kotlin.collections.List? = null +) +{ + /** + * + * Values: required,preferred + */ + enum class LimitDisclosure(val value: kotlin.String){ + required("required"), + preferred("preferred"); + } + /** + * + * Values: required,preferred + */ + enum class SubjectIsIssuer(val value: kotlin.String){ + required("required"), + preferred("preferred"); + } +} + diff --git a/sdks/web5-kt/src/main/kotlin/com/web5/models/PresentationDefinitionField.kt b/sdks/web5-kt/src/main/kotlin/com/web5/models/PresentationDefinitionField.kt new file mode 100644 index 0000000..dc43eb3 --- /dev/null +++ b/sdks/web5-kt/src/main/kotlin/com/web5/models/PresentationDefinitionField.kt @@ -0,0 +1,42 @@ +/** +* web5 SDK test server +* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) +* +* The version of the OpenAPI document: 0.2.0 +* +* +* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). +* https://openapi-generator.tech +* Do not edit the class manually. +*/ +package com.web5.models + + +/** + * + * @param id + * @param path + * @param purpose + * @param filter + * @param predicate + * @param name + */ +data class PresentationDefinitionField( + val id: kotlin.String? = null, + val path: kotlin.collections.List? = null, + val purpose: kotlin.String? = null, + val filter: PresentationDefinitionFilter? = null, + val predicate: PresentationDefinitionField.Predicate? = null, + val name: kotlin.String? = null +) +{ + /** + * + * Values: required,preferred + */ + enum class Predicate(val value: kotlin.String){ + required("required"), + preferred("preferred"); + } +} + diff --git a/sdks/web5-kt/src/main/kotlin/com/web5/models/PresentationDefinitionFilter.kt b/sdks/web5-kt/src/main/kotlin/com/web5/models/PresentationDefinitionFilter.kt new file mode 100644 index 0000000..c572f9c --- /dev/null +++ b/sdks/web5-kt/src/main/kotlin/com/web5/models/PresentationDefinitionFilter.kt @@ -0,0 +1,50 @@ +/** +* web5 SDK test server +* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) +* +* The version of the OpenAPI document: 0.2.0 +* +* +* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). +* https://openapi-generator.tech +* Do not edit the class manually. +*/ +package com.web5.models + + +/** + * + * @param `const` + * @param `enum` + * @param exclusiveMinimum + * @param exclusiveMaximum + * @param format + * @param formatMaximum + * @param formatMinimum + * @param formatExclusiveMaximum + * @param formatExclusiveMinimum + * @param minLength + * @param maxLength + * @param minimum + * @param maximum + * @param pattern + * @param type + */ +data class PresentationDefinitionFilter( + val `const`: kotlin.String? = null, + val `enum`: kotlin.collections.List? = null, + val exclusiveMinimum: kotlin.String? = null, + val exclusiveMaximum: kotlin.String? = null, + val format: kotlin.String? = null, + val formatMaximum: kotlin.String? = null, + val formatMinimum: kotlin.String? = null, + val formatExclusiveMaximum: kotlin.String? = null, + val formatExclusiveMinimum: kotlin.String? = null, + val minLength: java.math.BigDecimal? = null, + val maxLength: java.math.BigDecimal? = null, + val minimum: kotlin.String? = null, + val maximum: kotlin.String? = null, + val pattern: kotlin.String? = null, + val type: kotlin.String? = null +) + diff --git a/sdks/web5-kt/src/main/kotlin/com/web5/models/PresentationDefinitionHolderSubject.kt b/sdks/web5-kt/src/main/kotlin/com/web5/models/PresentationDefinitionHolderSubject.kt new file mode 100644 index 0000000..ad6cce7 --- /dev/null +++ b/sdks/web5-kt/src/main/kotlin/com/web5/models/PresentationDefinitionHolderSubject.kt @@ -0,0 +1,34 @@ +/** +* web5 SDK test server +* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) +* +* The version of the OpenAPI document: 0.2.0 +* +* +* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). +* https://openapi-generator.tech +* Do not edit the class manually. +*/ +package com.web5.models + + +/** + * + * @param fieldId + * @param directive + */ +data class PresentationDefinitionHolderSubject( + val fieldId: kotlin.collections.List? = null, + val directive: PresentationDefinitionHolderSubject.Directive? = null +) +{ + /** + * + * Values: required,preferred + */ + enum class Directive(val value: kotlin.String){ + required("required"), + preferred("preferred"); + } +} + diff --git a/sdks/web5-kt/src/main/kotlin/com/web5/models/PresentationDefinitionInputDescriptor.kt b/sdks/web5-kt/src/main/kotlin/com/web5/models/PresentationDefinitionInputDescriptor.kt new file mode 100644 index 0000000..64a0303 --- /dev/null +++ b/sdks/web5-kt/src/main/kotlin/com/web5/models/PresentationDefinitionInputDescriptor.kt @@ -0,0 +1,32 @@ +/** +* web5 SDK test server +* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) +* +* The version of the OpenAPI document: 0.2.0 +* +* +* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). +* https://openapi-generator.tech +* Do not edit the class manually. +*/ +package com.web5.models + + +/** + * + * @param id + * @param name + * @param purpose + * @param group + * @param issuance + * @param constraints + */ +data class PresentationDefinitionInputDescriptor( + val id: kotlin.String, + val name: kotlin.String? = null, + val purpose: kotlin.String? = null, + val group: kotlin.collections.List? = null, + val issuance: kotlin.collections.List? = null, + val constraints: PresentationDefinitionConstraints? = null +) + diff --git a/sdks/web5-kt/src/main/kotlin/com/web5/models/PresentationDefinitionIssuance.kt b/sdks/web5-kt/src/main/kotlin/com/web5/models/PresentationDefinitionIssuance.kt new file mode 100644 index 0000000..f8f6ac7 --- /dev/null +++ b/sdks/web5-kt/src/main/kotlin/com/web5/models/PresentationDefinitionIssuance.kt @@ -0,0 +1,22 @@ +/** +* web5 SDK test server +* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) +* +* The version of the OpenAPI document: 0.2.0 +* +* +* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). +* https://openapi-generator.tech +* Do not edit the class manually. +*/ +package com.web5.models + + +/** + * + * @param manifest + */ +data class PresentationDefinitionIssuance( + val manifest: kotlin.String? = null +) + diff --git a/sdks/web5-kt/src/main/kotlin/com/web5/models/PresentationDefinitionStatus.kt b/sdks/web5-kt/src/main/kotlin/com/web5/models/PresentationDefinitionStatus.kt new file mode 100644 index 0000000..7415ee4 --- /dev/null +++ b/sdks/web5-kt/src/main/kotlin/com/web5/models/PresentationDefinitionStatus.kt @@ -0,0 +1,33 @@ +/** +* web5 SDK test server +* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) +* +* The version of the OpenAPI document: 0.2.0 +* +* +* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). +* https://openapi-generator.tech +* Do not edit the class manually. +*/ + +package com.web5.models + +/** + * + * @param directive + */ +data class PresentationDefinitionStatus( + val directive: PresentationDefinitionStatus.Directive? = null +) +{ + /** + * + * Values: required,allowed,disallowed + */ + enum class Directive(val value: kotlin.String){ + required("required"), + allowed("allowed"), + disallowed("disallowed"); + } +} + diff --git a/sdks/web5-kt/src/main/kotlin/com/web5/models/PresentationDefinitionStatuses.kt b/sdks/web5-kt/src/main/kotlin/com/web5/models/PresentationDefinitionStatuses.kt new file mode 100644 index 0000000..72a4988 --- /dev/null +++ b/sdks/web5-kt/src/main/kotlin/com/web5/models/PresentationDefinitionStatuses.kt @@ -0,0 +1,25 @@ +/** +* web5 SDK test server +* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) +* +* The version of the OpenAPI document: 0.2.0 +* +* +* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). +* https://openapi-generator.tech +* Do not edit the class manually. +*/ +package com.web5.models + +/** + * + * @param active + * @param suspended + * @param revoked + */ +data class PresentationDefinitionStatuses( + val active: PresentationDefinitionStatus? = null, + val suspended: PresentationDefinitionStatus? = null, + val revoked: PresentationDefinitionStatus? = null +) + diff --git a/sdks/web5-kt/src/main/kotlin/com/web5/models/PresentationDefinitionSubmissionRequirement.kt b/sdks/web5-kt/src/main/kotlin/com/web5/models/PresentationDefinitionSubmissionRequirement.kt new file mode 100644 index 0000000..c807fc1 --- /dev/null +++ b/sdks/web5-kt/src/main/kotlin/com/web5/models/PresentationDefinitionSubmissionRequirement.kt @@ -0,0 +1,46 @@ +/** +* web5 SDK test server +* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) +* +* The version of the OpenAPI document: 0.2.0 +* +* +* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). +* https://openapi-generator.tech +* Do not edit the class manually. +*/ +package com.web5.models + + +/** + * + * @param rule + * @param name + * @param purpose + * @param count + * @param min + * @param max + * @param from + * @param fromNested + */ +data class PresentationDefinitionSubmissionRequirement( + val rule: PresentationDefinitionSubmissionRequirement.Rule, + val name: kotlin.String? = null, + val purpose: kotlin.String? = null, + val count: java.math.BigDecimal? = null, + val min: java.math.BigDecimal? = null, + val max: java.math.BigDecimal? = null, + val from: kotlin.String? = null, + val fromNested: kotlin.collections.List? = null +) +{ + /** + * + * Values: all,pick + */ + enum class Rule(val value: kotlin.String){ + all("all"), + pick("pick"); + } +} + diff --git a/sdks/web5-kt/src/main/kotlin/com/web5/models/PresentationExchangeRequest.kt b/sdks/web5-kt/src/main/kotlin/com/web5/models/PresentationExchangeRequest.kt new file mode 100644 index 0000000..c819466 --- /dev/null +++ b/sdks/web5-kt/src/main/kotlin/com/web5/models/PresentationExchangeRequest.kt @@ -0,0 +1,23 @@ +/** +* web5 SDK test server +* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) +* +* The version of the OpenAPI document: 0.2.0 +* +* +* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). +* https://openapi-generator.tech +* Do not edit the class manually. +*/ +package com.web5.models + +/** + * + * @param presentationDefinition + * @param vcJwts + */ +data class PresentationExchangeRequest( + val presentationDefinition: PresentationDefinition? = null, + val vcJwts: kotlin.collections.List? = null +) + diff --git a/sdks/web5-kt/src/main/kotlin/com/web5/models/StringEncodedData.kt b/sdks/web5-kt/src/main/kotlin/com/web5/models/StringEncodedData.kt index 3234f29..3e057a8 100644 --- a/sdks/web5-kt/src/main/kotlin/com/web5/models/StringEncodedData.kt +++ b/sdks/web5-kt/src/main/kotlin/com/web5/models/StringEncodedData.kt @@ -9,7 +9,7 @@ * https://openapi-generator.tech * Do not edit the class manually. */ -package models +package com.web5.models /** diff --git a/sdks/web5-kt/src/main/kotlin/com/web5/models/TestServerID.kt b/sdks/web5-kt/src/main/kotlin/com/web5/models/TestServerID.kt index 9656a4b..0ba38e8 100644 --- a/sdks/web5-kt/src/main/kotlin/com/web5/models/TestServerID.kt +++ b/sdks/web5-kt/src/main/kotlin/com/web5/models/TestServerID.kt @@ -9,7 +9,7 @@ * https://openapi-generator.tech * Do not edit the class manually. */ -package models +package com.web5.models /** diff --git a/sdks/web5-kt/src/main/kotlin/com/web5/models/VerifiableCredential.kt b/sdks/web5-kt/src/main/kotlin/com/web5/models/VerifiableCredential.kt index 8975118..5ee72fe 100644 --- a/sdks/web5-kt/src/main/kotlin/com/web5/models/VerifiableCredential.kt +++ b/sdks/web5-kt/src/main/kotlin/com/web5/models/VerifiableCredential.kt @@ -9,11 +9,14 @@ * https://openapi-generator.tech * Do not edit the class manually. */ -package models +package com.web5.models + +import com.fasterxml.jackson.annotation.JsonProperty + /** * - * @param atContext + * @param @Context * @param id * @param type * @param issuer @@ -23,7 +26,8 @@ package models * @param proof */ data class VerifiableCredential( - val atContext: kotlin.collections.List, + @JsonProperty("@context") + val `@context`: List, val id: kotlin.String, val type: kotlin.collections.List, val issuer: CredentialIssuer, diff --git a/sdks/web5-kt/src/main/kotlin/com/web5/plugins/routes/IssueCred.kt b/sdks/web5-kt/src/main/kotlin/com/web5/plugins/routes/IssueCred.kt index 9f20450..ace3bc5 100644 --- a/sdks/web5-kt/src/main/kotlin/com/web5/plugins/routes/IssueCred.kt +++ b/sdks/web5-kt/src/main/kotlin/com/web5/plugins/routes/IssueCred.kt @@ -1,33 +1,43 @@ package com.web5.plugins.routes +import com.danubetech.verifiablecredentials.CredentialSubject +import com.web5.models.CredentialIssuanceRequest +import com.web5.models.CredentialIssuanceResponse +import com.web5.models.StringEncodedData import io.ktor.http.* import io.ktor.server.application.* import io.ktor.server.request.* import io.ktor.server.response.* -import models.CredentialIssuanceRequestCredential -import models.CredentialIssuanceResponse -import models.StringEncodedData +import web5.sdk.credentials.VcDataModel import web5.sdk.credentials.VerifiableCredential import web5.sdk.crypto.InMemoryKeyManager import web5.sdk.dids.DidKey +import java.net.URI +import java.util.* suspend fun ApplicationCall.credentialIssue() { - val payload = receive() + val payload = receive() + val reqVc = payload.credential val keyManager = InMemoryKeyManager() val issuerDid = DidKey.create(keyManager) - val vc = VerifiableCredential.create( - type = payload.type[1], - issuer = payload.issuer.id, - subject = payload.credentialSubject.get("id").toString(), - data = payload.credentialSubject - ) + val credentialSubject = CredentialSubject.builder() + .id(URI.create(reqVc.credentialSubject.get("id").toString())) + .claims(reqVc.credentialSubject) + .build() - println(vc) + val vcDataModel = VcDataModel.builder() + .id(URI.create(reqVc.id)) + .issuer(URI.create(reqVc.issuer.id)) + .issuanceDate(Date()) + .credentialSubject(credentialSubject) + .build() + + val vc = VerifiableCredential(vcDataModel) val vcJwt = vc.sign(issuerDid) - val res = CredentialIssuanceResponse(verifiableCredential = StringEncodedData(vcJwt)) + val res = CredentialIssuanceResponse(verifiableCredential = StringEncodedData(data = vcJwt)) respond(HttpStatusCode.OK, res) } \ No newline at end of file diff --git a/sdks/web5-kt/src/main/resources/logback.xml b/sdks/web5-kt/src/main/resources/logback.xml index 3e11d78..aadef5d 100644 --- a/sdks/web5-kt/src/main/resources/logback.xml +++ b/sdks/web5-kt/src/main/resources/logback.xml @@ -4,7 +4,7 @@ %d{YYYY-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - + diff --git a/sdks/web5-kt/Dockerfile b/sdks/web5-kt/web5-spec.Dockerfile similarity index 92% rename from sdks/web5-kt/Dockerfile rename to sdks/web5-kt/web5-spec.Dockerfile index db49b53..41e5437 100644 --- a/sdks/web5-kt/Dockerfile +++ b/sdks/web5-kt/web5-spec.Dockerfile @@ -1,5 +1,4 @@ # Use an ARM64 compatible OpenJDK image -#FROM arm64v8/adoptopenjdk FROM openjdk:17-jdk # Set the working directory to /app diff --git a/tests/credentials.go b/tests/credentials.go index 05c7a09..a299509 100644 --- a/tests/credentials.go +++ b/tests/credentials.go @@ -3,6 +3,7 @@ package tests import ( "context" "encoding/json" + "fmt" "log" "github.com/TBD54566975/web5-spec/openapi" @@ -28,7 +29,7 @@ type Payload struct { func vcCreate(ctx context.Context, serverURL string) []error { expectedContext := []string{"https://www.w3.org/2018/credentials/v1"} expectedType := []string{"VerifiableCredential"} - expectedID := "id-123" + expectedID := "did:example:321" expectedIssuer := "did:example:123" expectedCredentialSubjectId := "did:example:123" @@ -95,7 +96,7 @@ func vcCreate(ctx context.Context, serverURL string) []error { } // Check id - if err := compareStrings(payload.Vc.Id, expectedID, "id"); err != nil { + if err := compareStringsContains(payload.Vc.Id, "did:", "id"); err != nil { errs = append(errs, err) } @@ -105,8 +106,21 @@ func vcCreate(ctx context.Context, serverURL string) []error { } // Check issuer - if err := compareStrings(payload.Vc.Issuer.Id, expectedIssuer, "issuer.id"); err != nil { - errs = append(errs, err) + //if err := compareStrings(payload.Vc.Issuer.Id, expectedIssuer, "issuer.id"); err != nil { + // errs = append(errs, err) + //} + + switch issuer := payload.Vc.Issuer.(type) { + case string: + if err := compareStrings(issuer, expectedIssuer, "issuer"); err != nil { + errs = append(errs, err) + } + case openapi.CredentialIssuer: + if err := compareStrings(issuer.Id, expectedIssuer, "issuer.id"); err != nil { + errs = append(errs, err) + } + default: + errs = append(errs, fmt.Errorf("Unexpected type for Issuer")) } return errs