repo_name
stringlengths
1
62
dataset
stringclasses
1 value
lang
stringclasses
11 values
pr_id
int64
1
20.1k
owner
stringlengths
2
34
reviewer
stringlengths
2
39
diff_hunk
stringlengths
15
262k
code_review_comment
stringlengths
1
99.6k
waltid-identity
github_2023
others
634
walt-id
mikeplotean
@@ -119,13 +124,39 @@ object IssuanceService { logger.debug { "Using issuer URL: ${credentialOffer.credentialIssuer}" } val credReqs = offeredCredentials.map { offeredCredential -> + println("Offered credential format: ${offeredCredential.format.name}")
please use the `logger`
waltid-identity
github_2023
others
634
walt-id
mikeplotean
@@ -119,13 +124,39 @@ object IssuanceService { logger.debug { "Using issuer URL: ${credentialOffer.credentialIssuer}" } val credReqs = offeredCredentials.map { offeredCredential -> + println("Offered credential format: ${offeredCredential.format.name}") + println("Offered crede...
perhaps this can be extracted to a separate entity, e.g. ```kotlin import COSE.OneKey import com.nimbusds.jose.jwk.ECKey import id.walt.did.dids.DidService import id.walt.oid4vc.data.CredentialOffer import id.walt.oid4vc.data.OfferedCredential import id.walt.oid4vc.data.ProofOfPossession import id.walt.oid4vc.d...
waltid-identity
github_2023
others
634
walt-id
mikeplotean
@@ -140,7 +171,7 @@ object IssuanceService { contentType(ContentType.Application.Json)
not part of the pr change, but still.. this return could be refactored in a similar way as above, e.g. ```kotlin import id.walt.oid4vc.data.OpenIDProviderMetadata import id.walt.oid4vc.requests.BatchCredentialRequest import id.walt.oid4vc.requests.CredentialRequest import id.walt.oid4vc.responses.BatchCredentialR...
waltid-identity
github_2023
others
634
walt-id
mikeplotean
@@ -198,16 +202,32 @@ class SSIKit2WalletService( logger.debug { "Resolved presentation definition: ${presentationSession.authorizationRequest!!.presentationDefinition!!.toJSONString()}" } val tokenResponse = credentialWallet.processImplicitFlowAuthorization(presentationSession.authorizationRequest!...
this could be extracted into 2 methods, e.g. ```kotlin private fun getFormParameters( authorizationRequest: AuthorizationRequest, tokenResponse: TokenResponse, presentationSession: VPresentationSession ) = if (authorizationRequest.responseMode == ResponseMode.direct_post_jwt) { directPostJwtParam...
waltid-identity
github_2023
others
634
walt-id
mikeplotean
@@ -0,0 +1,189 @@ +package id.walt.verifier.lspPotential + +import COSE.AlgorithmID +import COSE.OneKey +import cbor.Cbor +import com.nimbusds.jose.JWSAlgorithm +import com.nimbusds.jose.crypto.ECDSASigner +import com.nimbusds.jose.crypto.ECDSAVerifier +import com.nimbusds.jose.jwk.Curve +import com.nimbusds.jose.jwk.E...
ide suggests it could be private, is it going to be used externally?
waltid-identity
github_2023
others
634
walt-id
mikeplotean
@@ -0,0 +1,189 @@ +package id.walt.verifier.lspPotential + +import COSE.AlgorithmID +import COSE.OneKey +import cbor.Cbor +import com.nimbusds.jose.JWSAlgorithm +import com.nimbusds.jose.crypto.ECDSASigner +import com.nimbusds.jose.crypto.ECDSAVerifier +import com.nimbusds.jose.jwk.Curve +import com.nimbusds.jose.jwk.E...
same as readKeySpec
waltid-identity
github_2023
others
634
walt-id
mikeplotean
@@ -0,0 +1,189 @@ +package id.walt.verifier.lspPotential + +import COSE.AlgorithmID +import COSE.OneKey +import cbor.Cbor +import com.nimbusds.jose.JWSAlgorithm +import com.nimbusds.jose.crypto.ECDSASigner +import com.nimbusds.jose.crypto.ECDSAVerifier +import com.nimbusds.jose.jwk.Curve +import com.nimbusds.jose.jwk.E...
noticed this in several places, ide mentions it as a duplicate could it be instantiated once and have that instance referenced by all these places?
waltid-identity
github_2023
others
634
walt-id
mikeplotean
@@ -0,0 +1,125 @@ +package id.walt + +import COSE.AlgorithmID +import COSE.OneKey +import cbor.Cbor +import com.nimbusds.jose.jwk.ECKey +import com.nimbusds.jose.jwk.JWK +import com.nimbusds.jose.util.X509CertUtils +import com.upokecenter.cbor.CBORObject +import id.walt.commons.config.ConfigManager +import id.walt.comm...
is this assert still relevant?
waltid-identity
github_2023
others
634
walt-id
mikeplotean
@@ -0,0 +1,125 @@ +package id.walt + +import COSE.AlgorithmID +import COSE.OneKey +import cbor.Cbor +import com.nimbusds.jose.jwk.ECKey +import com.nimbusds.jose.jwk.JWK +import com.nimbusds.jose.util.X509CertUtils +import com.upokecenter.cbor.CBORObject +import id.walt.commons.config.ConfigManager +import id.walt.comm...
maybe this could be cleaned up?
waltid-identity
github_2023
others
634
walt-id
mikeplotean
@@ -0,0 +1,125 @@ +package id.walt + +import COSE.AlgorithmID +import COSE.OneKey +import cbor.Cbor +import com.nimbusds.jose.jwk.ECKey +import com.nimbusds.jose.jwk.JWK +import com.nimbusds.jose.util.X509CertUtils +import com.upokecenter.cbor.CBORObject +import id.walt.commons.config.ConfigManager +import id.walt.comm...
ide suggests to use `assertEquals`
waltid-identity
github_2023
others
634
walt-id
mikeplotean
@@ -0,0 +1,124 @@ +package id.walt.issuer.lspPotential + +import COSE.AlgorithmID +import com.nimbusds.jose.JWSAlgorithm +import com.nimbusds.jose.crypto.ECDSASigner +import com.nimbusds.jose.crypto.ECDSAVerifier +import com.nimbusds.jose.jwk.ECKey +import id.walt.credentials.vc.vcs.W3CVC +import id.walt.crypto.keys.Ke...
ide mentions duplicated code (similar line:106)
waltid-identity
github_2023
others
634
walt-id
mikeplotean
@@ -0,0 +1,124 @@ +package id.walt.issuer.lspPotential + +import COSE.AlgorithmID +import com.nimbusds.jose.JWSAlgorithm +import com.nimbusds.jose.crypto.ECDSASigner +import com.nimbusds.jose.crypto.ECDSAVerifier +import com.nimbusds.jose.jwk.ECKey +import id.walt.credentials.vc.vcs.W3CVC +import id.walt.crypto.keys.Ke...
as for the verifier, could this be private?
waltid-identity
github_2023
others
634
walt-id
mikeplotean
@@ -0,0 +1,124 @@ +package id.walt.issuer.lspPotential + +import COSE.AlgorithmID +import com.nimbusds.jose.JWSAlgorithm +import com.nimbusds.jose.crypto.ECDSASigner +import com.nimbusds.jose.crypto.ECDSAVerifier +import com.nimbusds.jose.jwk.ECKey +import id.walt.credentials.vc.vcs.W3CVC +import id.walt.crypto.keys.Ke...
and this one, couldn't it also be private?
waltid-identity
github_2023
others
634
walt-id
mikeplotean
@@ -57,6 +60,15 @@ object OidcApi : CIProvider() { get("/.well-known/openid-credential-issuer") { call.respond(metadata.toJSON()) } + get("/.well-known/oauth-authorization-server") { + call.respond(metadata.toJSON()) + } + get("/...
this endpoint appears twice, is it intended?
waltid-identity
github_2023
others
634
walt-id
mikeplotean
@@ -394,6 +403,40 @@ fun Application.issuerApi() { ?: throw BadRequestException("Session has no credential offer set") context.respond(credentialOffer.toJSON()) } + get("lspPotentialCredentialOffer") { + val jwkKey = JWKKey...
noticed this duplicated in tests, maybe it could be instantiated in a single location and referenced from there?
waltid-identity
github_2023
others
634
walt-id
mikeplotean
@@ -12,9 +12,18 @@ data class IssuanceRequest( val issuerDid: String, val credentialConfigurationId: String, - val credentialData: W3CVC, + val credentialData: W3CVC?, + val mdocData: Map<String, JsonObject>?, val mapping: JsonObject? = null, val selectiveDisclosure: SDMap? = null, + v...
doesn't look like it's being used anywhere, is it?
waltid-identity
github_2023
others
634
walt-id
mikeplotean
@@ -247,6 +256,43 @@ object IssuanceExamples { openBadgeCredentialIssuance ) +// val mDLIssuanceExample = typedValueExampleDescriptorDsl<IssuanceRequest>(IssuanceRequest( +// Json.parseToJsonElement(KeySerialization.serializeKey( runBlocking { +// JWKKey.importJWK(LspPotentialIssuan...
this seems duplicated in multiple locations (e.g. tests), maybe an instance of it can be created and referenced everywhere
waltid-identity
github_2023
others
634
walt-id
mikeplotean
@@ -247,33 +302,111 @@ open class CIProvider : OpenIDCredentialIssuer( issuerKid = issuerDid + "#" + issuerKey.getKeyId() when (credentialRequest.format) { - CredentialFormat.sd_jwt_vc -> vc.mergingSdJwtIssue( - issuerKey = issuerKey, - ...
maybe can be cleaned up
waltid-identity
github_2023
others
634
walt-id
mikeplotean
@@ -132,22 +168,53 @@ open class CIProvider : OpenIDCredentialIssuer( } } + override fun signCWTToken( + target: TokenTarget, + payload: MapElement, + header: MapElement?, + keyId: String?, + privKey: Key? + ): String { + TODO("Not yet implemented"...
maybe can be cleaned up
waltid-identity
github_2023
others
634
walt-id
mikeplotean
@@ -48,16 +68,32 @@ open class CIProvider : OpenIDCredentialIssuer( baseUrl = let { ConfigManager.getConfig<OIDCIssuerServiceConfig>().baseUrl }, config = CredentialIssuerConfig(credentialConfigurationsSupported = supportedCredentialTypes.flatMap { entry -> - CredentialFormat.entries.map { for...
ide suggests to replace values with entries
waltid-identity
github_2023
others
634
walt-id
mikeplotean
@@ -247,33 +302,111 @@ open class CIProvider : OpenIDCredentialIssuer( issuerKid = issuerDid + "#" + issuerKey.getKeyId() when (credentialRequest.format) { - CredentialFormat.sd_jwt_vc -> vc.mergingSdJwtIssue( - issuerKey = issuerKey, - ...
maybe the cases could be extracted into separate private methods, e.g. ```kotlin private suspend fun IssuanceSessionData.sdJwtVc( holderKey: JsonObject?, vc: W3CVC, data: IssuanceSessionData, holderDid: String? ) = (holderKey?.let { SDJwtVC.sign(SDPayload.createSDPayload(vc.toJsonObject(), b...
waltid-identity
github_2023
others
634
walt-id
mikeplotean
@@ -236,7 +291,7 @@ open class CIProvider : OpenIDCredentialIssuer( }).first() return CredentialResult(format = credentialRequest.format, credential = JsonPrimitive(runBlocking { - val vc = data.request.credentialData + val vc = data.request.credentialData ?: throw MissingField...
ide mentions `missing-field-exception` requires `@kotlinx.serialization.ExperimentalSerializationApi`
waltid-identity
github_2023
others
634
walt-id
mikeplotean
@@ -132,22 +168,53 @@ open class CIProvider : OpenIDCredentialIssuer( } } + override fun signCWTToken( + target: TokenTarget, + payload: MapElement, + header: MapElement?, + keyId: String?, + privKey: Key? + ): String { + TODO("Not yet implemented"...
ide mentions Cbor needs optin for `@kotlinx.serialization.ExperimentalSerializationApi`
waltid-identity
github_2023
others
634
walt-id
mikeplotean
@@ -0,0 +1,204 @@ +import id.walt.credentials.vc.vcs.W3CVC +import id.walt.crypto.keys.KeyGenerationRequest +import id.walt.crypto.keys.KeySerialization +import id.walt.crypto.keys.KeyType +import id.walt.crypto.keys.jwk.JWKKey +import id.walt.crypto.utils.JsonUtils.toJsonElement +import id.walt.issuer.issuance.Issuanc...
ide suggests this `let` is redundant here
waltid-identity
github_2023
others
634
walt-id
mikeplotean
@@ -0,0 +1,384 @@ +import COSE.AlgorithmID +import COSE.OneKey +import cbor.Cbor +import com.nimbusds.jose.JWSAlgorithm +import com.nimbusds.jose.crypto.ECDSASigner +import com.nimbusds.jose.crypto.ECDSAVerifier +import com.nimbusds.jose.jwk.ECKey +import id.walt.crypto.keys.KeyGenerationRequest +import id.walt.crypto....
ide suggests optin for `@kotlinx.serialization.ExperimentalSerializationApi` is required
waltid-identity
github_2023
others
634
walt-id
mikeplotean
@@ -0,0 +1,384 @@ +import COSE.AlgorithmID +import COSE.OneKey +import cbor.Cbor +import com.nimbusds.jose.JWSAlgorithm +import com.nimbusds.jose.crypto.ECDSASigner +import com.nimbusds.jose.crypto.ECDSAVerifier +import com.nimbusds.jose.jwk.ECKey +import id.walt.crypto.keys.KeyGenerationRequest +import id.walt.crypto....
maybe could be private?
waltid-identity
github_2023
others
634
walt-id
mikeplotean
@@ -0,0 +1,384 @@ +import COSE.AlgorithmID +import COSE.OneKey +import cbor.Cbor +import com.nimbusds.jose.JWSAlgorithm +import com.nimbusds.jose.crypto.ECDSASigner +import com.nimbusds.jose.crypto.ECDSAVerifier +import com.nimbusds.jose.jwk.ECKey +import id.walt.crypto.keys.KeyGenerationRequest +import id.walt.crypto....
this one as well
waltid-identity
github_2023
others
634
walt-id
mikeplotean
@@ -380,10 +382,99 @@ class E2ETest { assert(history.any { it.operation == "useOfferRequest" } && history.any { it.operation == "usePresentationRequest" }) { "incorrect history items" } } } + + val lspPotentialIssuance = LspPotentialIssuance(testHttpClient(d...
redundant `let` here
waltid-identity
github_2023
others
634
walt-id
mikeplotean
@@ -21,75 +22,79 @@ private val log = KotlinLogging.logger { } @JsExport class JwsSignatureScheme : SignatureScheme { - object JwsHeader { - const val KEY_ID = "kid" - } + object JwsHeader { + const val KEY_ID = "kid" + } - object JwsOption { - const val SUBJECT = "sub" - const ...
maybe this could be extracted in a separate method, e.g. ```kotlin private suspend fun verifyW3C(issuerDid: String, data: String): JsonElement { log.trace { "Verifying with issuer did: $issuerDid" } return DidService.resolveToKey(issuerDid) .also { if (log.isTraceEnabled()) { va...
waltid-identity
github_2023
others
634
walt-id
mikeplotean
@@ -0,0 +1,23 @@ +package id.walt.sdjwt
this file could use some formatting
waltid-identity
github_2023
others
634
walt-id
mikeplotean
@@ -21,3 +21,16 @@ data class VerificationResult<T : SDJwt>( val verified get() = signatureVerified && disclosuresVerified } + +class VCVerificationResult( + val sdJwtVC: SDJwtVC, + val sdJwtVerificationResult: VerificationResult<SDJwt>,
ide suggests all but sdJwtVC could be private, is it the case?
waltid-identity
github_2023
others
634
walt-id
mikeplotean
@@ -0,0 +1,115 @@ +package id.walt.sdjwt +import kotlinx.datetime.Clock +import kotlinx.serialization.json.* + +class SDJwtVC(sdJwt: SDJwt): SDJwt(sdJwt.jwt, sdJwt.header, sdJwt.sdPayload, sdJwt.keyBindingJwt, sdJwt.isPresentation) { + + val cnfObject: JsonObject? = undisclosedPayload["cnf"]?.jsonObject + val holderD...
could be private, as the class is not inheritable
waltid-identity
github_2023
others
634
walt-id
mikeplotean
@@ -0,0 +1,115 @@ +package id.walt.sdjwt +import kotlinx.datetime.Clock +import kotlinx.serialization.json.* + +class SDJwtVC(sdJwt: SDJwt): SDJwt(sdJwt.jwt, sdJwt.header, sdJwt.sdPayload, sdJwt.keyBindingJwt, sdJwt.isPresentation) { + + val cnfObject: JsonObject? = undisclosedPayload["cnf"]?.jsonObject + val holderD...
a method parameter with similar name already exists and being shadowed by this, is it intended?
waltid-identity
github_2023
others
634
walt-id
mikeplotean
@@ -103,9 +103,11 @@ kotlin { val commonMain by getting { dependencies { + //implementation(project(":waltid-crypto"))
should it be removed from common?
waltid-identity
github_2023
others
634
walt-id
mikeplotean
@@ -34,7 +44,7 @@ abstract class OpenIDCredentialIssuer( ) private var _supportedCredentialFormats: Set<CredentialFormat>? = null val supportedCredentialFormats
ide suggests `supportedCredentialFormats` could be private, is it the case?
waltid-identity
github_2023
others
634
walt-id
mikeplotean
@@ -51,7 +51,7 @@ object ConfigManager { .addDecoder(JsonElementDecoder()) .addCommandLineSource(args) .addDefaultParsers() - .addEnvironmentSource() + .addEnvironmentSource(allowUppercaseNames = false)
would this need to be mentioned in the docs?
waltid-identity
github_2023
others
634
walt-id
mikeplotean
@@ -75,3 +76,28 @@ plugins { } rootProject.name = "waltid-identity" +include(
I think this needs to be rebased
waltid-identity
github_2023
others
634
walt-id
mikeplotean
@@ -247,33 +299,72 @@ open class CIProvider : OpenIDCredentialIssuer( issuerKid = issuerDid + "#" + issuerKey.getKeyId() when (credentialRequest.format) { - CredentialFormat.sd_jwt_vc -> vc.mergingSdJwtIssue( - issuerKey = issuerKey, - ...
this one also requires optin for `@kotlinx.serialization.ExperimentalSerializationApi`
waltid-identity
github_2023
others
634
walt-id
mikeplotean
@@ -0,0 +1,91 @@ +package id.walt + +import COSE.AlgorithmID +import COSE.OneKey +import cbor.Cbor +import com.nimbusds.jose.jwk.JWK +import com.upokecenter.cbor.CBORObject +import id.walt.crypto.utils.Base64Utils.base64UrlDecode +import id.walt.did.dids.DidService +import id.walt.mdoc.COSECryptoProviderKeyInfo +import...
ide mentions this condition is always true, I guess there will be an exception thrown if decoding fails, will there not?
waltid-identity
github_2023
others
634
walt-id
mikeplotean
@@ -224,20 +204,34 @@ object IssuanceService { } private suspend fun getCredentialData( - credentialResp: CredentialResponse, manifest: JsonObject?, + processedOffer: ProcessedCredentialOffer, manifest: JsonObject?, ) = let { - val credential = credentialResp.credential!!.jsonPrimi...
ide suggests Cbor needs optin for `@kotlinx.serialization.ExperimentalSerializationApi`
waltid-identity
github_2023
others
634
walt-id
mikeplotean
@@ -68,29 +86,37 @@ class TestCredentialWallet( } } - override fun signToken(target: TokenTarget, payload: JsonObject, header: JsonObject?, keyId: String?, privKey: Key?): String { + override fun signToken(target: TokenTarget, payload: JsonObject, header: JsonObject?, keyId: String?, privKey: Key?...
perhaps this could be same block ```kotlin val key = privKey ?: keyId?.let { tryResolveKeyId(it) } ?: throw IllegalArgumentException("No key given or found for given keyId ${debugStateMsg()}") ```
waltid-identity
github_2023
others
634
walt-id
mikeplotean
@@ -68,29 +86,37 @@ class TestCredentialWallet( } } - override fun signToken(target: TokenTarget, payload: JsonObject, header: JsonObject?, keyId: String?, privKey: Key?): String { + override fun signToken(target: TokenTarget, payload: JsonObject, header: JsonObject?, keyId: String?, privKey: Key?...
here as well, ```kotlin val key = privKey ?: keyId?.let { tryResolveKeyId(it) } ?: throw IllegalArgumentException("No key given or found for given keyId ${debugStateMsg()}") ```
waltid-identity
github_2023
others
634
walt-id
mikeplotean
@@ -148,84 +176,101 @@ class TestCredentialWallet( println("Matched credentials: $matchedCredentials") println("Using disclosures: $selectedDisclosures") + val key = runBlocking { + runCatching { + DidService.resolveToKey(did).getOrThrow().let { KeysService.get(it.ge...
nitpicking alert: ide suggests `isNullOrEmpty` could be reduced to `isNotEmpty`
waltid-identity
github_2023
others
634
walt-id
mikeplotean
@@ -148,84 +176,101 @@ class TestCredentialWallet( println("Matched credentials: $matchedCredentials") println("Using disclosures: $selectedDisclosures") + val key = runBlocking { + runCatching { + DidService.resolveToKey(did).getOrThrow().let { KeysService.get(it.ge...
same here
waltid-identity
github_2023
others
634
walt-id
mikeplotean
@@ -0,0 +1,222 @@ +import COSE.AlgorithmID +import com.nimbusds.jose.JWSAlgorithm +import com.nimbusds.jose.crypto.ECDSASigner +import com.nimbusds.jose.crypto.ECDSAVerifier +import com.nimbusds.jose.jwk.ECKey +import com.nimbusds.jose.jwk.JWK +import com.nimbusds.jose.jwk.KeyUse +import com.nimbusds.jose.util.Base64UR...
seems not used anywhere
waltid-identity
github_2023
others
634
walt-id
mikeplotean
@@ -631,4 +662,49 @@ object IssuanceExamples { } """.trimIndent() ) + + // language=json + val sdjwt_vc_identity_credential = """
ide suggests `sdjwt_vc_identity_credential` could be private
waltid-identity
github_2023
others
597
walt-id
mikeplotean
@@ -24,47 +24,95 @@ object AccountsService { private val defaultGenerationConfig by lazy { ConfigManager.getConfig<RegistrationDefaultsConfig>() } - suspend fun register(tenant: String = "", request: AccountRequest): Result<RegistrationResult> = when (request) { - is EmailAccountRequest -> EmailAccou...
maybe `runCatching` would be a better option here (with some refactoring)? e.g. refactor register method ```kotlin suspend fun register(tenant: String = "", request: AccountRequest): Result<RegistrationResult> = runCatching { when (request) { is EmailAccountRequest -> EmailAccountStrategy.register(tena...
waltid-identity
github_2023
others
597
walt-id
mikeplotean
@@ -17,9 +17,10 @@ import org.jetbrains.exposed.sql.transactions.transaction object EmailAccountStrategy : PasswordAccountStrategy<EmailAccountRequest>() { override suspend fun register(tenant: String, request: EmailAccountRequest): Result<RegistrationResult> = runCatching { - val name = request.name ?: ...
I would probably try do it by introducing a `RequestValidator` interface with implementations according to the strategies which I'd inject through constructor, but this means the `EmailAccountStrategy` would also become a class (which will trigger more refactoring), but it depends on how much time it is desired to put ...
waltid-identity
github_2023
others
597
walt-id
mikeplotean
@@ -121,9 +121,12 @@ fun Application.keys() = walletRoute { } }) { val body = call.receiveText() - getWalletService().importKey(body) + val key = getWalletService().importKey(body) - context.respond(HttpStatusCode.OK) + context.respond( + ...
the original post asked to have the `keyId` in the response body, I think the additional message is not required
waltid-identity
github_2023
others
597
walt-id
mikeplotean
@@ -454,6 +454,7 @@ class SSIKit2WalletService( val key = keyResult.getOrThrow() val keyId = key.getKeyId() + require(KeysService.get(walletId, keyId) === null) { "Key with ID $keyId already exists in the database" }
I think referential equality is a little overkill when comparing with null, the [regular comparison](https://kotlinlang.org/docs/equality.html#structural-equality) would also work here another way to do it can be: ```kotlin KeysService.get(walletId, keyId) ?.let { throw IllegalArgumentException("Key wit...
waltid-identity
github_2023
others
597
walt-id
mikeplotean
@@ -49,9 +49,18 @@ object DidCreation { } } }) { - getWalletService().createDid( - DidWebMethodName, extractDidCreateParameters(DidWebMethodName, context.request.queryParameters) - ).let { context.respond(it) } + val parameters = ext...
probably could have `it.message` here
waltid-identity
github_2023
others
597
walt-id
mikeplotean
@@ -295,15 +295,30 @@ fun Application.auth() { response { HttpStatusCode.Created to { description = "Registration succeeded " } HttpStatusCode.BadRequest to { description = "Registration failed" } + HttpStatusCode.Conflict to ...
comparing against the error message to compute the error status doesn't feel right maybe we can have a dedicated type for application logic errors e.g. have an entity representing an `Error`: ```kotlin abstract class Error( val code: String, override val message: String, ) : Throwable() ``` and then de...
waltid-identity
github_2023
others
597
walt-id
mikeplotean
@@ -49,9 +49,18 @@ object DidCreation { } } }) { - getWalletService().createDid( - DidWebMethodName, extractDidCreateParameters(DidWebMethodName, context.request.queryParameters) - ).let { context.respond(it) } + val parameters = ext...
maybe also display the error (not just internal server error) if so, the whole failure block could be simplified, e.g. ```kotlin val status = if (it.message.contains("DID already exists") == true) { HttpStatusCode.Conflict } else { HttpStatusCode.InternalServerError } context.respond(status, it.message?...
waltid-identity
github_2023
others
597
walt-id
mikeplotean
@@ -49,9 +50,26 @@ object DidCreation { } } }) { - getWalletService().createDid( - DidWebMethodName, extractDidCreateParameters(DidWebMethodName, context.request.queryParameters) - ).let { context.respond(it) } + val parameters = ext...
I think this is not required anymore (catching the exception in controller), since there is a type - ConflictException - for it in service-commons WebExceptions that is thrown by the did-service, so status-pages should be able to display it
waltid-identity
github_2023
others
597
walt-id
waltkb
@@ -121,9 +121,12 @@ fun Application.keys() = walletRoute { } }) { val body = call.receiveText() - getWalletService().importKey(body) - - context.respond(HttpStatusCode.OK) + val key = getWalletService().importKey(body) + context.response.he...
Redirects in REST API are oftentimes problematic (API clients try to follow them etc)
waltid-identity
github_2023
others
597
walt-id
waltkb
@@ -454,6 +454,9 @@ class SSIKit2WalletService( val key = keyResult.getOrThrow() val keyId = key.getKeyId() + KeysService.get(walletId, keyId) + ?.let { throw IllegalArgumentException("Key with ID $keyId already exists in the database") }
Shouldn't this return Conflict?
waltid-identity
github_2023
others
597
walt-id
waltkb
@@ -17,9 +17,10 @@ import org.jetbrains.exposed.sql.transactions.transaction object EmailAccountStrategy : PasswordAccountStrategy<EmailAccountRequest>() { override suspend fun register(tenant: String, request: EmailAccountRequest): Result<RegistrationResult> = runCatching { - val name = request.name ?: ...
Maybe Conflict exception?
waltid-identity
github_2023
others
597
walt-id
waltkb
@@ -5,3 +5,10 @@ import io.ktor.http.* open class WebException(val status: HttpStatusCode, message: String) : Exception(message) class UnauthorizedException(message: String) : WebException(HttpStatusCode.Unauthorized, message) +class ConflictException(message: String) : WebException(HttpStatusCode.Conflict, message...
ok
waltid-identity
github_2023
others
597
walt-id
waltkb
@@ -5,3 +5,10 @@ import io.ktor.http.* open class WebException(val status: HttpStatusCode, message: String) : Exception(message) class UnauthorizedException(message: String) : WebException(HttpStatusCode.Unauthorized, message) +class ConflictException(message: String) : WebException(HttpStatusCode.Conflict, message...
ok
waltid-identity
github_2023
others
597
walt-id
waltkb
@@ -5,3 +5,10 @@ import io.ktor.http.* open class WebException(val status: HttpStatusCode, message: String) : Exception(message) class UnauthorizedException(message: String) : WebException(HttpStatusCode.Unauthorized, message) +class ConflictException(message: String) : WebException(HttpStatusCode.Conflict, message...
ok
waltid-identity
github_2023
others
597
walt-id
waltkb
@@ -5,3 +5,10 @@ import io.ktor.http.* open class WebException(val status: HttpStatusCode, message: String) : Exception(message) class UnauthorizedException(message: String) : WebException(HttpStatusCode.Unauthorized, message) +class ConflictException(message: String) : WebException(HttpStatusCode.Conflict, message...
name clash on class name -> already exists as io.ktor.server.plugins.BadRequestException
waltid-identity
github_2023
others
597
walt-id
waltkb
@@ -5,3 +5,10 @@ import io.ktor.http.* open class WebException(val status: HttpStatusCode, message: String) : Exception(message) class UnauthorizedException(message: String) : WebException(HttpStatusCode.Unauthorized, message) +class ConflictException(message: String) : WebException(HttpStatusCode.Conflict, message...
name clash on class name -> already exists as kotlin.IllegalStateException and java.lang.IllegalStateException
waltid-identity
github_2023
others
597
walt-id
waltkb
@@ -5,3 +5,10 @@ import io.ktor.http.* open class WebException(val status: HttpStatusCode, message: String) : Exception(message) class UnauthorizedException(message: String) : WebException(HttpStatusCode.Unauthorized, message) +class ConflictException(message: String) : WebException(HttpStatusCode.Conflict, message...
name clash on class name -> already exists as java.lang.IllegalArgumentException and kotlin.IllegalArgumentException
waltid-identity
github_2023
others
597
walt-id
waltkb
@@ -11,7 +11,6 @@ import kotlinx.serialization.json.JsonPrimitive private fun statusCodeForException(cause: Throwable) = when (cause) { - is IllegalArgumentException -> HttpStatusCode.BadRequest
Why was this removed? This refers to kotlin.IllegalArgumentException / java.lang.IllegalArgumentException
waltid-identity
github_2023
others
597
walt-id
waltkb
@@ -436,34 +439,55 @@ class SSIKit2WalletService( }.getKeyId() } - override suspend fun importKey(jwkOrPem: String): String { - val type = - when { - jwkOrPem.lines().first().contains("BEGIN ") -> "pem" - else -> "jwk" - } + private fu...
Not sure when this found it's way in, but imo a too primitive check -> what if JWK has a kid that contains "BEGIN" because a user was funny and named it like that? More reliable would be too check for JSON prefix (`{`), as a JWK will have to be valid JSON, and a PEM file will not contain non-base64 characters. And for ...
waltid-identity
github_2023
others
597
walt-id
waltkb
@@ -436,34 +439,55 @@ class SSIKit2WalletService( }.getKeyId() } - override suspend fun importKey(jwkOrPem: String): String { - val type = - when { - jwkOrPem.lines().first().contains("BEGIN ") -> "pem" - else -> "jwk" - } + private fu...
When looking at this with this case, 406 Not Acceptable is semantically not the right choice, because this should actually just happen when an `Accept`-type header does not match (it's done pre-request processing), e.g. `Accept`, `Accept-Encoding`, `Accept-Language`, and certain HTTP clients try to be too intelligent a...
waltid-identity
github_2023
others
597
walt-id
waltkb
@@ -436,34 +439,55 @@ class SSIKit2WalletService( }.getKeyId() } - override suspend fun importKey(jwkOrPem: String): String { - val type = - when { - jwkOrPem.lines().first().contains("BEGIN ") -> "pem" - else -> "jwk" - } + private fu...
as above
waltid-identity
github_2023
others
597
walt-id
waltkb
@@ -436,34 +439,55 @@ class SSIKit2WalletService( }.getKeyId() } - override suspend fun importKey(jwkOrPem: String): String { - val type = - when { - jwkOrPem.lines().first().contains("BEGIN ") -> "pem" - else -> "jwk" - } + private fu...
this is IllegalArgumentException again?
waltid-identity
github_2023
others
597
walt-id
waltkb
@@ -436,34 +439,55 @@ class SSIKit2WalletService( }.getKeyId() } - override suspend fun importKey(jwkOrPem: String): String { - val type = - when { - jwkOrPem.lines().first().contains("BEGIN ") -> "pem" - else -> "jwk" - } + private fu...
same with the rest here
waltid-identity
github_2023
others
597
walt-id
waltkb
@@ -436,34 +439,55 @@ class SSIKit2WalletService( }.getKeyId() } - override suspend fun importKey(jwkOrPem: String): String { - val type = - when { - jwkOrPem.lines().first().contains("BEGIN ") -> "pem" - else -> "jwk" - } + private fu...
never have `throw Exception`, a base Exception or Throwable should not be created or thrown, always have it more specific
waltid-identity
github_2023
others
597
walt-id
waltkb
@@ -17,10 +18,18 @@ import org.jetbrains.exposed.sql.transactions.transaction object EmailAccountStrategy : PasswordAccountStrategy<EmailAccountRequest>() { override suspend fun register(tenant: String, request: EmailAccountRequest): Result<RegistrationResult> = runCatching { - val name = request.name ?:...
For illegal argument exceptions, you can simply use `require`
waltid-identity
github_2023
others
597
walt-id
waltkb
@@ -295,15 +295,25 @@ fun Application.auth() { response { HttpStatusCode.Created to { description = "Registration succeeded " } HttpStatusCode.BadRequest to { description = "Registration failed" } + HttpStatusCode.Conflict to ...
you can receive as JsonObject directly
waltid-identity
github_2023
others
597
walt-id
waltkb
@@ -295,15 +295,25 @@ fun Application.auth() { response { HttpStatusCode.Created to { description = "Registration succeeded " } HttpStatusCode.BadRequest to { description = "Registration failed" } + HttpStatusCode.Conflict to ...
decode from JsonObject directly (instead of String)
waltid-identity
github_2023
others
597
walt-id
waltkb
@@ -491,8 +501,34 @@ suspend fun verifyToken(token: String): Result<String> { } } +data class LoginRequestError(override val message: String) : WebException( + message = message, + status = HttpStatusCode.BadRequest +) { + constructor(throwable: Throwable) : this( + when (throwable) { + ...
receive JsonObject directly
waltid-identity
github_2023
others
597
walt-id
waltkb
@@ -491,8 +501,34 @@ suspend fun verifyToken(token: String): Result<String> { } } +data class LoginRequestError(override val message: String) : WebException( + message = message, + status = HttpStatusCode.BadRequest +) { + constructor(throwable: Throwable) : this( + when (throwable) { + ...
decode from JsonObject directly (instead of string)
waltid-identity
github_2023
others
597
walt-id
waltkb
@@ -152,7 +154,7 @@ fun Application.configureSecurity() { try { parseAuthorizationHeader(it) } catch (cause: ParseException) { - throw BadRequestException("Invalid auth header", cause) + throw BadRequestExce...
Why would you not like to leave the `cause` in?
waltid-identity
github_2023
others
597
walt-id
waltkb
@@ -11,8 +11,10 @@ import kotlinx.serialization.json.JsonPrimitive private fun statusCodeForException(cause: Throwable) = when (cause) { - is IllegalArgumentException -> HttpStatusCode.BadRequest is NotFoundException -> HttpStatusCode.NotFound + is IllegalArgumentException -> HttpStatusCode.BadRequest +...
IllegalStateException is probably 500 (Internal Server Error), while IllegalArgumentException should be 400 (Bad Request)
waltid-identity
github_2023
others
597
walt-id
alegomes
@@ -124,11 +127,11 @@ class SSIKit2WalletService( } override suspend fun restoreCredential(id: String): WalletCredential = - credentialService.restore(walletId, id) ?: error("Credential not found: $id") + credentialService.restore(walletId, id) ?: throw NotFoundException("Credential not found:...
This error message exposes a class and a parameter name that doesn't make sense to the final user. Why not maintain the consistency with other messages just with "Credential not found: $id"?
waltid-identity
github_2023
others
597
walt-id
alegomes
@@ -436,34 +439,52 @@ class SSIKit2WalletService( }.getKeyId() } - override suspend fun importKey(jwkOrPem: String): String { - val type = - when { - jwkOrPem.lines().first().contains("BEGIN ") -> "pem" - else -> "jwk" - } + private fu...
That's a very clear message. 👏
waltid-identity
github_2023
others
597
walt-id
alegomes
@@ -343,7 +346,7 @@ class SSIKit2WalletService( override suspend fun loadDid(did: String): JsonObject = DidsService.get(walletId, did)?.let { Json.parseToJsonElement(it.document).jsonObject } - ?: throw IllegalArgumentException("Did not found: $did for account: $walletId") + ?: thr...
![image](https://github.com/user-attachments/assets/d766f268-dff5-42be-abdd-17665181ddc7)
waltid-identity
github_2023
others
597
walt-id
alegomes
@@ -106,9 +106,10 @@ fun Application.dids() = walletRoute { } } response { - HttpStatusCode.OK to { - description = "DID created" - } + HttpStatusCode.OK to { description = "DID created" } + HttpSta...
Can we provide the reason?
waltid-identity
github_2023
others
575
walt-id
mikeplotean
@@ -4,37 +4,32 @@ } # Wallet API -:{$WALLET_BACKEND_PORT} { - reverse_proxy http://wallet-api:{$WALLET_BACKEND_PORT} +:7001 {
this makes service ports in docker compose harder to configure does it cause any errors?
waltid-identity
github_2023
others
575
walt-id
mikeplotean
@@ -1,2 +1,2 @@ webHost = "0.0.0.0" -webPort = "${ISSUER_API_PORT}" +webPort = "7002"
same as above, having it set up like this makes it harder to configure for docker compose does it cause any error?
waltid-identity
github_2023
others
575
walt-id
mikeplotean
@@ -1 +1 @@ -baseUrl = "http://host.docker.internal:${VERIFIER_API_PORT}" +baseUrl = "http://verifier-api:7003"
please see web.conf comments
waltid-identity
github_2023
others
575
walt-id
mikeplotean
@@ -1,2 +1,2 @@ webHost = "0.0.0.0" -webPort = "${VERIFIER_API_PORT}" +webPort = "7003"
please see web.conf comments
waltid-identity
github_2023
others
575
walt-id
mikeplotean
@@ -1,5 +1,5 @@ hikariDataSource { - jdbcUrl = "jdbc:sqlite:${SQLITE_DB_DATA}" + jdbcUrl = "jdbc:sqlite:data/data.db"
please see web.conf comments
waltid-identity
github_2023
others
575
walt-id
mikeplotean
@@ -39,112 +39,112 @@ class WaltIdDidResolveCmdTest { @Test @Ignore - fun `should resolve uniresolver P-521 did-key example`() { + fun `should resolve uniresolver P-521 did|key example`() {
pipe char is an invalid char on windows and throws 'invalid path error' this is also the reason it was changed to '-'
waltid-identity
github_2023
others
575
walt-id
mikeplotean
@@ -45,7 +45,7 @@ class ExpirationDatePolicyTest { } @Test - fun `should NOT fail with a valid signed VC and data = jws-payload('vc')`() { + fun `should NOT fail with a valid signed VC and data = jws-payload("vc)"`() {
quote is an illegal char on windows this is also why it was changed to apostrophe (single-quote)
waltid-identity
github_2023
others
575
walt-id
mikeplotean
@@ -56,7 +56,7 @@ class ExpirationDatePolicyTest { } @Test - fun `should NOT fail with a valid NOT signed VC and data = jwt`() { + fun `should NOT fail with a valid NOT signed VC and data = jwt"`() {
same as above
waltid-identity
github_2023
others
575
walt-id
mikeplotean
@@ -67,7 +67,7 @@ class ExpirationDatePolicyTest { } @Test - fun `should fail ExpirationDatePolicy + jws-payload('vc')`() { + fun `should fail ExpirationDatePolicy + jws-payload("vc")`() {
and here
waltid-identity
github_2023
others
575
walt-id
mikeplotean
@@ -51,3 +52,16 @@ fun Instant.toDE(subType: DEDateTimeMode = DEDateTimeMode.tdate) = when(subType) * Convert to CBOR data element */ fun LocalDate.toDE(subType: DEFullDateMode = DEFullDateMode.full_date_str) = FullDateElement(this, subType) + +fun JsonElement.toDE(): AnyDataElement = when(this) {
perhaps can have the whole name (I guess toDataElement)
waltid-identity
github_2023
others
575
walt-id
mikeplotean
@@ -70,6 +70,18 @@ object OpenID4VCI { }.buildString() } + fun getOAuthProviderMetadataUrl(baseUrl: String): String { + return URLBuilder(baseUrl).apply {
nitpicking alert! could be simplified to assignment ```kotlin fun getOAuthProviderMetadataUrl(baseUrl: String): String = URLBuilder(baseUrl).apply { appendPathSegments(".well-known", "oauth-authorization-server") }.buildString() ```
waltid-identity
github_2023
others
575
walt-id
mikeplotean
@@ -70,6 +70,18 @@ object OpenID4VCI { }.buildString() } + fun getOAuthProviderMetadataUrl(baseUrl: String): String { + return URLBuilder(baseUrl).apply { + appendPathSegments(".well-known", "oauth-authorization-server") + }.buildString() + } + + fun getJWTIssuerProvide...
same as above
waltid-identity
github_2023
others
575
walt-id
mikeplotean
@@ -70,6 +70,18 @@ object OpenID4VCI { }.buildString() } + fun getOAuthProviderMetadataUrl(baseUrl: String): String { + return URLBuilder(baseUrl).apply { + appendPathSegments(".well-known", "oauth-authorization-server") + }.buildString() + } + + fun getJWTIssuerProvide...
here as well
waltid-identity
github_2023
others
575
walt-id
mikeplotean
@@ -60,9 +61,7 @@ data class ProofOfPossession @OptIn(ExperimentalSerializationApi::class) private } override suspend fun build(key: Key): ProofOfPossession { - return ProofOfPossession(ProofType.jwt, key.signJws(payload.toString().toByteArray(), - // NOTE: this assumes eve...
nitpicking alert! could be simplied, e.g. ```kotlin override suspend fun build(key: Key): ProofOfPossession = ProofOfPossession( ProofType.jwt, key.signJws(payload.toString().toByteArray(), headers), null, null ) ```
waltid-identity
github_2023
others
575
walt-id
mikeplotean
@@ -40,67 +40,91 @@ data class PresentationDefinition( override fun fromJSON(jsonObject: JsonObject) = Json.decodeFromJsonElement(PresentationDefinitionSerializer, jsonObject) - fun primitiveGenerationFromVcTypes(types: List<String>, openId4VPProfile: OpenId4VPProfile): PresentationDefini...
ide suggests it could be private, couldn't it?
waltid-identity
github_2023
others
575
walt-id
mikeplotean
@@ -40,67 +40,91 @@ data class PresentationDefinition( override fun fromJSON(jsonObject: JsonObject) = Json.decodeFromJsonElement(PresentationDefinitionSerializer, jsonObject) - fun primitiveGenerationFromVcTypes(types: List<String>, openId4VPProfile: OpenId4VPProfile): PresentationDefini...
maybe this could be simplified to be more readable, e.g. extract the mdl case into a separate private function, then this method would look like: ```kotlin fun primitiveGenerationFromVcTypes( types: List<String>, openId4VPProfile: OpenId4VPProfile = OpenId4VPProfile.DEFAULT ): PresentationDefinition = Pres...
waltid-identity
github_2023
others
575
walt-id
mikeplotean
@@ -40,67 +40,91 @@ data class PresentationDefinition( override fun fromJSON(jsonObject: JsonObject) = Json.decodeFromJsonElement(PresentationDefinitionSerializer, jsonObject) - fun primitiveGenerationFromVcTypes(types: List<String>, openId4VPProfile: OpenId4VPProfile): PresentationDefini...
maybe this could also be simplified by extracting the cases into separate functions, e.g. ```kotlin fun generateDefaultInputDescriptor( type: String, openId4VPProfile: OpenId4VPProfile = OpenId4VPProfile.DEFAULT ): InputDescriptor = when (openId4VPProfile) { OpenId4VPProfile.HAIP -> haipProfuleInputDe...
waltid-identity
github_2023
others
575
walt-id
mikeplotean
@@ -320,15 +329,29 @@ abstract class OpenIDCredentialIssuer( } } + protected fun getNonceFromProof(proofOfPossession: ProofOfPossession) = when(proofOfPossession.proofType) { + ProofType.jwt -> parseTokenPayload(proofOfPossession.jwt!!)[JWTClaims.Payload.nonce]?.jsonPrimitive?.content + ...
optIn seems unnecessary anymore
waltid-identity
github_2023
others
575
walt-id
mikeplotean
@@ -320,15 +329,29 @@ abstract class OpenIDCredentialIssuer( } } + protected fun getNonceFromProof(proofOfPossession: ProofOfPossession) = when(proofOfPossession.proofType) { + ProofType.jwt -> parseTokenPayload(proofOfPossession.jwt!!)[JWTClaims.Payload.nonce]?.jsonPrimitive?.content + ...
perhaps this `if` could be simplified by extracting the checks into separate methods, e.g. ```kotlin private fun isCwtProofType( credentialRequest: CredentialRequest, proof: ProofOfPossession? ) = credentialRequest.proof?.proofType == ProofType.cwt && !proof?.cwt.isNullOrEmpty() private fun isJwtProofTy...