diff --git a/connect/lib/core/src/main/scala/io/iohk/atala/connect/core/model/ConnectionRecord.scala b/connect/lib/core/src/main/scala/io/iohk/atala/connect/core/model/ConnectionRecord.scala index b2c7964664..3a91d8ef26 100644 --- a/connect/lib/core/src/main/scala/io/iohk/atala/connect/core/model/ConnectionRecord.scala +++ b/connect/lib/core/src/main/scala/io/iohk/atala/connect/core/model/ConnectionRecord.scala @@ -13,6 +13,8 @@ import java.util.UUID * @param updatedAt * @param thid * @param label + * @param goalCode + * @param goal * @param role * @param protocolState * @param invitation @@ -31,6 +33,8 @@ case class ConnectionRecord( updatedAt: Option[Instant], thid: String, label: Option[String], + goalCode: Option[String], + goal: Option[String], role: Role, protocolState: ProtocolState, invitation: Invitation, diff --git a/connect/lib/core/src/main/scala/io/iohk/atala/connect/core/service/ConnectionService.scala b/connect/lib/core/src/main/scala/io/iohk/atala/connect/core/service/ConnectionService.scala index de7e9e387b..01d4c56184 100644 --- a/connect/lib/core/src/main/scala/io/iohk/atala/connect/core/service/ConnectionService.scala +++ b/connect/lib/core/src/main/scala/io/iohk/atala/connect/core/service/ConnectionService.scala @@ -14,6 +14,8 @@ trait ConnectionService { def createConnectionInvitation( label: Option[String], + goalCode: Option[String], + goal: Option[String], pairwiseDID: DidId ): ZIO[WalletAccessContext, ConnectionServiceError, ConnectionRecord] diff --git a/connect/lib/core/src/main/scala/io/iohk/atala/connect/core/service/ConnectionServiceImpl.scala b/connect/lib/core/src/main/scala/io/iohk/atala/connect/core/service/ConnectionServiceImpl.scala index 0cf609b5b9..1ea4ecd0f1 100644 --- a/connect/lib/core/src/main/scala/io/iohk/atala/connect/core/service/ConnectionServiceImpl.scala +++ b/connect/lib/core/src/main/scala/io/iohk/atala/connect/core/service/ConnectionServiceImpl.scala @@ -25,10 +25,12 @@ private class ConnectionServiceImpl( override def createConnectionInvitation( label: Option[String], + goalCode: Option[String], + goal: Option[String], pairwiseDID: DidId ): ZIO[WalletAccessContext, ConnectionServiceError, ConnectionRecord] = for { - invitation <- ZIO.succeed(ConnectionInvitation.makeConnectionInvitation(pairwiseDID)) + invitation <- ZIO.succeed(ConnectionInvitation.makeConnectionInvitation(pairwiseDID, goalCode, goal)) record <- ZIO.succeed( ConnectionRecord( id = UUID.fromString(invitation.id), @@ -36,6 +38,8 @@ private class ConnectionServiceImpl( updatedAt = None, thid = invitation.id, label = label, + goalCode = goalCode, + goal = goal, role = ConnectionRecord.Role.Inviter, protocolState = ConnectionRecord.ProtocolState.InvitationGenerated, invitation = invitation, @@ -129,6 +133,8 @@ private class ConnectionServiceImpl( // TODO: According to the standard, we should rather use 'pthid' and not 'thid' thid = invitation.id, label = None, + goalCode = invitation.body.goal_code, + goal = invitation.body.goal, role = ConnectionRecord.Role.Invitee, protocolState = ConnectionRecord.ProtocolState.InvitationReceived, invitation = invitation, diff --git a/connect/lib/core/src/main/scala/io/iohk/atala/connect/core/service/ConnectionServiceNotifier.scala b/connect/lib/core/src/main/scala/io/iohk/atala/connect/core/service/ConnectionServiceNotifier.scala index a6e26df880..82ef62a0ea 100644 --- a/connect/lib/core/src/main/scala/io/iohk/atala/connect/core/service/ConnectionServiceNotifier.scala +++ b/connect/lib/core/src/main/scala/io/iohk/atala/connect/core/service/ConnectionServiceNotifier.scala @@ -20,9 +20,11 @@ class ConnectionServiceNotifier( override def createConnectionInvitation( label: Option[String], + goalCode: Option[String], + goal: Option[String], pairwiseDID: DidId ): ZIO[WalletAccessContext, ConnectionServiceError, ConnectionRecord] = - notifyOnSuccess(svc.createConnectionInvitation(label, pairwiseDID)) + notifyOnSuccess(svc.createConnectionInvitation(label, goalCode, goal, pairwiseDID)) override def receiveConnectionInvitation( invitation: String diff --git a/connect/lib/core/src/main/scala/io/iohk/atala/connect/core/service/MockConnectionService.scala b/connect/lib/core/src/main/scala/io/iohk/atala/connect/core/service/MockConnectionService.scala index 0403629c39..0c3ed07791 100644 --- a/connect/lib/core/src/main/scala/io/iohk/atala/connect/core/service/MockConnectionService.scala +++ b/connect/lib/core/src/main/scala/io/iohk/atala/connect/core/service/MockConnectionService.scala @@ -12,7 +12,8 @@ import java.util.UUID object MockConnectionService extends Mock[ConnectionService] { - object CreateConnectionInvitation extends Effect[(Option[String], DidId), ConnectionServiceError, ConnectionRecord] + object CreateConnectionInvitation + extends Effect[(Option[String], Option[String], Option[String], DidId), ConnectionServiceError, ConnectionRecord] object ReceiveConnectionInvitation extends Effect[String, ConnectionServiceError, ConnectionRecord] object AcceptConnectionInvitation extends Effect[(UUID, DidId), ConnectionServiceError, ConnectionRecord] object MarkConnectionRequestSent extends Effect[UUID, ConnectionServiceError, ConnectionRecord] @@ -29,9 +30,11 @@ object MockConnectionService extends Mock[ConnectionService] { } yield new ConnectionService { override def createConnectionInvitation( label: Option[String], + goalCode: Option[String], + goal: Option[String], pairwiseDID: DidId ): IO[ConnectionServiceError, ConnectionRecord] = - proxy(CreateConnectionInvitation, label, pairwiseDID) + proxy(CreateConnectionInvitation, label, goalCode, goal, pairwiseDID) override def receiveConnectionInvitation(invitation: String): IO[ConnectionServiceError, ConnectionRecord] = proxy(ReceiveConnectionInvitation, invitation) diff --git a/connect/lib/core/src/test/scala/io/iohk/atala/connect/core/repository/ConnectionRepositorySpecSuite.scala b/connect/lib/core/src/test/scala/io/iohk/atala/connect/core/repository/ConnectionRepositorySpecSuite.scala index d65f963227..20a66adca8 100644 --- a/connect/lib/core/src/test/scala/io/iohk/atala/connect/core/repository/ConnectionRepositorySpecSuite.scala +++ b/connect/lib/core/src/test/scala/io/iohk/atala/connect/core/repository/ConnectionRepositorySpecSuite.scala @@ -24,13 +24,19 @@ object ConnectionRepositorySpecSuite { None, UUID.randomUUID().toString, None, + None, + None, ConnectionRecord.Role.Inviter, ConnectionRecord.ProtocolState.InvitationGenerated, Invitation( id = UUID.randomUUID().toString, from = DidId("did:prism:aaa"), body = Invitation - .Body(goal_code = "io.atalaprism.connect", goal = "Establish a trust connection between two peers", Nil) + .Body( + goal_code = Some("io.atalaprism.connect"), + goal = Some("Establish a trust connection between two peers"), + Nil + ) ), None, None, diff --git a/connect/lib/core/src/test/scala/io/iohk/atala/connect/core/service/ConnectionServiceImplSpec.scala b/connect/lib/core/src/test/scala/io/iohk/atala/connect/core/service/ConnectionServiceImplSpec.scala index 72a756042d..df331dece3 100644 --- a/connect/lib/core/src/test/scala/io/iohk/atala/connect/core/service/ConnectionServiceImplSpec.scala +++ b/connect/lib/core/src/test/scala/io/iohk/atala/connect/core/service/ConnectionServiceImplSpec.scala @@ -26,7 +26,12 @@ object ConnectionServiceImplSpec extends ZIOSpecDefault { for { svc <- ZIO.service[ConnectionService] did = DidId("did:peer:INVITER") - record <- svc.createConnectionInvitation(Some("Test connection invitation"), did) + record <- svc.createConnectionInvitation( + Some("Test connection invitation"), + Some("Test goal code"), + Some("Test goal"), + did + ) } yield { assertTrue(record.label.contains("Test connection invitation")) && assertTrue(record.protocolState == ProtocolState.InvitationGenerated) && @@ -37,7 +42,8 @@ object ConnectionServiceImplSpec extends ZIOSpecDefault { assertTrue(record.updatedAt.isEmpty) && assertTrue(record.invitation.from == did) && assertTrue(record.invitation.attachments.isEmpty) && - assertTrue(record.invitation.body.goal_code == "io.atalaprism.connect") && + assertTrue(record.invitation.body.goal_code == Some("Test goal code")) && + assertTrue(record.invitation.body.goal == Some("Test goal")) && assertTrue(record.invitation.body.accept.isEmpty) } }, { @@ -46,6 +52,8 @@ object ConnectionServiceImplSpec extends ZIOSpecDefault { svc <- ZIO.service[ConnectionService] createdRecord <- svc.createConnectionInvitation( Some("Test connection invitation"), + Some("Test goal code"), + Some("Test goal"), DidId("did:peer:INVITER") ) foundRecord <- svc.getConnectionRecord(createdRecord.id) @@ -61,10 +69,14 @@ object ConnectionServiceImplSpec extends ZIOSpecDefault { svc <- ZIO.service[ConnectionService] createdRecord1 <- svc.createConnectionInvitation( Some("Test connection invitation #1"), + Some("Test goal code"), + Some("Test goal"), DidId("did:peer:INVITER") ) createdRecord2 <- svc.createConnectionInvitation( Some("Test connection invitation #2"), + Some("Test goal code"), + Some("Test goal"), DidId("did:peer:INVITER") ) records <- svc.getConnectionRecords() @@ -81,10 +93,14 @@ object ConnectionServiceImplSpec extends ZIOSpecDefault { inviteeSvc <- ZIO.service[ConnectionService].provideLayer(connectionServiceLayer) inviterRecord <- inviterSvc.createConnectionInvitation( Some("Inviter"), + Some("Test goal code"), + Some("Test goal"), DidId("did:peer:INVITER") ) inviteeRecord <- inviteeSvc.createConnectionInvitation( Some("Invitee"), + Some("Test goal code"), + Some("Test goal"), DidId("did:peer:INVITEE") ) allInviterRecords <- inviterSvc.getConnectionRecords() @@ -103,6 +119,8 @@ object ConnectionServiceImplSpec extends ZIOSpecDefault { inviteeSvc <- ZIO.service[ConnectionService].provideLayer(connectionServiceLayer) inviterRecord <- inviterSvc.createConnectionInvitation( Some("Test connection invitation"), + Some("Test goal code"), + Some("Test goal"), DidId("did:peer:INVITER") ) inviteeRecord <- inviteeSvc.receiveConnectionInvitation(inviterRecord.invitation.toBase64) @@ -136,6 +154,8 @@ object ConnectionServiceImplSpec extends ZIOSpecDefault { inviteeSvc <- ZIO.service[ConnectionService].provideLayer(connectionServiceLayer) inviterRecord <- inviterSvc.createConnectionInvitation( Some("Test connection invitation"), + Some("Test goal code"), + Some("Test goal"), DidId("did:peer:INVITER") ) inviteeRecord <- inviteeSvc.receiveConnectionInvitation(inviterRecord.invitation.toBase64) @@ -159,6 +179,8 @@ object ConnectionServiceImplSpec extends ZIOSpecDefault { inviteeSvc <- ZIO.service[ConnectionService].provideLayer(connectionServiceLayer) inviterRecord <- inviterSvc.createConnectionInvitation( Some("Test connection invitation"), + Some("Test goal code"), + Some("Test goal"), DidId("did:peer:INVITER") ) inviteeRecord <- inviteeSvc.receiveConnectionInvitation(inviterRecord.invitation.toBase64) @@ -186,6 +208,8 @@ object ConnectionServiceImplSpec extends ZIOSpecDefault { inviteeSvc <- ZIO.service[ConnectionService].provideLayer(connectionServiceLayer) inviterRecord <- inviterSvc.createConnectionInvitation( Some("Test connection invitation"), + Some("Test goal code"), + Some("Test goal"), DidId("did:peer:INVITER") ) inviteeRecord <- inviteeSvc.receiveConnectionInvitation(inviterRecord.invitation.toBase64) @@ -213,6 +237,8 @@ object ConnectionServiceImplSpec extends ZIOSpecDefault { inviteeSvc <- ZIO.service[ConnectionService].provideLayer(connectionServiceLayer) inviterRecord <- inviterSvc.createConnectionInvitation( Some("Test connection invitation"), + Some("Test goal code"), + Some("Test goal"), DidId("did:peer:INVITER") ) inviteeRecord <- inviteeSvc.receiveConnectionInvitation(inviterRecord.invitation.toBase64) @@ -246,6 +272,8 @@ object ConnectionServiceImplSpec extends ZIOSpecDefault { inviteeSvc <- ZIO.service[ConnectionService].provideLayer(connectionServiceLayer) inviterRecord <- inviterSvc.createConnectionInvitation( Some("Test connection invitation"), + Some("Test goal code"), + Some("Test goal"), DidId("did:peer:INVITER") ) inviteeRecord <- inviteeSvc.receiveConnectionInvitation(inviterRecord.invitation.toBase64) diff --git a/connect/lib/core/src/test/scala/io/iohk/atala/connect/core/service/ConnectionServiceNotifierSpec.scala b/connect/lib/core/src/test/scala/io/iohk/atala/connect/core/service/ConnectionServiceNotifierSpec.scala index c9d528352f..957a8beb69 100644 --- a/connect/lib/core/src/test/scala/io/iohk/atala/connect/core/service/ConnectionServiceNotifierSpec.scala +++ b/connect/lib/core/src/test/scala/io/iohk/atala/connect/core/service/ConnectionServiceNotifierSpec.scala @@ -24,9 +24,11 @@ object ConnectionServiceNotifierSpec extends ZIOSpecDefault { None, UUID.randomUUID().toString, None, + None, + None, ConnectionRecord.Role.Inviter, ProtocolState.InvitationGenerated, - Invitation(from = DidId("did:peer:INVITER"), Invitation.Body("", "", Nil)), + Invitation(from = DidId("did:peer:INVITER"), Invitation.Body(None, None, Nil)), None, None, 5, @@ -71,7 +73,12 @@ object ConnectionServiceNotifierSpec extends ZIOSpecDefault { cs <- ZIO.service[ConnectionService] ens <- ZIO.service[EventNotificationService] did = DidId("did:peer:INVITER") - connectionRecord <- cs.createConnectionInvitation(Some("test"), did) + connectionRecord <- cs.createConnectionInvitation( + Some("test"), + Some("test-goal-code"), + Some("test-goal"), + did + ) _ <- cs.receiveConnectionRequest( ConnectionRequest( from = DidId("did:peer:INVITER"), @@ -106,6 +113,8 @@ object ConnectionServiceNotifierSpec extends ZIOSpecDefault { inviterDID = DidId("did:peer:INVITER") inviterRecord <- inviterSvc.createConnectionInvitation( Some("Test connection invitation"), + Some("Test goal code"), + Some("Test goal"), inviterDID ) inviteeSvc <- ZIO.service[ConnectionService] diff --git a/connect/lib/sql-doobie/src/main/resources/sql/connect/V7__add_goal_and_goal_code.sql b/connect/lib/sql-doobie/src/main/resources/sql/connect/V7__add_goal_and_goal_code.sql new file mode 100644 index 0000000000..b13c433d9c --- /dev/null +++ b/connect/lib/sql-doobie/src/main/resources/sql/connect/V7__add_goal_and_goal_code.sql @@ -0,0 +1,5 @@ + +-- Introduce a goal and goal code for connection +ALTER TABLE public.connection_records + ADD COLUMN "goal_code" TEXT, + ADD COLUMN "goal" TEXT; diff --git a/connect/lib/sql-doobie/src/main/scala/io/iohk/atala/connect/sql/repository/JdbcConnectionRepository.scala b/connect/lib/sql-doobie/src/main/scala/io/iohk/atala/connect/sql/repository/JdbcConnectionRepository.scala index e8249e0490..ea39aba43b 100644 --- a/connect/lib/sql-doobie/src/main/scala/io/iohk/atala/connect/sql/repository/JdbcConnectionRepository.scala +++ b/connect/lib/sql-doobie/src/main/scala/io/iohk/atala/connect/sql/repository/JdbcConnectionRepository.scala @@ -59,7 +59,9 @@ class JdbcConnectionRepository(xa: Transactor[ContextAwareTask], xb: Transactor[ | meta_retries, | meta_next_retry, | meta_last_failure, - | wallet_id + | wallet_id, + | goal_code, + | goal | ) values ( | ${record.id}, | ${record.createdAt}, @@ -72,7 +74,9 @@ class JdbcConnectionRepository(xa: Transactor[ContextAwareTask], xb: Transactor[ | ${record.metaRetries}, | ${record.metaNextRetry}, | ${record.metaLastFailure}, - | current_setting('app.current_wallet_id')::UUID + | current_setting('app.current_wallet_id')::UUID, + | ${record.goalCode}, + | ${record.goal} | ) """.stripMargin.update @@ -92,6 +96,8 @@ class JdbcConnectionRepository(xa: Transactor[ContextAwareTask], xb: Transactor[ | updated_at, | thid, | label, + | goal_code, + | goal, | role, | protocol_state, | invitation, @@ -148,6 +154,8 @@ class JdbcConnectionRepository(xa: Transactor[ContextAwareTask], xb: Transactor[ | updated_at, | thid, | label, + | goal_code, + | goal, | role, | protocol_state, | invitation, @@ -175,6 +183,8 @@ class JdbcConnectionRepository(xa: Transactor[ContextAwareTask], xb: Transactor[ | updated_at, | thid, | label, + | goal_code, + | goal, | role, | protocol_state, | invitation, @@ -212,6 +222,8 @@ class JdbcConnectionRepository(xa: Transactor[ContextAwareTask], xb: Transactor[ | updated_at, | thid, | label, + | goal_code, + | goal, | role, | protocol_state, | invitation, diff --git a/mercury/mercury-library/agent/src/main/scala/io/iohk/atala/mercury/InvitationPrograms.scala b/mercury/mercury-library/agent/src/main/scala/io/iohk/atala/mercury/InvitationPrograms.scala index 0b4d98089a..c8950a8a31 100644 --- a/mercury/mercury-library/agent/src/main/scala/io/iohk/atala/mercury/InvitationPrograms.scala +++ b/mercury/mercury-library/agent/src/main/scala/io/iohk/atala/mercury/InvitationPrograms.scala @@ -24,7 +24,7 @@ object InvitationPrograms { "https://didcomm.org/out-of-band/2.0/invitation", getNewMsgId, merdiator.id, - Body("request-mediate", "RequestMediate", Seq("didcomm/v2", "didcomm/aip2;env=rfc587")) + Body(Some("request-mediate"), Some("RequestMediate"), Seq("didcomm/v2", "didcomm/aip2;env=rfc587")) ) _ <- ZIO.log(s"createInvitationV2 from '${merdiator.id}'") result = invitation.asJson.deepDropNullValues diff --git a/mercury/mercury-library/protocol-connection/src/main/scala/io/iohk/atala/mercury/protocol/connection/ConnectionInvitation.scala b/mercury/mercury-library/protocol-connection/src/main/scala/io/iohk/atala/mercury/protocol/connection/ConnectionInvitation.scala index 2e6208b788..691f5805bd 100644 --- a/mercury/mercury-library/protocol-connection/src/main/scala/io/iohk/atala/mercury/protocol/connection/ConnectionInvitation.scala +++ b/mercury/mercury-library/protocol-connection/src/main/scala/io/iohk/atala/mercury/protocol/connection/ConnectionInvitation.scala @@ -8,11 +8,19 @@ object ConnectionInvitation { /** Make a invitation to establish a trust connection between two peers */ def makeConnectionInvitation(from: DidId): Invitation = { + makeConnectionInvitation( + from = from, + goalCode = Some("io.atalaprism.connect"), + goal = Some(s"Establish a trust connection between two peers using the protocol '${ConnectionRequest.`type`}'") + ) + } + + def makeConnectionInvitation(from: DidId, goalCode: Option[String], goal: Option[String]): Invitation = { Invitation( from = from, body = Invitation.Body( - goal_code = "io.atalaprism.connect", - goal = s"Establish a trust connection between two peers using the protocol '${ConnectionRequest.`type`}'", + goal_code = goalCode, + goal = goal, Nil ) ) diff --git a/mercury/mercury-library/protocol-connection/src/main/scala/io/iohk/atala/mercury/protocol/connection/ConnectionRequest.scala b/mercury/mercury-library/protocol-connection/src/main/scala/io/iohk/atala/mercury/protocol/connection/ConnectionRequest.scala index b99d488e47..4915354659 100644 --- a/mercury/mercury-library/protocol-connection/src/main/scala/io/iohk/atala/mercury/protocol/connection/ConnectionRequest.scala +++ b/mercury/mercury-library/protocol-connection/src/main/scala/io/iohk/atala/mercury/protocol/connection/ConnectionRequest.scala @@ -32,8 +32,8 @@ object ConnectionRequest { ConnectionRequest( `type` = ConnectionRequest.`type`, body = Body( - goal_code = Some(invitation.body.goal_code), - goal = Some(invitation.body.goal), + goal_code = invitation.body.goal_code, + goal = invitation.body.goal, accept = Some(invitation.body.accept) ), thid = None, diff --git a/mercury/mercury-library/protocol-invitation/src/main/scala/io/iohk/atala/mercury/protocol/invitation/v2/Invitation.scala b/mercury/mercury-library/protocol-invitation/src/main/scala/io/iohk/atala/mercury/protocol/invitation/v2/Invitation.scala index dfbd544554..9cfb4711c4 100644 --- a/mercury/mercury-library/protocol-invitation/src/main/scala/io/iohk/atala/mercury/protocol/invitation/v2/Invitation.scala +++ b/mercury/mercury-library/protocol-invitation/src/main/scala/io/iohk/atala/mercury/protocol/invitation/v2/Invitation.scala @@ -24,8 +24,8 @@ final case class Invitation( object Invitation { final case class Body( - goal_code: String, - goal: String, // TODO goal can be optional + goal_code: Option[String], + goal: Option[String], accept: Seq[String] ) diff --git a/mercury/mercury-library/protocol-invitation/src/test/scala/io/iohk/atala/mercury/protocol/invitation/v2/OutOfBandSpec.scala b/mercury/mercury-library/protocol-invitation/src/test/scala/io/iohk/atala/mercury/protocol/invitation/v2/OutOfBandSpec.scala index 142eb4d6aa..87eb8f60e0 100644 --- a/mercury/mercury-library/protocol-invitation/src/test/scala/io/iohk/atala/mercury/protocol/invitation/v2/OutOfBandSpec.scala +++ b/mercury/mercury-library/protocol-invitation/src/test/scala/io/iohk/atala/mercury/protocol/invitation/v2/OutOfBandSpec.scala @@ -21,7 +21,7 @@ class OutOfBandSpec extends FunSuite { DidId( "did:peer:2.Ez6LSmLmWmTvwjgLSuUaEQHdHSFWPwyibgzomWjFmnC6FhLnU.Vz6MktNgLh4N1u9KNhDiqe8KZ8bsLzLcqsifoNiUtBoSs9jxf.SeyJpZCI6Im5ldy1pZCIsInQiOiJkbSIsInMiOiJodHRwOi8vMTI3LjAuMC4xOjgwMDAiLCJhIjpbImRpZGNvbW0vdjIiXX0" ), - Body("request-mediate", "RequestMediate", Seq("didcomm/v2", "didcomm/aip2;env=rfc587")), + Body(Some("request-mediate"), Some("RequestMediate"), Seq("didcomm/v2", "didcomm/aip2;env=rfc587")), ) assertEquals(ret, Right(expected)) diff --git a/prism-agent/service/server/src/main/scala/io/iohk/atala/agent/server/jobs/ConnectBackgroundJobs.scala b/prism-agent/service/server/src/main/scala/io/iohk/atala/agent/server/jobs/ConnectBackgroundJobs.scala index 819706de04..f724807e69 100644 --- a/prism-agent/service/server/src/main/scala/io/iohk/atala/agent/server/jobs/ConnectBackgroundJobs.scala +++ b/prism-agent/service/server/src/main/scala/io/iohk/atala/agent/server/jobs/ConnectBackgroundJobs.scala @@ -90,6 +90,8 @@ object ConnectBackgroundJobs extends BackgroundJobsHelper { _, _, _, + _, + _, Invitee, ConnectionRequestPending, _, @@ -136,6 +138,8 @@ object ConnectBackgroundJobs extends BackgroundJobsHelper { _, _, _, + _, + _, Inviter, ConnectionResponsePending, _, diff --git a/prism-agent/service/server/src/main/scala/io/iohk/atala/connect/controller/ConnectionControllerImpl.scala b/prism-agent/service/server/src/main/scala/io/iohk/atala/connect/controller/ConnectionControllerImpl.scala index ae58774e4a..bed453ee7e 100644 --- a/prism-agent/service/server/src/main/scala/io/iohk/atala/connect/controller/ConnectionControllerImpl.scala +++ b/prism-agent/service/server/src/main/scala/io/iohk/atala/connect/controller/ConnectionControllerImpl.scala @@ -29,7 +29,7 @@ class ConnectionControllerImpl( ): ZIO[WalletAccessContext, ErrorResponse, Connection] = { val result = for { pairwiseDid <- managedDIDService.createAndStorePeerDID(appConfig.agent.didCommEndpoint.publicEndpointUrl) - connection <- service.createConnectionInvitation(request.label, pairwiseDid.did) + connection <- service.createConnectionInvitation(request.label, request.goalCode, request.goal, pairwiseDid.did) } yield Connection.fromDomain(connection) result.mapError(toHttpError) diff --git a/prism-agent/service/server/src/main/scala/io/iohk/atala/connect/controller/http/Connection.scala b/prism-agent/service/server/src/main/scala/io/iohk/atala/connect/controller/http/Connection.scala index 4b02c9e332..11b2223cd6 100644 --- a/prism-agent/service/server/src/main/scala/io/iohk/atala/connect/controller/http/Connection.scala +++ b/prism-agent/service/server/src/main/scala/io/iohk/atala/connect/controller/http/Connection.scala @@ -11,6 +11,7 @@ import zio.json.{DeriveJsonDecoder, DeriveJsonEncoder, JsonDecoder, JsonEncoder} import java.time.{OffsetDateTime, ZoneOffset} import java.util.UUID +import io.iohk.atala.connect.controller.http.Connection.annotations.goalcode case class Connection( @description(annotations.connectionId.description) @@ -22,6 +23,12 @@ case class Connection( @description(annotations.label.description) @encodedExample(annotations.label.example) label: Option[String] = None, + @description(annotations.goalcode.description) + @encodedExample(annotations.goalcode.example) + goalCode: Option[String] = None, + @description(annotations.goal.description) + @encodedExample(annotations.goal.example) + goal: Option[String] = None, @description(annotations.myDid.description) @encodedExample(annotations.myDid.example) myDid: Option[String] = None, @@ -66,6 +73,8 @@ object Connection { connectionId = domain.id, thid = domain.thid, label = domain.label, + goalCode = domain.goalCode, + goal = domain.goal, myDid = domain.role match case Role.Inviter => domain.connectionResponse.map(_.from).orElse(domain.connectionRequest.map(_.to)).map(_.value) @@ -110,6 +119,18 @@ object Connection { example = "Peter" ) + object goalcode + extends Annotation[String]( + description = + "A self-attested code the receiver may want to display to the user or use in automatically deciding what to do with the out-of-band message.", + example = "issue-vc" + ) + object goal + extends Annotation[String]( + description = + "A self-attested string that the receiver may want to display to the user about the context-specific goal of the out-of-band message.", + example = "To issue a Peter College Graduate credential" + ) object myDid extends Annotation[String]( description = "The DID representing me as the inviter or invitee in this specific connection.", diff --git a/prism-agent/service/server/src/main/scala/io/iohk/atala/connect/controller/http/CreateConnectionRequest.scala b/prism-agent/service/server/src/main/scala/io/iohk/atala/connect/controller/http/CreateConnectionRequest.scala index adeeeea90d..6b0cb5df28 100644 --- a/prism-agent/service/server/src/main/scala/io/iohk/atala/connect/controller/http/CreateConnectionRequest.scala +++ b/prism-agent/service/server/src/main/scala/io/iohk/atala/connect/controller/http/CreateConnectionRequest.scala @@ -9,7 +9,13 @@ import zio.json.{DeriveJsonDecoder, DeriveJsonEncoder, JsonDecoder, JsonEncoder} case class CreateConnectionRequest( @description(annotations.label.description) @encodedExample(annotations.label.example) - label: Option[String] = None + label: Option[String] = None, + @description(annotations.goalcode.description) + @encodedExample(annotations.goalcode.example) + goalCode: Option[String] = None, + @description(annotations.goal.description) + @encodedExample(annotations.goal.example) + goal: Option[String] = None ) object CreateConnectionRequest { @@ -20,6 +26,18 @@ object CreateConnectionRequest { description = "A human readable alias for the connection.", example = "Peter" ) + object goalcode + extends Annotation[String]( + description = + "A self-attested code the receiver may want to display to the user or use in automatically deciding what to do with the out-of-band message.", + example = "issue-vc" + ) + object goal + extends Annotation[String]( + description = + "A self-attested string that the receiver may want to display to the user about the context-specific goal of the out-of-band message.", + example = "To issue a Peter College Graduate credential" + ) } given encoder: JsonEncoder[CreateConnectionRequest] =