• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

input-output-hk / atala-prism-building-blocks / 8814867820

24 Apr 2024 10:11AM UTC coverage: 32.015% (+0.1%) from 31.912%
8814867820

Pull #973

FabioPinheiro
Merge remote-tracking branch 'origin/main' into align-repo-with-new-name
Pull Request #973: feat: Align the repo with new name identus-cloud-agent

0 of 5 new or added lines in 3 files covered. (0.0%)

391 existing lines in 87 files now uncovered.

4614 of 14412 relevant lines covered (32.01%)

0.32 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

42.11
/pollux/lib/core/src/main/scala/io/iohk/atala/pollux/core/service/PresentationServiceNotifier.scala
1
package io.iohk.atala.pollux.core.service
2

3
import org.hyperledger.identus.event.notification.{Event, EventNotificationService}
4
import org.hyperledger.identus.mercury.model.DidId
5
import org.hyperledger.identus.mercury.protocol.presentproof.{
6
  Presentation,
7
  ProofType,
8
  ProposePresentation,
9
  RequestPresentation
10
}
11
import io.iohk.atala.pollux.anoncreds.AnoncredPresentation
12
import io.iohk.atala.pollux.core.model.error.PresentationError
13
import io.iohk.atala.pollux.core.model.presentation.Options
14
import io.iohk.atala.pollux.core.model.{DidCommID, PresentationRecord}
15
import io.iohk.atala.pollux.core.service.serdes.{AnoncredCredentialProofsV1, AnoncredPresentationRequestV1}
16
import io.iohk.atala.pollux.vc.jwt.{Issuer, PresentationPayload, W3cCredentialPayload}
17
import io.iohk.atala.shared.models.WalletAccessContext
18
import zio.{IO, URLayer, ZIO, ZLayer}
19

20
import java.time.Instant
21
import java.util.UUID
22

