Skip to content

Commit

Permalink
fix: rename signature to signatureM and add Transactional spring anno…
Browse files Browse the repository at this point in the history
…tation to handleKeriVerification and handleCardanoVerification
  • Loading branch information
jimcase committed Jul 16, 2024
1 parent 68a637e commit 5fa1ff7
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ private Either<Problem, EventSummary> validateEvent(String eventId) {
.build()));
}

@Transactional(propagation = Propagation.SUPPORTS)
private Either<Problem, IsVerifiedResponse> handleCardanoVerification(DiscordCheckVerificationRequest request, String eventId, String walletId) {

String signature = request.getCoseSignature().orElse(null);
Expand Down Expand Up @@ -349,11 +350,12 @@ private Either<Problem, Tuple2<String, Optional<String>>> verifySignature(String
return Either.right(new Tuple2<>(msg, maybeAddress));
}

@Transactional(propagation = Propagation.SUPPORTS)
private Either<Problem, IsVerifiedResponse> handleKeriVerification(DiscordCheckVerificationRequest request, String eventId, String walletId) {

String signature = request.getKeriSignedMessage().orElse(null);
String signatureM = request.getKeriSignedMessage().orElse(null);

if (signature == null) {
if (signatureM == null) {
return Either.left(Problem.builder()
.withTitle("MISSING_SIGNATURE")
.withDetail("Missing signature.")
Expand Down Expand Up @@ -443,7 +445,7 @@ private Either<Problem, IsVerifiedResponse> handleKeriVerification(DiscordCheckV

if (oobiCheckResult.isRight()) {
log.info("OOBI already registered: {}", oobiCheckResult);
Either<Problem, Boolean> verificationResult = keriVerificationClient.verifySignature(walletId, signature, payload);
Either<Problem, Boolean> verificationResult = keriVerificationClient.verifySignature(walletId, signatureM, payload);

if (verificationResult.isLeft()) {
return Either.left(verificationResult.getLeft());
Expand All @@ -457,7 +459,7 @@ private Either<Problem, IsVerifiedResponse> handleKeriVerification(DiscordCheckV
.build());
}

log.info("Keri signature {} verified for walletId {} with payload {}", signature, walletId, payload);
log.info("Keri signature {} verified for walletId {} with payload {}", signatureM, walletId, payload);
pendingVerification.setWalletId(Optional.of(walletId));
pendingVerification.setWalletType(request.getWalletType());
pendingVerification.setUpdatedAt(LocalDateTime.now(clock));
Expand All @@ -484,7 +486,7 @@ private Either<Problem, IsVerifiedResponse> handleKeriVerification(DiscordCheckV
}

// Step 4: Verify signature after OOBI registration
Either<Problem, Boolean> verificationResult = keriVerificationClient.verifySignature(walletId, signature, payload);
Either<Problem, Boolean> verificationResult = keriVerificationClient.verifySignature(walletId, signatureM, payload);

if (verificationResult.isLeft()) {
return Either.left(verificationResult.getLeft());
Expand All @@ -498,7 +500,7 @@ private Either<Problem, IsVerifiedResponse> handleKeriVerification(DiscordCheckV
.build());
}

log.info("Keri signature {} verified for walletId {} with payload {}", signature, walletId, payload);
log.info("Keri signature {} verified for walletId {} with payload {}", signatureM, walletId, payload);
pendingVerification.setWalletId(Optional.of(walletId));
pendingVerification.setWalletType(request.getWalletType());
pendingVerification.setUpdatedAt(LocalDateTime.now(clock));
Expand Down

0 comments on commit 5fa1ff7

Please sign in to comment.