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 | 762 | walt-id | mikeplotean | @@ -348,10 +360,11 @@ class TSEKey(
fun throwTSEError(msg: String): Nothing =
throw RuntimeException("Invalid TSE server (${metadata.server}) response: $msg")
- val keyName = keyData["name"]?.jsonPrimitive?.content ?: throwTSEError("no key name in key data: $keyData")
+ ... | <del>same as above, maybe just `KeyNotFoundException` would be enough</del>
actually this is not about they, but rather about missing property, so I'd probably have either `IllegalArgumentException` or a custom `TSEError.MissingKeyNameException` |
waltid-identity | github_2023 | others | 762 | walt-id | mikeplotean | @@ -348,10 +360,11 @@ class TSEKey(
fun throwTSEError(msg: String): Nothing =
throw RuntimeException("Invalid TSE server (${metadata.server}) response: $msg")
- val keyName = keyData["name"]?.jsonPrimitive?.content ?: throwTSEError("no key name in key data: $keyData")
+ ... | same as above, maybe a custom `TSEError,MissingKeyDataException` |
waltid-identity | github_2023 | others | 762 | walt-id | mikeplotean | @@ -305,24 +308,25 @@ class TSEKey(
KeyType.Ed25519 -> "ed25519"
KeyType.secp256r1 -> "ecdsa-p256"
KeyType.RSA -> "rsa-2048"
- KeyType.secp256k1 -> throw IllegalArgumentException("Not supported: $type")
+ KeyType.secp256k1 -> throw KeyTypeNotSupportedExceptio... | will put it here, just to make sure this is not a comment by mistake |
waltid-identity | github_2023 | others | 762 | walt-id | mikeplotean | @@ -0,0 +1,207 @@
+import love.forte.plugin.suspendtrans.ClassInfo
+import love.forte.plugin.suspendtrans.SuspendTransformConfiguration
+import love.forte.plugin.suspendtrans.TargetPlatform
+import love.forte.plugin.suspendtrans.gradle.SuspendTransPluginConstants
+import love.forte.plugin.suspendtrans.gradle.SuspendTra... | this being multiplatform now, I think it should be `id.walt.library-commons` or similar, so all build artifacts will go under the same root group, regardless of platform
for example for the crypto lib, it's `id.walt.crypto` |
waltid-identity | github_2023 | others | 762 | walt-id | mikeplotean | @@ -0,0 +1,56 @@
+package id.walt.commons.exceptions
+
+import io.ktor.http.HttpStatusCode
+
+open class CryptoException(val status: HttpStatusCode, message: String) : Exception(message)
+
+
+class KeyTypeNotSupportedException(type: String) :
+ CryptoException(HttpStatusCode.BadRequest, "Key type $type not supported... | nitpicking alert!
I think the correct form in this case would be "missing from" |
waltid-identity | github_2023 | others | 736 | walt-id | mikeplotean | @@ -0,0 +1,256 @@
+package id.walt.did.dids.registrar.dids
+
+import id.walt.crypto.keys.Key
+import id.walt.crypto.keys.KeyType
+import id.walt.did.dids.DidUtils
+import id.walt.did.dids.document.DidDocument
+import id.walt.did.dids.document.models.service.Service
+import id.walt.did.dids.document.models.service.Servi... | maybe this method could be simplified - have a separate method for each variable:
```kotlin
private suspend fun createVerificationMethod(did: String) = verificationConfigurationMap
.values
.flatten()
.map { verConf ->
val key = publicKeyMap[verConf.publicKeyId]
?: throw IllegalSta... |
waltid-identity | github_2023 | others | 736 | walt-id | mikeplotean | @@ -0,0 +1,149 @@
+package id.walt.did.dids.document.models.service
+
+import kotlinx.serialization.KSerializer
+import kotlinx.serialization.Serializable
+import kotlinx.serialization.builtins.SetSerializer
+import kotlinx.serialization.descriptors.SerialDescriptor
+import kotlinx.serialization.encoding.Decoder
+impor... | maybe this could be refactored, e.g.:
```kotlin
private fun JsonObjectBuilder.putType(value: ServiceMap) = when (value.type.size) {
1 -> {
value.type.first().toJsonElement()
}
else -> {
Json.encodeToJsonElement(value.type)
}
}.let {
put("type", it)
}
```
and
```kotlin... |
waltid-identity | github_2023 | others | 736 | walt-id | mikeplotean | @@ -0,0 +1,149 @@
+package id.walt.did.dids.document.models.service
+
+import kotlinx.serialization.KSerializer
+import kotlinx.serialization.Serializable
+import kotlinx.serialization.builtins.SetSerializer
+import kotlinx.serialization.descriptors.SerialDescriptor
+import kotlinx.serialization.encoding.Decoder
+impor... | perhaps these calls could also be simplified to:
```kotlin
private fun JsonObjectBuilder.putType(value: ServiceMap) = when (value.type.size) {
1 -> {
put("type", value.type.first().toString())
}
else -> {
put("type", Json.encodeToJsonElement(value.type))
}
}
```
and
```kotl... |
waltid-identity | github_2023 | others | 736 | walt-id | mikeplotean | @@ -0,0 +1,74 @@
+package id.walt.did.dids.document.models.service
+
+import id.walt.crypto.utils.JsonUtils.toJsonElement
+import kotlinx.serialization.*
+import kotlinx.serialization.encoding.Decoder
+import kotlinx.serialization.encoding.Encoder
+import kotlinx.serialization.json.*
+import kotlin.js.ExperimentalJsExp... | shouldn't this say 'as a json object'? |
waltid-identity | github_2023 | others | 736 | walt-id | mikeplotean | @@ -0,0 +1,125 @@
+package id.walt.did.serialize.service
+
+import id.walt.crypto.utils.JsonUtils.toJsonElement
+import id.walt.did.dids.document.models.service.*
+import kotlinx.coroutines.test.runTest
+import kotlinx.serialization.encodeToString
+import kotlinx.serialization.json.Json
+import kotlinx.serialization.js... | since there's no suspend run, the test wouldn't require a `runTest` context |
waltid-identity | github_2023 | others | 736 | walt-id | mikeplotean | @@ -0,0 +1,158 @@
+package id.walt.did.serialize.service
+
+import id.walt.crypto.utils.JsonUtils.toJsonElement
+import id.walt.did.dids.document.models.service.*
+import kotlinx.coroutines.test.runTest
+import kotlinx.serialization.encodeToString
+import kotlinx.serialization.json.Json
+import kotlinx.serialization.js... | same as with `ServiceEndpointTest`s - currently no need for `runTest` context
|
waltid-identity | github_2023 | others | 755 | walt-id | mikeplotean | @@ -454,43 +455,41 @@ private fun getErrorDescription(it: Throwable): String? = when (it.localizedMess
else -> null
}
-private suspend fun PipelineContext<Unit, ApplicationCall>.processError(
- sessionId: String, exception: Throwable
-) {
- val session = verificationUseCase.getSession(sessionId)
- if (... | this could be extracted into a separate method, e.g. processError:
```kotlin
private suspend fun PipelineContext<Unit, ApplicationCall>.processError(
sessionId: String,
error: Throwable
) {
val session = verificationUseCase.getSession(sessionId)
if (session.walletInitiatedAuthState != null) {
... |
waltid-identity | github_2023 | others | 755 | walt-id | mikeplotean | @@ -1,14 +1,21 @@
package id.walt.webwallet.utils
import io.github.oshai.kotlinlogging.KotlinLogging
+import kotlinx.serialization.json.Json
+import kotlinx.serialization.json.jsonObject
import java.io.InputStream
-import java.util.*
+import java.util.Base64
+import java.util.BitSet | please optimize imports |
waltid-identity | github_2023 | others | 749 | walt-id | mikeplotean | @@ -192,7 +192,7 @@ class AuthApi(private val client: HttpClient) {
)
private val subjectJWKPrivateKey = PKIXUtils.javaPrivateKeyToJWKKey(subjectKeyPair.private)
- private fun createX5CAccountRequest(key: JWKKey, cert: X509Certificate) = runBlocking {
+ private fun createX5CAccountRequ... | this feels like a change coming from https://github.com/walt-id/waltid-identity/pull/746 |
waltid-identity | github_2023 | others | 749 | walt-id | mikeplotean | @@ -19,7 +19,7 @@ import kotlinx.uuid.generateUUID
import org.jetbrains.exposed.sql.insert
import org.jetbrains.exposed.sql.transactions.transaction
-object X5CAccountStrategy: PasswordlessAccountStrategy<X5CAccountRequest>() {
+object X5CAccountStrategy : PasswordlessAccountStrategy<X5CAccountRequest>() { | this also feels like a change coming from https://github.com/walt-id/waltid-identity/pull/746 |
waltid-identity | github_2023 | others | 749 | walt-id | mikeplotean | @@ -7,7 +7,7 @@ const val x5cAuthPath = "auth/x5c"
val x5cAuthTags = listOf("X5C Authentication")
fun Application.x5cAuthRoutes() = webWalletRoute {
- X5CLoginController().routes("login").invoke(this)
+ X5CLoginController().routes("login")(this) | and this one also coming from https://github.com/walt-id/waltid-identity/pull/746
what happened with the merge? |
waltid-identity | github_2023 | others | 749 | walt-id | mikeplotean | @@ -22,5 +22,5 @@ MSSQL_DB_PORT=1433
#sqlite | postgres | mssql
DATABASE_ENGINE=postgres
-VERSION_TAG=0.6.0
+VERSION_TAG=0.7.0 | if this update is done before the release, then it might happen that someone using docker compose will face issues running it, as the images are not available yet |
waltid-identity | github_2023 | others | 705 | walt-id | waltkb | @@ -220,7 +220,7 @@ fun Application.entraVerifierApi() {
if (!EntraVerifierApi.callbackMapping.containsKey(nonce)) {
- context.respond(HttpStatusCode.BadRequest)
+ context.respond(HttpStatusCode.BadRequest, "Invalid nonce") | throw exception instead (otherwise the response is plain text in body) |
waltid-identity | github_2023 | others | 705 | walt-id | waltkb | @@ -335,13 +369,17 @@ fun Application.verfierApi() {
required = true
}
}
+ response {
+ HttpStatusCode.OK to { body<JsonObject>() }
+ HttpStatusCode.NotFound to { body<String>() }
+ }
... |
throw exception instead (otherwise the response is plain text in body)
|
waltid-identity | github_2023 | others | 705 | walt-id | waltkb | @@ -314,6 +338,16 @@ fun Application.verfierApi() {
description = "Session info"
}
}
+ HttpStatusCode.BadRequest to {
+ body<String> {
+ description = "Session not found or inv... | NotFoundException meant here instead? |
waltid-identity | github_2023 | others | 705 | walt-id | alegomes | @@ -149,7 +149,7 @@ object OIDCVerifierService : OpenIDCredentialVerifier(
// Simple cryptographic operations interface implementation
override fun doVerify(tokenResponse: TokenResponse, session: PresentationSession): Boolean {
val policies = sessionVerificationInfos[session.id]
- ?: throw... | What are the cases in which this might happen. Is it an internal issue or something caused by the user? |
waltid-identity | github_2023 | others | 705 | walt-id | alegomes | @@ -206,7 +206,8 @@ object OIDCVerifierService : OpenIDCredentialVerifier(
val parsedDeviceResponse = DeviceResponse.fromCBORBase64URL(tokenResponse.vpToken!!.jsonPrimitive.content)
val parsedMdoc = parsedDeviceResponse.documents[0]
val deviceKey = OneKey(CBORObject.DecodeFromBytes(parsedMdoc... | Same question as before: Does this message make sense to the API user? Or is it something internal to the service and out of the user's control? |
waltid-identity | github_2023 | others | 705 | walt-id | alegomes | @@ -256,46 +272,54 @@ fun Application.verfierApi() {
}
}
}) {
- logger.info { "POST verify/state" }
- val sessionId = call.parameters["state"]
- logger.info { "State: $sessionId" }
- verificationUseCase.verify... | Is there any specific case that could be captured and broken down into another less generic exception? I think the less BadRequest we throw, the better the experience. |
waltid-identity | github_2023 | others | 705 | walt-id | alegomes | @@ -90,8 +90,8 @@ class VerificationUseCase(
val specificPolicies = requestCredentialsArr.filterIsInstance<JsonObject>().associate {
(it["credential"]
- ?: throw IllegalArgumentException("No `credential` name supplied, in `request_credentials`.")).jsonPrimitive.content to (it["pol... | I think that comma should not be there. |
waltid-identity | github_2023 | others | 705 | walt-id | alegomes | @@ -90,8 +90,8 @@ class VerificationUseCase(
val specificPolicies = requestCredentialsArr.filterIsInstance<JsonObject>().associate {
(it["credential"]
- ?: throw IllegalArgumentException("No `credential` name supplied, in `request_credentials`.")).jsonPrimitive.content to (it["pol... | Remove comma from exception message. |
waltid-identity | github_2023 | others | 705 | walt-id | alegomes | @@ -111,12 +111,13 @@ class VerificationUseCase(
session
}
- fun getSession(sessionId: String): PresentationSession = sessionId.let { OIDCVerifierService.getSession(it) }!!
+ fun getSession(sessionId: String): PresentationSession = sessionId.let { OIDCVerifierService.getSession(it) }
+ ?: t... | This what the user will get:
`State parameter doesn't refer to an existing session, or session expired: LOREMIPSUM`
Looking at the code, it's clear what the last token of the message is about. However, when the user gets the resulting message, it might not be so clear. What if it was like this?
`State paramete... |
waltid-identity | github_2023 | others | 705 | walt-id | alegomes | @@ -111,12 +111,13 @@ class VerificationUseCase(
session
}
- fun getSession(sessionId: String): PresentationSession = sessionId.let { OIDCVerifierService.getSession(it) }!!
+ fun getSession(sessionId: String): PresentationSession = sessionId.let { OIDCVerifierService.getSession(it) }
+ ?: t... | "State parameter $sessionId doesn't refer to an existing session or session is expired." |
waltid-identity | github_2023 | others | 705 | walt-id | alegomes | @@ -126,7 +127,7 @@ class VerificationUseCase(
else -> TokenResponse.fromHttpParameters(tokenResponseParameters)
}
val sessionVerificationInfo = OIDCVerifierService.sessionVerificationInfos[session.id] ?: return Result.failure(
- IllegalStateException("No session verification i... | Is "session id" == "state parameter" ?
If so, what it we standardize the vocabulary to avoid confusion? |
waltid-identity | github_2023 | others | 705 | walt-id | alegomes | @@ -179,12 +180,12 @@ class VerificationUseCase(
fun getPresentationDefinition(sessionId: String): Result<PresentationDefinition> =
OIDCVerifierService.getSession(sessionId)?.presentationDefinition?.let {
Result.success(it)
- } ?: Result.failure(error("Invalid id provided (expired?): $... | I suggest standardizing the messages related to the same issue.
Look how many variations there are for the same problem:
"Invalid id provided (expired?): $sessionId"
"No session verification information found for session id!"
"State parameter doesn't refer to an existing session, or session expired"
"State par... |
waltid-identity | github_2023 | others | 705 | walt-id | alegomes | @@ -149,7 +150,7 @@ object OIDCVerifierService : OpenIDCredentialVerifier(
// Simple cryptographic operations interface implementation
override fun doVerify(tokenResponse: TokenResponse, session: PresentationSession): Boolean {
val policies = sessionVerificationInfos[session.id]
- ?: throw... | I was wondering. Is there anything the user can do if the policy listing could not be found? If yes, ok. But, if not, why should we tell him this? |
waltid-identity | github_2023 | others | 705 | walt-id | waltkb | @@ -179,12 +180,14 @@ class VerificationUseCase(
fun getPresentationDefinition(sessionId: String): Result<PresentationDefinition> =
OIDCVerifierService.getSession(sessionId)?.presentationDefinition?.let {
Result.success(it)
- } ?: Result.failure(IllegalArgumentException("Invalid id pro... | ok |
waltid-identity | github_2023 | others | 705 | walt-id | waltkb | @@ -179,12 +180,14 @@ class VerificationUseCase(
fun getPresentationDefinition(sessionId: String): Result<PresentationDefinition> =
OIDCVerifierService.getSession(sessionId)?.presentationDefinition?.let {
Result.success(it)
- } ?: Result.failure(IllegalArgumentException("Invalid id pro... | ok (repeated though) |
waltid-identity | github_2023 | others | 705 | walt-id | waltkb | @@ -164,7 +165,7 @@ class VerificationUseCase(
fun getResult(sessionId: String): Result<PresentationSessionInfo> {
val session = OIDCVerifierService.getSession(sessionId)
- ?: return Result.failure(IllegalArgumentException("Invalid id provided (expired?): $sessionId"))
+ ?: return ... | repeated 3x |
waltid-identity | github_2023 | others | 705 | walt-id | waltkb | @@ -126,7 +127,7 @@ class VerificationUseCase(
else -> TokenResponse.fromHttpParameters(tokenResponseParameters)
}
val sessionVerificationInfo = OIDCVerifierService.sessionVerificationInfos[session.id] ?: return Result.failure(
- IllegalStateException("No session verification i... | ok (no space before `:`) |
waltid-identity | github_2023 | others | 705 | walt-id | waltkb | @@ -111,12 +111,13 @@ class VerificationUseCase(
session
}
- fun getSession(sessionId: String): PresentationSession = sessionId.let { OIDCVerifierService.getSession(it) }!!
+ fun getSession(sessionId: String): PresentationSession = sessionId.let { OIDCVerifierService.getSession(it) }
+ ?: t... | ok |
waltid-identity | github_2023 | others | 705 | walt-id | waltkb | @@ -111,12 +111,13 @@ class VerificationUseCase(
session
}
- fun getSession(sessionId: String): PresentationSession = sessionId.let { OIDCVerifierService.getSession(it) }!!
+ fun getSession(sessionId: String): PresentationSession = sessionId.let { OIDCVerifierService.getSession(it) }
+ ?: t... | repeated 4x |
waltid-identity | github_2023 | others | 705 | walt-id | waltkb | @@ -90,8 +90,8 @@ class VerificationUseCase(
val specificPolicies = requestCredentialsArr.filterIsInstance<JsonObject>().associate {
(it["credential"]
- ?: throw IllegalArgumentException("No `credential` name supplied, in `request_credentials`.")).jsonPrimitive.content to (it["pol... | IllegalArgumentException gets transformed to a BadRequestException afaik |
waltid-identity | github_2023 | others | 705 | walt-id | waltkb | @@ -206,7 +207,8 @@ object OIDCVerifierService : OpenIDCredentialVerifier(
val parsedDeviceResponse = DeviceResponse.fromCBORBase64URL(tokenResponse.vpToken!!.jsonPrimitive.content)
val parsedMdoc = parsedDeviceResponse.documents[0]
val deviceKey = OneKey(CBORObject.DecodeFromBytes(parsedMdoc... | ok |
waltid-identity | github_2023 | others | 705 | walt-id | waltkb | @@ -149,7 +150,7 @@ object OIDCVerifierService : OpenIDCredentialVerifier(
// Simple cryptographic operations interface implementation
override fun doVerify(tokenResponse: TokenResponse, session: PresentationSession): Boolean {
val policies = sessionVerificationInfos[session.id]
- ?: throw... | ok |
waltid-identity | github_2023 | others | 705 | walt-id | waltkb | @@ -218,11 +218,7 @@ fun Application.entraVerifierApi() {
//println("Body: " + context.receiveText())
println("URL: " + context.url())
- if (!EntraVerifierApi.callbackMapping.containsKey(nonce)) {
-
- context.respond(HttpStatusCode.BadRequest)
- ... | ok |
waltid-identity | github_2023 | others | 705 | walt-id | waltkb | @@ -339,13 +371,17 @@ fun Application.verfierApi() {
required = true
}
}
+ response {
+ HttpStatusCode.OK to { body<JsonObject>() }
+ HttpStatusCode.NotFound to { body<String>() }
+ }
... | ok |
waltid-identity | github_2023 | others | 705 | walt-id | waltkb | @@ -371,7 +407,7 @@ fun Application.verfierApi() {
call.respondText(it, ContentType.parse("application/oauth-authz-req+jwt"), HttpStatusCode.OK)
}.onFailure {
logger.debug(it) { "Cannot view request session ($it)" }
- call.respond(HttpStatusC... | ok |
waltid-identity | github_2023 | others | 705 | walt-id | waltkb | @@ -318,14 +337,27 @@ fun Application.verfierApi() {
description = "Session info"
}
}
+ HttpStatusCode.NotFound to {
+ body<String> {
+ description = "Session not found or inva... | This does not do anything (everything repeated is default behavior)? -> the runCatching can be disposed |
waltid-identity | github_2023 | others | 705 | walt-id | waltkb | @@ -229,7 +234,13 @@ fun Application.verfierApi() {
else -> session.authorizationRequest!!.toHttpQueryString()
}
)
- )
+ }.onSuccess {
+ call.respondText(it, ContentType.Text.Plain, HttpStatusCode... | onFailure -> throw it
from below:
This does not do anything (everything repeated is default behavior)? -> the runCatching can be disposed
|
waltid-identity | github_2023 | others | 705 | walt-id | waltkb | @@ -260,46 +266,54 @@ fun Application.verfierApi() {
}
}
}) {
- logger.info { "POST verify/state" }
- val sessionId = call.parameters["state"]
- logger.info { "State: $sessionId" }
- verificationUseCase.verify... | basically means
`if (error is IllegalArgumentException) throw IllegalArgumentException(error.message)`
`if (error is NotFoundException throw NotFoundException(error.message)`
`...`
This is useless because by default it would already do the exact same thing? Besides loosing the real stack trace and cause of the exce... |
waltid-identity | github_2023 | others | 705 | walt-id | mikeplotean | @@ -260,46 +266,51 @@ fun Application.verfierApi() {
}
}
}) {
- logger.info { "POST verify/state" }
- val sessionId = call.parameters["state"]
- logger.info { "State: $sessionId" }
- verificationUseCase.verify... | not sure checking the `localizedMessage` is a good approach
but anyway, maybe the error description could be extracted to separate method, e.g.:
```kotlin
private fun getErrorDescription(it: Throwable): String? = when (it.localizedMessage) {
"Verification policies did not succeed: expired" ->
"<\$prese... |
waltid-identity | github_2023 | others | 705 | walt-id | mikeplotean | @@ -260,46 +266,51 @@ fun Application.verfierApi() {
}
}
}) {
- logger.info { "POST verify/state" }
- val sessionId = call.parameters["state"]
- logger.info { "State: $sessionId" }
- verificationUseCase.verify... | since the error is re-thrown here, is runCatching still needed? |
waltid-identity | github_2023 | others | 705 | walt-id | mikeplotean | @@ -260,46 +266,51 @@ fun Application.verfierApi() {
}
}
}) {
- logger.info { "POST verify/state" }
- val sessionId = call.parameters["state"]
- logger.info { "State: $sessionId" }
- verificationUseCase.verify... | maybe worth replacing this with:
```kotlin
val sessionId = call.parameters.getOrFail("state")
```
this would allow to update `verificationUseCase.verify` to take a non-nullable `sessionId` parameter
which would allow to remove null-safety for `sessionId` when [fetching](https://github.com/walt-id/waltid-identity/b... |
waltid-identity | github_2023 | others | 705 | walt-id | mikeplotean | @@ -25,15 +25,15 @@ import io.github.oshai.kotlinlogging.KotlinLogging
import io.ktor.client.*
import io.ktor.client.request.*
import io.ktor.http.*
+import io.ktor.server.plugins.*
import kotlinx.coroutines.runBlocking
import kotlinx.serialization.json.*
import java.security.KeyFactory
import java.security.cert... | not related to this pr, but since here
maybe update the `getClientIdScheme` to private scope |
waltid-identity | github_2023 | others | 705 | walt-id | waltkb | @@ -260,46 +267,22 @@ fun Application.verfierApi() {
}
}
}) {
- logger.info { "POST verify/state" }
- val sessionId = call.parameters["state"]
- logger.info { "State: $sessionId" }
- verificationUseCase.verify... | `runCatching { ... }.onFailure { throw it }`? |
waltid-identity | github_2023 | others | 705 | walt-id | waltkb | @@ -314,18 +297,25 @@ fun Application.verfierApi() {
}
response {
HttpStatusCode.OK to {
- body<PresentationSessionInfo> { // it's PresentationSessionInfo
+ body<PresentationSessionInfo> {
d... | :heavy_check_mark: |
waltid-identity | github_2023 | others | 729 | walt-id | mikeplotean | @@ -0,0 +1,63 @@
+package id.walt.webwallet.usecase.claim
+
+import id.walt.webwallet.db.models.WalletCredential
+import id.walt.webwallet.service.credentials.CredentialsService
+import id.walt.webwallet.service.events.EventType
+import id.walt.webwallet.service.exchange.IssuanceService
+import id.walt.webwallet.usecas... | nitpicking alert!
this could be simplified with `=`, e.g.:
```kotlin
addReceiveCredentialToUseCaseLog(/*...*/) = eventUseCase.log(/*...*/)
``` |
waltid-identity | github_2023 | others | 729 | walt-id | mikeplotean | @@ -0,0 +1,16 @@
+package id.walt.webwallet.web.controllers.exchange
+
+import kotlinx.serialization.json.*
+
+object ExchangeUtils {
+
+ fun getFirstAuthKeyIdFromDidDocument(
+ didDocument: String,
+ ) = Json.decodeFromString<JsonObject>(didDocument)["authentication"]!!.jsonArray.first().let { | maybe it would be good to validate the field, either here or at the caller site, e.g.
```kotlin
private fun validateAuthentication(json: JsonObject) {
checkNotNull(json["authentication"]) { "missing authentication.. " }
require(json["authentication"] is JsonArray) { "unexpected authentication value.." }
... |
waltid-identity | github_2023 | others | 729 | walt-id | mikeplotean | @@ -29,23 +26,179 @@ import io.ktor.util.*
import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.Serializable
import kotlinx.serialization.decodeFromByteArray
-import kotlinx.serialization.json.Json
-import kotlinx.serialization.json.JsonObject
-import kotlinx.serialization.json.json... | was thinking, maybe this could be split, e.g. have an issuance-service-base for common things and 2 separate services (with external-signing and internal-signing) for each use case inheriting from base, until we merge them:
```kotlin
abstract class IssuanceServiceBase {
protected val http = WalletHttpClients.get... |
waltid-identity | github_2023 | others | 729 | walt-id | mikeplotean | @@ -0,0 +1,120 @@
+package id.walt.webwallet.service.exchange
+
+import COSE.OneKey
+import com.nimbusds.jose.jwk.ECKey
+import id.walt.crypto.utils.JsonUtils.toJsonElement
+import id.walt.did.dids.DidService
+import id.walt.oid4vc.data.CredentialOffer
+import id.walt.oid4vc.data.OfferedCredential
+import id.walt.oid4v... | nitpicking alert!
this could be refactored even more, have a separate method for building the proof-type from each key and did, for cwt and jwt, respectively and also have the instantiation of possesion-parameters extracted into separate methods, e.g.:
```kotlin
private fun cwtProofOfPossessionParameters(it: ProofOf... |
waltid-identity | github_2023 | others | 729 | walt-id | mikeplotean | @@ -1,5 +1,6 @@
package id.walt.webwallet.web.controllers.exchange | not part of this pr, but maybe worth renaming
- `rootPath` to smth. like `exchangeRootPath`
- and `route` to `exchangeRoute` |
waltid-identity | github_2023 | others | 729 | walt-id | mikeplotean | @@ -355,6 +350,176 @@ fun Application.exchangeExternalSignatures() = walletRoute {
}
}
}
+ post("external_signatures/offer/prepare", {
+ summary = "Preparation (first) step for an OID4VCI flow with externally provided signatures."
+
+ request {
+ ... | this could probably be simplified to smth. like:
```kotlin
runCatching {
WalletServiceManager
.externalSignatureClaimStrategy
.submitCredentialClaim(
tenantId = walletService.tenant,
accountId = walletService.accountId,
walletId = walletService.walletId,
... |
waltid-identity | github_2023 | others | 729 | walt-id | mikeplotean | @@ -355,6 +350,176 @@ fun Application.exchangeExternalSignatures() = walletRoute {
}
}
}
+ post("external_signatures/offer/prepare", {
+ summary = "Preparation (first) step for an OID4VCI flow with externally provided signatures."
+
+ request {
+ ... | this could probably be simplified to smth. like:
```kotlin
runCatching {
WalletServiceManager.externalSignatureClaimStrategy.prepareCredentialClaim(
did = walletDID.did,
keyId = authKeyId,
offerURL = offer,
)
}.getOrElse { throw IllegalStateException("") }.let { prepareClaimResul... |
waltid-identity | github_2023 | others | 729 | walt-id | mikeplotean | @@ -1,26 +1,37 @@
+import COSE.AlgorithmID
import E2ETestWebService.loadResource
+import cbor.Cbor
+import com.nimbusds.jose.jwk.ECKey
+import id.walt.crypto.keys.KeyType
import id.walt.crypto.keys.jwk.JWKKey
import id.walt.did.utils.randomUUID
+import id.walt.issuer.issuance.IssuanceExamples
import id.walt.issuer.... | not part of this pr, but just noticed
since this test suite wipes the wallet data before running the tests,
maybe it's worth mentioning that in e2e test, at this location:
```kotlin
// test External Signature API Endpoints
ExchangeExternalSignatures().executeTestCases()
``` |
waltid-identity | github_2023 | others | 729 | walt-id | mikeplotean | @@ -168,21 +141,222 @@ class ExchangeExternalSignatures {
runBlocking {
registerAccountAndLogin()
prepareApis()
- getWalletDefaultGeneratedParams()
-// initializeWallet()
- issueCredentialToWallet()
+ cleanWallet()
}
}
... | nitpicking alert!
perhaps typo for 'should be'? |
waltid-identity | github_2023 | others | 689 | walt-id | mikeplotean | @@ -99,3 +96,21 @@ data class IssuanceRequest(
data class IssuerOnboardingResponse(
val issuerKey: JsonElement, val issuerDid: String,
)
+
+fun validateIssuanceRequest(request: IssuanceRequest): Pair<HttpStatusCode, String> { | I'd move this to IssuanceRequest object, e.g.:
```kotlin
@Serializable
data class IssuanceRequest(
val issuerKey: JsonObject,
val issuerDid: String,
val credentialConfigurationId: String,
val credentialData: W3CVC?,
val mdocData: Map<String, JsonObject>? = null,
val mapping: JsonObject?... |
waltid-identity | github_2023 | others | 689 | walt-id | mikeplotean | @@ -22,3 +24,15 @@ data class OnboardingRequest(
method = "jwk"
)
)
+
+fun validateOnboardingRequest(request: OnboardingRequest) { | would do the same thing as for IssuanceRequest:
```kotlin
@Serializable
data class OnboardingRequest(
val key: KeyGenerationRequest = KeyGenerationRequest(
backend = "jwk",
keyType = KeyType.Ed25519
),
val did: OnboardRequestDid = OnboardRequestDid(
method = "jwk"
)
... |
waltid-identity | github_2023 | others | 689 | walt-id | mikeplotean | @@ -198,219 +215,288 @@ fun Application.issuerApi() {
)
}
}
+ "400" to {
+ description = "Bad request"
+ }
}
... | these try/catch blocks could be improved
e.g. have a `validateRawSignRequest` for validating the input
```kotlin
fun validateRawSignRequest(json: JsonObject){
requireNotNull(json["issuerKey"]?.jsonObject) { "Missing issuerKey in the request body." }
requireNotNull(json["subjectDid"]?.jsonPrimitive?.content... |
waltid-identity | github_2023 | others | 689 | walt-id | alegomes | @@ -103,3 +104,24 @@ data class IssuanceRequest(
data class IssuerOnboardingResponse(
val issuerKey: JsonElement, val issuerDid: String,
)
+
+fun validateIssuanceRequest(request: IssuanceRequest): Pair<HttpStatusCode, String?> {
+ request.credentialData?.let {
+ require(it.isNotEmpty()) {
+ ... | What if the full field name was specified in the message? I mean, instead of "Credential is required", something like "Property credentialData expected in the request body". |
waltid-identity | github_2023 | others | 689 | walt-id | alegomes | @@ -221,26 +237,61 @@ fun Application.issuerApi() {
)
}
}
+ "400" to {
+ description = "Bad request"
+ }
}
... | Look how this message is much more specific than the one at line 121 ("Issuer key must not be empty") |
waltid-identity | github_2023 | others | 689 | walt-id | alegomes | @@ -221,26 +237,61 @@ fun Application.issuerApi() {
)
}
}
+ "400" to {
+ description = "Bad request" | That's all we can provide? Any more detail? |
waltid-identity | github_2023 | others | 689 | walt-id | alegomes | @@ -221,26 +237,61 @@ fun Application.issuerApi() {
)
}
}
+ "400" to {
+ description = "Bad request"
+ }
}
... | That's what I was talking about in the comment I left for line 111. |
waltid-identity | github_2023 | others | 689 | walt-id | alegomes | @@ -285,14 +336,28 @@ fun Application.issuerApi() {
}
}
}
+ "400" to {
+ description =
+ "Bad request - The request could not be... | Will it be complemented later in the code flow with more informations? |
waltid-identity | github_2023 | others | 689 | walt-id | alegomes | @@ -449,3 +527,23 @@ fun Application.issuerApi() {
}
}
}
+
+private suspend fun PipelineContext<Unit, ApplicationCall>.throwError(
+ it: Throwable
+) {
+ when (it) {
+ is BadRequestException -> context.respond(HttpStatusCode.BadRequest, it.message ?: "Bad request.")
+ is JedisConnecti... | What if we include the address it tried to use to connect? |
waltid-identity | github_2023 | others | 689 | walt-id | alegomes | @@ -449,3 +527,23 @@ fun Application.issuerApi() {
}
}
}
+
+private suspend fun PipelineContext<Unit, ApplicationCall>.throwError(
+ it: Throwable
+) {
+ when (it) {
+ is BadRequestException -> context.respond(HttpStatusCode.BadRequest, it.message ?: "Bad request.")
+ is JedisConnecti... | I imagine a scenario in which the user sets up the access credentials in the wrong place. For them, the credentials are correct but, as the system is looking elsewhere, they may not understand why the error occurred.
So, my first reaction would be to suggest including the username and password that was used here in ... |
waltid-identity | github_2023 | others | 689 | walt-id | alegomes | @@ -449,3 +527,23 @@ fun Application.issuerApi() {
}
}
}
+
+private suspend fun PipelineContext<Unit, ApplicationCall>.throwError(
+ it: Throwable
+) {
+ when (it) {
+ is BadRequestException -> context.respond(HttpStatusCode.BadRequest, it.message ?: "Bad request.")
+ is JedisConnecti... | Nothing else that could be included? |
waltid-identity | github_2023 | others | 689 | walt-id | alegomes | @@ -22,3 +24,15 @@ data class OnboardingRequest(
method = "jwk"
)
)
+
+fun validateOnboardingRequest(request: OnboardingRequest) {
+ require(request.key.backend.isNotEmpty()) {
+ throw WebException(HttpStatusCode.BadRequest, "Key backend must not be empty") | I would go for the property name. "Missing property X" or "Property x in the request body cannot be empty" |
waltid-identity | github_2023 | others | 720 | walt-id | SuperBatata | @@ -24,13 +26,20 @@ data class IssuerDataTransferObject(
)
companion object {
- fun default(wallet: UUID) = IssuerDataTransferObject(
- wallet = wallet,
- did = "did:web:walt.id",
- description = "walt.id issuer portal",
- uiEndpoint = "https://portal.walt.... | avoid using the (!!) operator , it can lead to `NullPointerException` if the value is null. Instead, we can use safe calls `(?.)` or providing default values |
waltid-identity | github_2023 | others | 720 | walt-id | SuperBatata | @@ -24,13 +26,20 @@ data class IssuerDataTransferObject(
)
companion object {
- fun default(wallet: UUID) = IssuerDataTransferObject(
- wallet = wallet,
- did = "did:web:walt.id",
- description = "walt.id issuer portal",
- uiEndpoint = "https://portal.walt.... | maybe simplify the null check you can use the let function to handle the non null case more cleanly |
waltid-identity | github_2023 | others | 720 | walt-id | SuperBatata | @@ -29,7 +29,10 @@ object AccountsService {
WalletServiceManager.createWallet(tenant, registeredUserId)
}.also { walletId ->
//TODO: inject
- WalletServiceManager.issuerUseCase.add(IssuerDataTransferObject.default(walletId))
+ val issuer = Iss... | you can use the safe call operator (?.) to simplify the null check and avoid the explicit if statement |
waltid-identity | github_2023 | others | 720 | walt-id | SuperBatata | @@ -49,12 +49,13 @@ class IssuerUseCaseImpl(
}
private suspend fun fetchCredentials(url: String): List<CredentialDataTransferObject> =
- fetchConfiguration(url).jsonObject["credentials_supported"]!!.jsonArray.map {
- CredentialDataTransferObject(id = it.jsonObject["id"]!!.jsonPrimitive... | use safe calls (?.) combined with an ?: operator to provide default values or handle errors |
waltid-identity | github_2023 | others | 720 | walt-id | SuperBatata | @@ -49,12 +49,13 @@ class IssuerUseCaseImpl(
}
private suspend fun fetchCredentials(url: String): List<CredentialDataTransferObject> =
- fetchConfiguration(url).jsonObject["credentials_supported"]!!.jsonArray.map {
- CredentialDataTransferObject(id = it.jsonObject["id"]!!.jsonPrimitive... | same as above |
waltid-identity | github_2023 | others | 723 | walt-id | mikeplotean | @@ -0,0 +1,267 @@
+import E2ETestWebService.loadResource
+import id.walt.commons.web.plugins.httpJson
+import id.walt.crypto.keys.jwk.JWKKey
+import id.walt.did.utils.randomUUID
+import id.walt.issuer.issuance.IssuanceRequest
+import id.walt.webwallet.db.models.WalletCredential
+import id.walt.webwallet.db.models.Walle... | ide suggests it could be val |
waltid-identity | github_2023 | others | 723 | walt-id | mikeplotean | @@ -0,0 +1,267 @@
+import E2ETestWebService.loadResource
+import id.walt.commons.web.plugins.httpJson
+import id.walt.crypto.keys.jwk.JWKKey
+import id.walt.did.utils.randomUUID
+import id.walt.issuer.issuance.IssuanceRequest
+import id.walt.webwallet.db.models.WalletCredential
+import id.walt.webwallet.db.models.Walle... | maybe the comment could be translated / replaced? |
waltid-identity | github_2023 | others | 723 | walt-id | mikeplotean | @@ -0,0 +1,267 @@
+import E2ETestWebService.loadResource
+import id.walt.commons.web.plugins.httpJson
+import id.walt.crypto.keys.jwk.JWKKey
+import id.walt.did.utils.randomUUID
+import id.walt.issuer.issuance.IssuanceRequest
+import id.walt.webwallet.db.models.WalletCredential
+import id.walt.webwallet.db.models.Walle... | couldn't the version from E2E file be used, so to avoid duplicates?
e.g. move it out of E2E class or have it static |
waltid-identity | github_2023 | others | 723 | walt-id | mikeplotean | @@ -0,0 +1,267 @@
+import E2ETestWebService.loadResource
+import id.walt.commons.web.plugins.httpJson
+import id.walt.crypto.keys.jwk.JWKKey
+import id.walt.did.utils.randomUUID
+import id.walt.issuer.issuance.IssuanceRequest
+import id.walt.webwallet.db.models.WalletCredential
+import id.walt.webwallet.db.models.Walle... | just noticed, this is also checked in E2E tests
but it enforces the number of policies to be at least 2
wondering if it's intended |
waltid-identity | github_2023 | others | 723 | walt-id | mikeplotean | @@ -0,0 +1,18 @@
+package id.walt.webwallet.service.oidc4vc
+
+import id.walt.oid4vc.data.CredentialFormat
+import id.walt.webwallet.db.models.WalletCredential
+
+object CredentialFilterUtils { | since it's a utils, maybe it could be move to the [utils](https://github.com/walt-id/waltid-identity/tree/main/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/utils) package |
waltid-identity | github_2023 | others | 723 | walt-id | mikeplotean | @@ -0,0 +1,398 @@
+package id.walt.webwallet.web.controllers.exchange
+
+import com.nimbusds.jose.jwk.JWK
+import com.nimbusds.jose.jwk.KeyUse
+import com.nimbusds.jose.util.Base64URL
+import id.walt.crypto.keys.KeyGenerationRequest
+import id.walt.crypto.keys.KeyManager
+import id.walt.crypto.keys.KeyType
+import id.w... | could be moved to 'global' context, e.g.
```kotlin
fun Application.exchangeExternalSignatures() = walletRoute {
val logger = KotlinLogging.logger { }
//...
}
``` |
waltid-identity | github_2023 | others | 723 | walt-id | mikeplotean | @@ -0,0 +1,398 @@
+package id.walt.webwallet.web.controllers.exchange
+
+import com.nimbusds.jose.jwk.JWK
+import com.nimbusds.jose.jwk.KeyUse
+import com.nimbusds.jose.util.Base64URL
+import id.walt.crypto.keys.KeyGenerationRequest
+import id.walt.crypto.keys.KeyManager
+import id.walt.crypto.keys.KeyType
+import id.w... | perhaps cleanup and have a ticket for it to implement event logging for external-signature endpoints |
waltid-identity | github_2023 | others | 723 | walt-id | mikeplotean | @@ -66,5 +72,6 @@ object FeatureCatalog : ServiceFeatureCatalog {
runtimeMockFeature,
didWebRegistry,
x5cAuthFeature, | just wondering if there are use cases where only one of these features is used
would it make sense to combine them into single feature that would activate both the auth and the exchange endpoints? |
waltid-identity | github_2023 | others | 610 | walt-id | severinstampler | @@ -108,43 +112,104 @@ object OidcApi : CIProvider() {
get("/authorize") {
val authReq = runBlocking { AuthorizationRequest.fromHttpParametersAuto(call.parameters.toMap()) }
try {
- val authResp = if (authReq.responseType.contains(ResponseType.Code)) {
-... | Could be improved with sub functions for when-cases, for better readability |
waltid-identity | github_2023 | others | 610 | walt-id | severinstampler | @@ -612,6 +614,1065 @@ class CI_JVM_Test {
assertTrue(actual = JwtSignaturePolicy().verify(credential, null, mapOf()).isSuccess)
}
+ // Test case for available authentication methods are: NONE, ID_TOKEN, VP_TOKEN, PRE_AUTHORIZED PWD(Handled by third party authorization server)
+ @Test
+ fun tes... | test is about 500 lines long, maybe split into multiple tests? |
waltid-identity | github_2023 | others | 610 | walt-id | severinstampler | @@ -612,6 +614,1065 @@ class CI_JVM_Test {
assertTrue(actual = JwtSignaturePolicy().verify(credential, null, mapOf()).isSuccess)
}
+ // Test case for available authentication methods are: NONE, ID_TOKEN, VP_TOKEN, PRE_AUTHORIZED PWD(Handled by third party authorization server)
+ @Test
+ fun tes... | Can commented code be cleaned up? |
waltid-identity | github_2023 | others | 610 | walt-id | cpatsonakis | @@ -26,7 +27,12 @@ suspend fun createCredentialOfferUri(issuanceRequests: List<IssuanceRequest>): S
OidcIssuance.issuanceRequestsToCredentialOfferBuilder(issuanceRequests)
val issuanceSession = OidcApi.initializeCredentialOffer(
- credentialOfferBuilder = credentialOfferBuilder, expiresIn = 5.min... | This is a reasonable default expiration value, however, the client has no control. Perhaps we should consider adding an optional parameter with this as a default value? |
waltid-identity | github_2023 | others | 716 | walt-id | waltkb | @@ -115,15 +120,23 @@ class AndroidKey() : Key() {
}
override suspend fun signJws(plaintext: ByteArray, headers: Map<String, JsonElement>): String {
- val signature: ByteArray = signWithKeystore(plaintext)
+ val signingInput = base64Url.encode(
+ Json.encodeToString(headers).toByteA... | use helper function here |
waltid-identity | github_2023 | others | 716 | walt-id | waltkb | @@ -115,15 +120,23 @@ class AndroidKey() : Key() {
}
override suspend fun signJws(plaintext: ByteArray, headers: Map<String, JsonElement>): String {
- val signature: ByteArray = signWithKeystore(plaintext)
+ val signingInput = base64Url.encode(
+ Json.encodeToString(headers).toByteA... | use helper function here |
waltid-identity | github_2023 | others | 716 | walt-id | waltkb | @@ -115,15 +120,23 @@ class AndroidKey() : Key() {
}
override suspend fun signJws(plaintext: ByteArray, headers: Map<String, JsonElement>): String {
- val signature: ByteArray = signWithKeystore(plaintext)
+ val signingInput = base64Url.encode(
+ Json.encodeToString(headers).toByteA... | EccUtils.convertDERtoIEEEP1363(derSignature: ByteArray): ByteArray |
waltid-identity | github_2023 | others | 698 | walt-id | SuperBatata | @@ -4,6 +4,7 @@ VERIFIER_API_PORT=7003
WALLET_FRONTEND_PORT=7101 | Maybe rename it to `DEMO_WALLET_FRONTEND_PORT` for consistency |
waltid-identity | github_2023 | others | 698 | walt-id | SuperBatata | @@ -0,0 +1,207 @@
+<template>
+ <div class="flex flex-col items-center">
+ <!-- <div v-if="videoStarted && noError">
+ <div class="inline-flex flex-row justify-between gap-3 p-2">
+ <WaltButton :icon="ChevronUpDownIcon"> Choose camera </WaltButton>
+ <WaltButton :icon=... | Remove commented code if not needed |
waltid-identity | github_2023 | others | 664 | walt-id | waltkb | @@ -14,7 +14,9 @@ object Base64Utils {
fun ByteArray.encodeToBase64Url() = Base64.UrlSafe.encode(this).trimEnd('=')
- fun String.base64UrlDecode() = Base64.UrlSafe.decode(this)
+ fun String.base64UrlDecode()= base64.decode(this) | base64 != base64url |
waltid-identity | github_2023 | others | 664 | walt-id | waltkb | @@ -14,7 +14,9 @@ object Base64Utils {
fun ByteArray.encodeToBase64Url() = Base64.UrlSafe.encode(this).trimEnd('=')
- fun String.base64UrlDecode() = Base64.UrlSafe.decode(this)
+ fun String.base64UrlDecode()= base64.decode(this)
fun String.base64Decode() = Base64.decode(this)
+
+ val base64 = B... | make `val base64` and `val base64url` |
waltid-identity | github_2023 | others | 634 | walt-id | mikeplotean | @@ -1,11 +1,28 @@
package id.walt.webwallet.service.oidc4vc | this file could use some formatting |
waltid-identity | github_2023 | others | 634 | walt-id | mikeplotean | @@ -148,66 +205,96 @@ class TestCredentialWallet(
println("Matched credentials: $matchedCredentials")
println("Using disclosures: $selectedDisclosures")
+ val key = runBlocking {
+ runCatching {
+ DidService.resolveToKey(did).getOrThrow().let { KeysService.get(it.get... | ide suggests to use `isNotEmpty()` |
waltid-identity | github_2023 | others | 634 | walt-id | mikeplotean | @@ -76,7 +96,7 @@ class TestCredentialWallet(
// val key = runBlocking { walletService.getKeyByDid(keyId) }
val key = runBlocking {
runCatching {
- DidService.resolveToKey(keyId).getOrThrow().let { KeysService.get(it.getKeyId()) }?.let {
+ KeysService.get(if(D... | this looks somewhat similar to the block from `signCWTToken`
maybe it can be extracted into a separate private method, e.g.
```kotlin
private suspend fun tryResolveKeyId(keyId: String) = runCatching {
val kid = keyId.takeIf { DidUtils.isDidUrl(it) }?.let {
DidService.resolveToKey(it).getOrThrow().getKe... |
waltid-identity | github_2023 | others | 634 | walt-id | mikeplotean | @@ -87,12 +107,45 @@ class TestCredentialWallet(
val authKeyId = resolveDidAuthentication(did)
val payloadToSign = Json.encodeToString(payload).encodeToByteArray()
- key.signJws(payloadToSign, mapOf("typ" to "JWT", "kid" to authKeyId))
+ val headersToSign = mapOf("typ" ... | and this would become, e.g.
```kotlin
val key = privKey ?: keyId?.let { tryResolveKeyId(it) }
``` |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.