23
class PresentationServiceNotifier(
24
    svc: PresentationService,
25
    eventNotificationService: EventNotificationService
26
) extends PresentationService {
27

28
  private val presentationUpdatedEvent = "PresentationUpdated"
29

1✔
30
  override def createJwtPresentationRecord(
31
      pairwiseVerifierDID: DidId,
32
      pairwiseProverDID: DidId,
33
      thid: DidCommID,
34
      connectionId: Option[String],
35
      proofTypes: Seq[ProofType],
36
      options: Option[Options],
37
  ): ZIO[WalletAccessContext, PresentationError, PresentationRecord] =
1✔
38
    notifyOnSuccess(
1✔
39
      svc.createJwtPresentationRecord(
40
        pairwiseVerifierDID,
41
        pairwiseProverDID,
42
        thid,
43
        connectionId,
44
        proofTypes,
45
        options
46
      )
47
    )
48

×
49
  def createAnoncredPresentationRecord(
50
      pairwiseVerifierDID: DidId,
51
      pairwiseProverDID: DidId,
52
      thid: DidCommID,
53
      connectionId: Option[String],
54
      presentationRequest: AnoncredPresentationRequestV1
55
  ): ZIO[WalletAccessContext, PresentationError, PresentationRecord] =
×
56
    notifyOnSuccess(
×
57
      svc.createAnoncredPresentationRecord(
58
        pairwiseVerifierDID,
59
        pairwiseProverDID,
60
        thid,
61
        connectionId,
62
        presentationRequest
63
      )
64
    )
65

1✔
66
  override def markRequestPresentationSent(
67
      recordId: DidCommID
68
  ): ZIO[WalletAccessContext, PresentationError, PresentationRecord] =
1✔
69
    notifyOnSuccess(svc.markRequestPresentationSent(recordId))
70

1✔
71
  override def receiveRequestPresentation(
72
      connectionId: Option[String],
73
      request: RequestPresentation
74
  ): ZIO[WalletAccessContext, PresentationError, PresentationRecord] =
1✔
75
    notifyOnSuccess(svc.receiveRequestPresentation(connectionId, request))
76

×
77
  override def markRequestPresentationRejected(
78
      recordId: DidCommID
79
  ): ZIO[WalletAccessContext, PresentationError, PresentationRecord] =
×
80
    notifyOnSuccess(svc.markRequestPresentationRejected(recordId))
81

1✔
82
  override def acceptRequestPresentation(
83
      recordId: DidCommID,
84
      credentialsToUse: Seq[String]
85
  ): ZIO[WalletAccessContext, PresentationError, PresentationRecord] =
1✔
86
    notifyOnSuccess(svc.acceptRequestPresentation(recordId, credentialsToUse))
87

×
88
  override def acceptAnoncredRequestPresentation(
89
      recordId: DidCommID,
90
      credentialsToUse: AnoncredCredentialProofsV1
×
91
  ): ZIO[WalletAccessContext, PresentationError, PresentationRecord] = notifyOnSuccess(
×
92
    svc.acceptAnoncredRequestPresentation(recordId, credentialsToUse)
93
  )
94

1✔
95
  override def rejectRequestPresentation(
96
      recordId: DidCommID
97
  ): ZIO[WalletAccessContext, PresentationError, PresentationRecord] =
1✔
98
    notifyOnSuccess(svc.rejectRequestPresentation(recordId))
99

1✔
100
  override def markPresentationGenerated(
101
      recordId: DidCommID,
102
      presentation: Presentation
103
  ): ZIO[WalletAccessContext, PresentationError, PresentationRecord] =
1✔
104
    notifyOnSuccess(svc.markPresentationGenerated(recordId, presentation))
105

1✔
106
  override def markPresentationSent(
107
      recordId: DidCommID
108
  ): ZIO[WalletAccessContext, PresentationError, PresentationRecord] =
1✔
109
    notifyOnSuccess(svc.markPresentationSent(recordId))
110

1✔
111
  override def receivePresentation(
112
      presentation: Presentation
113
  ): ZIO[WalletAccessContext, PresentationError, PresentationRecord] =
1✔
114
    notifyOnSuccess(svc.receivePresentation(presentation))
115

1✔
116
  override def markPresentationVerified(
117
      recordId: DidCommID
118
  ): ZIO[WalletAccessContext, PresentationError, PresentationRecord] =
1✔
119
    notifyOnSuccess(svc.markPresentationVerified(recordId))
120

1✔
121
  override def markPresentationVerificationFailed(
122
      recordId: DidCommID
123
  ): ZIO[WalletAccessContext, PresentationError, PresentationRecord] =
1✔
124
    notifyOnSuccess(svc.markPresentationVerificationFailed(recordId))
125

×
126
  override def verifyAnoncredPresentation(
127
      presentation: Presentation,
128
      requestPresentation: RequestPresentation,
129
      recordId: DidCommID
130
  ): ZIO[WalletAccessContext, PresentationError, PresentationRecord] =
×
131
    notifyOnSuccess(
×
132
      svc.verifyAnoncredPresentation(presentation, requestPresentation, recordId)
133
    )
134

1✔
135
  override def acceptPresentation(
136
      recordId: DidCommID
137
  ): ZIO[WalletAccessContext, PresentationError, PresentationRecord] =
1✔
138
    notifyOnSuccess(svc.acceptPresentation(recordId))
139

1✔
140
  override def rejectPresentation(
141
      recordId: DidCommID
142
  ): ZIO[WalletAccessContext, PresentationError, PresentationRecord] =
1✔
143
    notifyOnSuccess(svc.rejectPresentation(recordId))
144

1✔
145
  private[this] def notifyOnSuccess[R](effect: ZIO[R, PresentationError, PresentationRecord]) =
1✔
146
    for {
147
      record <- effect
1✔
148
      _ <- notify(record)
149
    } yield record
150

1✔
151
  private[this] def notify(record: PresentationRecord) = {
1✔
152
    val result = for {
×
153
      walletId <- ZIO.serviceWith[WalletAccessContext](_.walletId)
×
154
      producer <- eventNotificationService.producer[PresentationRecord]("Presentation")
1✔
155
      _ <- producer.send(Event(presentationUpdatedEvent, record, walletId))
UNCOV
156
    } yield ()
×
157
    result.catchAll(e => ZIO.logError(s"Notification service error: $e"))
158
  }
159

×
160
  override def extractIdFromCredential(credential: W3cCredentialPayload): Option[UUID] =
×
161
    svc.extractIdFromCredential(credential)
162

×
163
  override def getPresentationRecords(
164
      ignoreWithZeroRetries: Boolean
165
  ): ZIO[WalletAccessContext, PresentationError, Seq[PresentationRecord]] =
×
166
    svc.getPresentationRecords(ignoreWithZeroRetries)
167

×
168
  override def createJwtPresentationPayloadFromRecord(
169
      record: DidCommID,
170
      issuer: Issuer,
171
      issuanceDate: Instant
172
  ): ZIO[WalletAccessContext, PresentationError, PresentationPayload] =
×
173
    svc.createJwtPresentationPayloadFromRecord(record, issuer, issuanceDate)
174

×
175
  override def createAnoncredPresentationPayloadFromRecord(
176
      record: DidCommID,
177
      anoncredCredentialProof: AnoncredCredentialProofsV1,
178
      issuanceDate: Instant
179
  ): ZIO[WalletAccessContext, PresentationError, AnoncredPresentation] =
×
180
    svc.createAnoncredPresentationPayloadFromRecord(record, anoncredCredentialProof, issuanceDate)
181

×
182
  override def createAnoncredPresentation(
183
      requestPresentation: RequestPresentation,
184
      recordId: DidCommID,
185
      anoncredCredentialProof: AnoncredCredentialProofsV1,
186
      issuanceDate: Instant
187
  ): ZIO[WalletAccessContext, PresentationError, Presentation] =
×
188
    svc.createAnoncredPresentation(requestPresentation, recordId, anoncredCredentialProof, issuanceDate)
189

×
190
  override def getPresentationRecordsByStates(
191
      ignoreWithZeroRetries: Boolean,
192
      limit: Int,
193
      state: PresentationRecord.ProtocolState*
194
  ): ZIO[WalletAccessContext, PresentationError, Seq[PresentationRecord]] =
×
195
    svc.getPresentationRecordsByStates(ignoreWithZeroRetries, limit, state: _*)
196

×
197
  override def getPresentationRecordsByStatesForAllWallets(
198
      ignoreWithZeroRetries: Boolean,
199
      limit: Int,
200
      state: PresentationRecord.ProtocolState*
201
  ): IO[PresentationError, Seq[PresentationRecord]] =
×
202
    svc.getPresentationRecordsByStatesForAllWallets(ignoreWithZeroRetries, limit, state: _*)
203

×
204
  override def getPresentationRecord(
205
      recordId: DidCommID
206
  ): ZIO[WalletAccessContext, PresentationError, Option[PresentationRecord]] =
×
207
    svc.getPresentationRecord(recordId)
208

×
209
  override def getPresentationRecordByThreadId(
210
      thid: DidCommID
211
  ): ZIO[WalletAccessContext, PresentationError, Option[PresentationRecord]] =
×
212
    svc.getPresentationRecordByThreadId(thid)
213

×
214
  override def receiveProposePresentation(
215
      request: ProposePresentation
216
  ): ZIO[WalletAccessContext, PresentationError, PresentationRecord] =
×
217
    svc.receiveProposePresentation((request))
218

×
219
  override def acceptProposePresentation(
220
      recordId: DidCommID
221
  ): ZIO[WalletAccessContext, PresentationError, PresentationRecord] =
×
222
    svc.acceptPresentation(recordId)
223

×
224
  override def markProposePresentationSent(
225
      recordId: DidCommID
226
  ): ZIO[WalletAccessContext, PresentationError, PresentationRecord] =
×
227
    svc.markProposePresentationSent(recordId)
228

×
229
  override def markPresentationAccepted(
230
      recordId: DidCommID
231
  ): ZIO[WalletAccessContext, PresentationError, PresentationRecord] =
×
232
    svc.markPresentationAccepted(recordId)
233

×
234
  override def markPresentationRejected(
235
      recordId: DidCommID
236
  ): ZIO[WalletAccessContext, PresentationError, PresentationRecord] =
×
237
    svc.markPresentationRejected(recordId)
238

×
239
  override def reportProcessingFailure(
240
      recordId: DidCommID,
241
      failReason: Option[_root_.java.lang.String]
×
242
  ): ZIO[WalletAccessContext, PresentationError, Unit] = svc.reportProcessingFailure(recordId, failReason)
243
}
244

245
object PresentationServiceNotifier {
246
  val layer: URLayer[EventNotificationService & PresentationService, PresentationService] =
1✔
247
    ZLayer.fromFunction(PresentationServiceNotifier(_, _))
248
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc