Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Epic VDR phase 3 branch #1245

Closed
wants to merge 32 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
f1565ac
Empty comit to epic branch
Jul 2, 2024
cf940c4
feat: change all resource URLs in VCs from http URLs to DID URLs (#1249)
Jul 16, 2024
e6693c6
fix: Move InMemory classes to the test moduels (#1240)
FabioPinheiro Jul 4, 2024
bbc9629
feat: upgrade docusaurus and semantic-release packages
yshyn-iohk Jul 8, 2024
a80ffab
fix: Wallet Management Error Handling (#1248)
CryptoKnightIOG Jul 5, 2024
438e1a6
fix: use Put and Get for DID in doobie statement (#1250)
Jul 5, 2024
ebc19cc
test: e2e test for oid4vci authorization code flow (#1252)
Jul 8, 2024
599becb
chore: update codeowners files [skip ci] (#1255)
yshyn-iohk Jul 10, 2024
58e3302
chore: update CODEOWNERS to have identus-maintainers team only [skip-…
yshyn-iohk Jul 11, 2024
ecf671a
docs: add local stack examples [skip ci] (#939)
Jul 12, 2024
46508fa
build: make sure -Dquill.macro.log=false is passed when quill compile…
Jul 12, 2024
d10507b
test: add sd-jwt integration test (#1260)
amagyar-iohk Jul 15, 2024
601ee43
chore(release): cut Identus Cloud agent 1.38.0 release
hyperledger-bot Jul 15, 2024
f07809d
fix: add reportProcessingFailure back in PresentationRepository (#1232)
FabioPinheiro Jul 16, 2024
ff2d9b6
docs: oid4vci example and docs [skip ci] (#1265)
Jul 16, 2024
2ca47d6
Merge branch 'main' into ATL-6543-epic-vdr-phase-3
Jul 17, 2024
4a024cc
feat: add implementation for DID url resolver (#1267)
Jul 19, 2024
b138825
Merge branch 'main' into ATL-6543-epic-vdr-phase-3
Jul 19, 2024
34626d0
Merge branch 'main' into ATL-6543-epic-vdr-phase-3
Aug 1, 2024
0a7579e
Merge branch 'main' into ATL-6543-epic-vdr-phase-3
Aug 5, 2024
f78596f
feat(pollux): update storage for static resources to be wrapped in an…
Sep 9, 2024
cda60eb
Merge branch 'main' into ATL-6543-epic-vdr-phase-3
Sep 12, 2024
cf595c8
Merge branch 'main' into ATL-6543-epic-vdr-phase-3
Sep 12, 2024
c9ef4f3
Format
Sep 12, 2024
2fb5020
Merge branch 'main' into ATL-6543-epic-vdr-phase-3
Sep 14, 2024
ecde01d
feat: add base url services to DID (#1358)
Sep 19, 2024
8f2d9a9
Merge branch 'main' into ATL-6543-epic-vdr-phase-3
Sep 19, 2024
2a0b369
format
Sep 19, 2024
63c8160
Merge branch 'main' into ATL-6543-epic-vdr-phase-3
Sep 23, 2024
5c984ee
Merge branch 'main' into ATL-6543-epic-vdr-phase-3
Sep 24, 2024
d69e35e
fix: OAS and http clients for Kotliln and TypeScript (#1375)
yshyn-iohk Sep 26, 2024
b59ce50
Merge branch 'main' into ATL-6543-epic-vdr-phase-3
Sep 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .sbtopts
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
-Dquill.macro.log=false
-J-Xmx4G
-J-XX:+UseG1GC
12 changes: 11 additions & 1 deletion cloud-agent/client/kotlin/.openapi-generator-ignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ settings.gradle
build.gradle
docs

# igore broken files
# ignore broken files

src/main/kotlin/org/hyperledger/identus/client/models/UpdateManagedDIDServiceAction.kt
src/main/kotlin/org/hyperledger/identus/client/models/UpdateManagedDIDServiceActionType.kt

Expand All @@ -15,3 +16,12 @@ src/main/kotlin/org/hyperledger/identus/client/models/CredentialSubject.kt
src/main/kotlin/org/hyperledger/identus/client/models/DateTimeParameter.kt
src/main/kotlin/org/hyperledger/identus/client/models/DidParameter.kt
src/main/kotlin/org/hyperledger/identus/client/models/VcVerificationParameter.kt

src/test/kotlin/org/hyperledger/identus/client/models/UpdateManagedDIDServiceActionTest.kt
src/test/kotlin/org/hyperledger/identus/client/models/UpdateManagedDIDServiceActionTypeTest.kt

src/test/kotlin/org/hyperledger/identus/client/models/ServiceTest.kt
src/test/kotlin/org/hyperledger/identus/client/models/ServiceTypeTest.kt

src/test/kotlin/org/hyperledger/identus/client/models/StatusPurposeTest.kt
src/test/kotlin/org/hyperledger/identus/client/models/CredentialSubjectTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,52 @@
"ArrayInDataClass",
"EnumEntryName",
"RemoveRedundantQualifierName",
"UnusedImport"
"UnusedImport",
)

package org.hyperledger.identus.client.models

import org.hyperledger.identus.client.models.Json

import com.google.gson.*
import com.google.gson.annotations.JsonAdapter
import com.google.gson.annotations.SerializedName

/**
* A service expressed in the DID document. https://www.w3.org/TR/did-core/#services
*
* @param id The id of the service. Requires a URI fragment when use in create / update DID. Returns the full ID (with DID prefix) when resolving DID
* @param type
* @param serviceEndpoint
*/


data class Service (
import java.lang.reflect.Type

class StringOrStringArrayAdapter : JsonSerializer<List<String>>, JsonDeserializer<List<String>> {

// Deserialize logic: String or Array of Strings to List<String>
override fun deserialize(json: JsonElement?, typeOfT: Type?, context: JsonDeserializationContext?): List<String> {
return when {
json?.isJsonArray == true -> {
context!!.deserialize(json, typeOfT)
}
json?.isJsonPrimitive == true -> {
listOf(json.asString)
}
else -> throw JsonParseException("Unexpected type for field")
}
}

// Serialize logic: List<String> to String or Array of Strings
override fun serialize(src: List<String>?, typeOfSrc: Type?, context: JsonSerializationContext?): JsonElement {
return when {
src == null -> JsonNull.INSTANCE
src.size == 1 -> JsonPrimitive(src[0]) // If only one string, serialize as a single string
else -> context!!.serialize(src) // Otherwise, serialize as a list
}
}
}

data class Service(

/* The id of the service. Requires a URI fragment when use in create / update DID. Returns the full ID (with DID prefix) when resolving DID */
@SerializedName("id")
val id: kotlin.String,

@SerializedName("type")
@JsonAdapter(StringOrStringArrayAdapter::class)
val type: kotlin.collections.List<kotlin.String>? = null,

@SerializedName("serviceEndpoint")
val serviceEndpoint: Json
val serviceEndpoint: JsonElement? = null,

)

Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,23 @@
"ArrayInDataClass",
"EnumEntryName",
"RemoveRedundantQualifierName",
"UnusedImport"
"UnusedImport",
)

package org.hyperledger.identus.client.models

import org.hyperledger.identus.client.models.Json

import com.google.gson.JsonElement
import com.google.gson.annotations.SerializedName

/**
* A patch to existing Service. 'type' and 'serviceEndpoint' cannot both be empty.
*
* @param id The id of the service to update
* @param type
* @param serviceEndpoint
* @param type
* @param serviceEndpoint
*/


data class UpdateManagedDIDServiceAction (
data class UpdateManagedDIDServiceAction(

/* The id of the service to update */
@SerializedName("id")
Expand All @@ -38,7 +36,6 @@ data class UpdateManagedDIDServiceAction (
val type: kotlin.collections.List<kotlin.String>? = null,

@SerializedName("serviceEndpoint")
val serviceEndpoint: Json? = null
val serviceEndpoint: JsonElement? = null,

)

16 changes: 1 addition & 15 deletions cloud-agent/client/typescript/models/Service.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,3 @@
/**
* Prism Agent
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* OpenAPI spec version: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/

import { Json } from '../models/Json';

/**
* A service expressed in the DID document. https://www.w3.org/TR/did-core/#services
*/
Expand All @@ -21,7 +7,7 @@ export class Service {
*/
'id': string;
'type': Array<string>;
'serviceEndpoint': Json;
'serviceEndpoint': string | Array<string> | object;

static readonly discriminator: string | undefined = undefined;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,3 @@
/**
* Prism Agent
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* OpenAPI spec version: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/

import { Json } from '../models/Json';

/**
* A patch to existing Service. \'type\' and \'serviceEndpoint\' cannot both be empty.
*/
Expand All @@ -21,7 +7,7 @@ export class UpdateManagedDIDServiceAction {
*/
'id': string;
'type'?: Array<string>;
'serviceEndpoint'?: Json;
'serviceEndpoint'?: string | Array<string> | object;

static readonly discriminator: string | undefined = undefined;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ agent {
port = 8085
port =${?AGENT_HTTP_PORT}
}
serviceName = "agent-base-url"
publicEndpointUrl = "https://host.docker.internal:8080/cloud-agent"
publicEndpointUrl = ${?REST_SERVICE_URL}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import org.hyperledger.identus.pollux.prex.PresentationExchangeServerEndpoints
import org.hyperledger.identus.pollux.vc.jwt.DidResolver as JwtDidResolver
import org.hyperledger.identus.presentproof.controller.PresentProofServerEndpoints
import org.hyperledger.identus.resolvers.DIDResolver
import org.hyperledger.identus.shared.http.UriResolver
import org.hyperledger.identus.shared.models.{HexString, WalletAccessContext, WalletAdministrationContext, WalletId}
import org.hyperledger.identus.shared.utils.DurationOps.toMetricsSeconds
import org.hyperledger.identus.system.controller.SystemServerEndpoints
Expand Down Expand Up @@ -68,8 +69,8 @@ object CloudAgentApp {
} yield ()

private val presentProofExchangeJob: RIO[
AppConfig & DidOps & DIDResolver & JwtDidResolver & HttpClient & PresentationService & CredentialService &
DIDNonSecretStorage & DIDService & ManagedDIDService,
AppConfig & DidOps & UriResolver & DIDResolver & JwtDidResolver & HttpClient & PresentationService &
CredentialService & DIDNonSecretStorage & DIDService & ManagedDIDService,
Unit
] =
for {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ trait ControllerHelper {
protected def extractPrismDIDFromString(maybeDid: String): IO[ErrorResponse, PrismDID] =
ZIO
.fromEither(PrismDID.fromString(maybeDid))
.mapError(e => ErrorResponse.badRequest(detail = Some(s"Error parsing string as PrismDID: ${e}")))
.mapError(e => ErrorResponse.badRequest(detail = Some(s"Error parsing string as PrismDID: $e")))

protected def getLongFormPrismDID(
did: PrismDID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ import org.hyperledger.identus.agent.walletapi.sql.{
}
import org.hyperledger.identus.agent.walletapi.storage.GenericSecretStorage
import org.hyperledger.identus.castor.controller.{DIDControllerImpl, DIDRegistrarControllerImpl}
import org.hyperledger.identus.castor.core.model.did.{
Service as DidDocumentService,
ServiceEndpoint as DidDocumentServiceEndpoint,
ServiceType as DidDocumentServiceType
}
import org.hyperledger.identus.castor.core.service.DIDServiceImpl
import org.hyperledger.identus.castor.core.util.DIDOperationValidator
import org.hyperledger.identus.connect.controller.ConnectionControllerImpl
Expand Down Expand Up @@ -142,6 +147,24 @@ object MainApp extends ZIOAppDefault {
|""".stripMargin)
.ignore

appConfig <- ZIO.service[AppConfig].provide(SystemModule.configLayer)
// these services are added to any DID document by default when they are created.
defaultDidDocumentServices = Set(
DidDocumentService(
id = appConfig.agent.httpEndpoint.serviceName,
serviceEndpoint = DidDocumentServiceEndpoint
.Single(
DidDocumentServiceEndpoint.UriOrJsonEndpoint
.Uri(
DidDocumentServiceEndpoint.UriValue
.fromString(appConfig.agent.httpEndpoint.publicEndpointUrl.toString)
.toOption
.get // This will fail if URL is invalid, which will prevent app from starting since public endpoint in config is invalid
)
),
`type` = DidDocumentServiceType.Single(DidDocumentServiceType.Name.fromStringUnsafe("LinkedResourceV1"))
)
)
_ <- preMigrations
_ <- migrations

Expand Down Expand Up @@ -178,7 +201,7 @@ object MainApp extends ZIOAppDefault {
AppModule.didJwtResolverLayer,
DIDOperationValidator.layer(),
DIDResolver.layer,
HttpURIDereferencerImpl.layer,
GenericUriResolverImpl.layer,
PresentationDefinitionValidatorImpl.layer,
// service
ConnectionServiceImpl.layer >>> ConnectionServiceNotifier.layer,
Expand All @@ -188,7 +211,7 @@ object MainApp extends ZIOAppDefault {
LinkSecretServiceImpl.layer >>> CredentialServiceImpl.layer >>> CredentialServiceNotifier.layer,
DIDServiceImpl.layer,
EntityServiceImpl.layer,
ManagedDIDServiceWithEventNotificationImpl.layer,
ZLayer.succeed(defaultDidDocumentServices) >>> ManagedDIDServiceWithEventNotificationImpl.layer,
LinkSecretServiceImpl.layer >>> PresentationServiceImpl.layer >>> PresentationServiceNotifier.layer,
VerificationPolicyServiceImpl.layer,
WalletManagementServiceImpl.layer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ final case class DatabaseConfig(
DbConfig(
username = if (appUser) appUsername else username,
password = if (appUser) appPassword else password,
jdbcUrl = s"jdbc:postgresql://${host}:${port}/${databaseName}",
jdbcUrl = s"jdbc:postgresql://$host:$port/${databaseName}",
awaitConnectionThreads = awaitConnectionThreads
)
}
Expand Down Expand Up @@ -187,7 +187,7 @@ final case class AgentConfig(

}

final case class HttpEndpointConfig(http: HttpConfig, publicEndpointUrl: java.net.URL)
final case class HttpEndpointConfig(http: HttpConfig, serviceName: String, publicEndpointUrl: java.net.URL)

final case class DidCommEndpointConfig(http: HttpConfig, publicEndpointUrl: java.net.URL)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ object PresentBackgroundJobs extends BackgroundJobsHelper {
/*DIDSecretStorageError | PresentationError | CredentialServiceError | BackgroundJobError | TransportError | */
CastorDIDResolutionError | GetManagedDIDError | Failure

private type RESOURCES = COMMON_RESOURCES & CredentialService & JwtDidResolver & DIDService & AppConfig &
MESSAGING_RESOURCES
private type RESOURCES = COMMON_RESOURCES & CredentialService & JwtDidResolver & UriResolver & DIDService &
AppConfig & MESSAGING_RESOURCES

private type COMMON_RESOURCES = PresentationService & DIDNonSecretStorage & ManagedDIDService

Expand Down Expand Up @@ -1035,7 +1035,7 @@ object PresentBackgroundJobs extends BackgroundJobsHelper {
credentialFormat: CredentialFormat,
invitation: Option[Invitation]
): ZIO[
AppConfig & JwtDidResolver & COMMON_RESOURCES & MESSAGING_RESOURCES,
AppConfig & JwtDidResolver & UriResolver & COMMON_RESOURCES & MESSAGING_RESOURCES,
Failure,
Unit
] = {
Expand Down Expand Up @@ -1069,7 +1069,7 @@ object PresentBackgroundJobs extends BackgroundJobsHelper {
presentation: Presentation,
invitation: Option[Invitation]
): ZIO[
AppConfig & JwtDidResolver & COMMON_RESOURCES & MESSAGING_RESOURCES,
AppConfig & JwtDidResolver & UriResolver & COMMON_RESOURCES & MESSAGING_RESOURCES,
Failure,
Unit
] = {
Expand Down Expand Up @@ -1114,28 +1114,12 @@ object PresentBackgroundJobs extends BackgroundJobsHelper {
// https://www.w3.org/TR/vc-data-model/#proofs-signatures-0
// A proof is typically attached to a verifiable presentation for authentication purposes
// and to a verifiable credential as a method of assertion.
httpLayer <- ZIO.service[HttpClient]
httpUrlResolver = new UriResolver {
override def resolve(uri: String): IO[GenericUriResolverError, String] = {
val res = HttpClient
.get(uri)
.map(x => x.bodyAsString)
.provideSomeLayer(ZLayer.succeed(httpLayer))
res.mapError(err => SchemaSpecificResolutionError("http", err))
}
}
genericUriResolver = GenericUriResolver(
Map(
"data" -> DataUrlResolver(),
"http" -> httpUrlResolver,
"https" -> httpUrlResolver
)
)
uriResolver <- ZIO.service[UriResolver]
result <- JwtPresentation
.verify(
JWT(base64Decoded),
verificationConfig.toPresentationVerificationOptions()
)(didResolverService, genericUriResolver)(clock)
)(didResolverService, uriResolver)(clock)
.mapError(error => PresentationError.PresentationVerificationError(error.mkString))
} yield result

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,13 @@ object ServiceType {
case Single(value) => Left(value)
case Multiple(values) => Right(values.toArray)
}
given decoder: JsonDecoder[ServiceType] = JsonDecoder.string
.orElseEither(JsonDecoder.array[String])
.map[ServiceType] {
case Left(value) => Single(value)
case Right(values) => Multiple(values.toSeq)
}

given decoder: JsonDecoder[ServiceType] = JsonDecoder[String]
.map(Single.apply)
.orElse(
JsonDecoder[Seq[String]].map(Multiple.apply)
)

given schema: Schema[ServiceType] = Schema
.schemaForEither(Schema.schemaForString, Schema.schemaForArray[String])
.map[ServiceType] {
Expand Down
Loading
Loading