From 64f935bd8e69e8a7f4891b7b1019db3fb2a13205 Mon Sep 17 00:00:00 2001 From: kubel Date: Wed, 8 May 2024 11:26:58 +0200 Subject: [PATCH] Add rejection tags --- .../walletconnect/android/internal/common/model/Tags.kt | 8 ++++++-- .../use_case/calls/ApproveSessionAuthenticateUseCase.kt | 2 +- .../sign/engine/use_case/calls/ApproveSessionUseCase.kt | 2 +- .../use_case/calls/RejectSessionAuthenticateUseCase.kt | 2 +- .../sign/engine/use_case/calls/RejectSessionUseCase.kt | 2 +- .../use_case/requests/OnSessionAuthenticateUseCase.kt | 2 +- .../engine/use_case/requests/OnSessionProposalUseCase.kt | 2 +- 7 files changed, 12 insertions(+), 8 deletions(-) diff --git a/core/android/src/main/kotlin/com/walletconnect/android/internal/common/model/Tags.kt b/core/android/src/main/kotlin/com/walletconnect/android/internal/common/model/Tags.kt index 0f64d0fa4..8711acf05 100644 --- a/core/android/src/main/kotlin/com/walletconnect/android/internal/common/model/Tags.kt +++ b/core/android/src/main/kotlin/com/walletconnect/android/internal/common/model/Tags.kt @@ -10,7 +10,9 @@ enum class Tags(val id: Int) { PAIRING_PING_RESPONSE(1003), SESSION_PROPOSE(1100), - SESSION_PROPOSE_RESPONSE(1101), + SESSION_PROPOSE_RESPONSE_APPROVE(1101), + SESSION_PROPOSE_RESPONSE_REJECT(1120), + SESSION_PROPOSE_RESPONSE_AUTO_REJECT(1121), SESSION_SETTLE(1102), SESSION_SETTLE_RESPONSE(1103), @@ -34,7 +36,9 @@ enum class Tags(val id: Int) { SESSION_PING_RESPONSE(1115), SESSION_AUTHENTICATE(1116), - SESSION_AUTHENTICATE_RESPONSE(1117), + SESSION_AUTHENTICATE_RESPONSE_APPROVE(1117), + SESSION_AUTHENTICATE_RESPONSE_REJECT(1118), + SESSION_AUTHENTICATE_RESPONSE_AUTO_REJECT(1119), CHAT_INVITE(2000), CHAT_INVITE_RESPONSE(2001), diff --git a/protocol/sign/src/main/kotlin/com/walletconnect/sign/engine/use_case/calls/ApproveSessionAuthenticateUseCase.kt b/protocol/sign/src/main/kotlin/com/walletconnect/sign/engine/use_case/calls/ApproveSessionAuthenticateUseCase.kt index 76e5bb77d..6a18c415c 100644 --- a/protocol/sign/src/main/kotlin/com/walletconnect/sign/engine/use_case/calls/ApproveSessionAuthenticateUseCase.kt +++ b/protocol/sign/src/main/kotlin/com/walletconnect/sign/engine/use_case/calls/ApproveSessionAuthenticateUseCase.kt @@ -87,7 +87,7 @@ internal class ApproveSessionAuthenticateUseCase( val symmetricKey: SymmetricKey = crypto.generateSymmetricKeyFromKeyAgreement(senderPublicKey, receiverPublicKey) val responseTopic: Topic = crypto.getTopicFromKey(receiverPublicKey) val sessionTopic = crypto.getTopicFromKey(symmetricKey) - val irnParams = IrnParams(Tags.SESSION_AUTHENTICATE_RESPONSE, Ttl(dayInSeconds)) + val irnParams = IrnParams(Tags.SESSION_AUTHENTICATE_RESPONSE_APPROVE, Ttl(dayInSeconds)) if (cacaos.find { cacao -> !cacaoVerifier.verify(cacao) } != null) { logger.error("Invalid Cacao for Session Authenticate") diff --git a/protocol/sign/src/main/kotlin/com/walletconnect/sign/engine/use_case/calls/ApproveSessionUseCase.kt b/protocol/sign/src/main/kotlin/com/walletconnect/sign/engine/use_case/calls/ApproveSessionUseCase.kt index 480b7d1ba..49fc7d6e9 100644 --- a/protocol/sign/src/main/kotlin/com/walletconnect/sign/engine/use_case/calls/ApproveSessionUseCase.kt +++ b/protocol/sign/src/main/kotlin/com/walletconnect/sign/engine/use_case/calls/ApproveSessionUseCase.kt @@ -113,7 +113,7 @@ internal class ApproveSessionUseCase( val selfPublicKey: PublicKey = crypto.generateAndStoreX25519KeyPair() val sessionTopic = crypto.generateTopicFromKeyAgreement(selfPublicKey, PublicKey(proposerPublicKey)) val approvalParams = proposal.toSessionApproveParams(selfPublicKey) - val irnParams = IrnParams(Tags.SESSION_PROPOSE_RESPONSE, Ttl(fiveMinutesInSeconds)) + val irnParams = IrnParams(Tags.SESSION_PROPOSE_RESPONSE_APPROVE, Ttl(fiveMinutesInSeconds)) logger.log("Subscribing to session topic: $sessionTopic") jsonRpcInteractor.subscribe(sessionTopic, onSuccess = { diff --git a/protocol/sign/src/main/kotlin/com/walletconnect/sign/engine/use_case/calls/RejectSessionAuthenticateUseCase.kt b/protocol/sign/src/main/kotlin/com/walletconnect/sign/engine/use_case/calls/RejectSessionAuthenticateUseCase.kt index e01855a68..76707f47f 100644 --- a/protocol/sign/src/main/kotlin/com/walletconnect/sign/engine/use_case/calls/RejectSessionAuthenticateUseCase.kt +++ b/protocol/sign/src/main/kotlin/com/walletconnect/sign/engine/use_case/calls/RejectSessionAuthenticateUseCase.kt @@ -62,7 +62,7 @@ internal class RejectSessionAuthenticateUseCase( val responseTopic: Topic = crypto.getTopicFromKey(receiverPublicKey) crypto.setKey(symmetricKey, responseTopic.value) - val irnParams = IrnParams(Tags.SESSION_AUTHENTICATE_RESPONSE, Ttl(dayInSeconds), false) + val irnParams = IrnParams(Tags.SESSION_AUTHENTICATE_RESPONSE_REJECT, Ttl(dayInSeconds), false) logger.log("Sending Session Authenticate Reject on topic: $responseTopic") jsonRpcInteractor.publishJsonRpcResponse( diff --git a/protocol/sign/src/main/kotlin/com/walletconnect/sign/engine/use_case/calls/RejectSessionUseCase.kt b/protocol/sign/src/main/kotlin/com/walletconnect/sign/engine/use_case/calls/RejectSessionUseCase.kt index ed248a123..4870ccaa1 100644 --- a/protocol/sign/src/main/kotlin/com/walletconnect/sign/engine/use_case/calls/RejectSessionUseCase.kt +++ b/protocol/sign/src/main/kotlin/com/walletconnect/sign/engine/use_case/calls/RejectSessionUseCase.kt @@ -36,7 +36,7 @@ internal class RejectSessionUseCase( jsonRpcInteractor.respondWithError( proposal.toSessionProposeRequest(), PeerError.EIP1193.UserRejectedRequest(reason), - IrnParams(Tags.SESSION_PROPOSE_RESPONSE, Ttl(fiveMinutesInSeconds)), + IrnParams(Tags.SESSION_PROPOSE_RESPONSE_REJECT, Ttl(fiveMinutesInSeconds)), onSuccess = { logger.log("Session rejection sent successfully, topic: ${proposal.pairingTopic.value}") scope.launch { diff --git a/protocol/sign/src/main/kotlin/com/walletconnect/sign/engine/use_case/requests/OnSessionAuthenticateUseCase.kt b/protocol/sign/src/main/kotlin/com/walletconnect/sign/engine/use_case/requests/OnSessionAuthenticateUseCase.kt index be315c704..480828e96 100644 --- a/protocol/sign/src/main/kotlin/com/walletconnect/sign/engine/use_case/requests/OnSessionAuthenticateUseCase.kt +++ b/protocol/sign/src/main/kotlin/com/walletconnect/sign/engine/use_case/requests/OnSessionAuthenticateUseCase.kt @@ -36,7 +36,7 @@ internal class OnSessionAuthenticateUseCase( val events: SharedFlow = _events.asSharedFlow() suspend operator fun invoke(request: WCRequest, authenticateSessionParams: SignParams.SessionAuthenticateParams) = supervisorScope { - val irnParams = IrnParams(Tags.SESSION_AUTHENTICATE_RESPONSE, Ttl(dayInSeconds)) + val irnParams = IrnParams(Tags.SESSION_AUTHENTICATE_RESPONSE_AUTO_REJECT, Ttl(dayInSeconds)) logger.log("Received session authenticate: ${request.topic}") try { if (Expiry(authenticateSessionParams.expiryTimestamp).isExpired()) { diff --git a/protocol/sign/src/main/kotlin/com/walletconnect/sign/engine/use_case/requests/OnSessionProposalUseCase.kt b/protocol/sign/src/main/kotlin/com/walletconnect/sign/engine/use_case/requests/OnSessionProposalUseCase.kt index a9ccf0b06..fd39632cf 100644 --- a/protocol/sign/src/main/kotlin/com/walletconnect/sign/engine/use_case/requests/OnSessionProposalUseCase.kt +++ b/protocol/sign/src/main/kotlin/com/walletconnect/sign/engine/use_case/requests/OnSessionProposalUseCase.kt @@ -45,7 +45,7 @@ internal class OnSessionProposalUseCase( private val isAuthenticateEnabled: Boolean by lazy { wcKoinApp.koin.get(named(AndroidCommonDITags.ENABLE_AUTHENTICATE)) } suspend operator fun invoke(request: WCRequest, payloadParams: SignParams.SessionProposeParams) = supervisorScope { - val irnParams = IrnParams(Tags.SESSION_PROPOSE_RESPONSE, Ttl(fiveMinutesInSeconds)) + val irnParams = IrnParams(Tags.SESSION_PROPOSE_RESPONSE_AUTO_REJECT, Ttl(fiveMinutesInSeconds)) try { if (isSessionAuthenticateImplemented(request)) { logger.error("Session proposal received error: pairing supports authenticated sessions")