-
Notifications
You must be signed in to change notification settings - Fork 191
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[Auth, Sign] #485 remove pairing
- Loading branch information
Showing
25 changed files
with
223 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import Foundation | ||
import WalletConnectNetworking | ||
|
||
enum AuthProtocolMethod: String, ProtocolMethod { | ||
case authRequest = "wc_authRequest" | ||
case pairingDelete = "wc_pairingDelete" | ||
case pairingPing = "wc_pairingPing" | ||
|
||
var method: String { | ||
return self.rawValue | ||
} | ||
|
||
var requestTag: Int { | ||
switch self { | ||
case .authRequest: | ||
return 3000 | ||
case .pairingDelete: | ||
return 1000 | ||
case .pairingPing: | ||
return 1002 | ||
} | ||
} | ||
|
||
var responseTag: Int { | ||
switch self { | ||
case .authRequest: | ||
return 3001 | ||
case .pairingDelete: | ||
return 1001 | ||
case .pairingPing: | ||
return 1003 | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import Foundation | ||
import WalletConnectNetworking | ||
import JSONRPC | ||
import WalletConnectKMS | ||
import WalletConnectUtils | ||
import WalletConnectPairing | ||
|
||
class DeletePairingService { | ||
enum Errors: Error { | ||
case pairingNotFound | ||
} | ||
private let networkingInteractor: NetworkInteracting | ||
private let kms: KeyManagementServiceProtocol | ||
private let pairingStorage: WCPairingStorage | ||
private let logger: ConsoleLogging | ||
|
||
init(networkingInteractor: NetworkInteracting, | ||
kms: KeyManagementServiceProtocol, | ||
pairingStorage: WCPairingStorage, | ||
logger: ConsoleLogging) { | ||
self.networkingInteractor = networkingInteractor | ||
self.kms = kms | ||
self.pairingStorage = pairingStorage | ||
self.logger = logger | ||
} | ||
|
||
func delete(topic: String) async throws { | ||
guard pairingStorage.hasPairing(forTopic: topic) else { throw Errors.pairingNotFound} | ||
let reason = AuthError.userDisconnected | ||
logger.debug("Will delete pairing for reason: message: \(reason.message) code: \(reason.code)") | ||
let request = RPCRequest(method: AuthProtocolMethod.pairingDelete.rawValue, params: reason) | ||
try await networkingInteractor.request(request, topic: topic, tag: AuthProtocolMethod.pairingDelete.requestTag) | ||
pairingStorage.delete(topic: topic) | ||
kms.deleteSymmetricKey(for: topic) | ||
networkingInteractor.unsubscribe(topic: topic) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
Sources/WalletConnectSign/Engine/Common/DeletePairingService.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import Foundation | ||
import WalletConnectKMS | ||
import WalletConnectUtils | ||
import WalletConnectPairing | ||
|
||
class DeletePairingService { | ||
private let networkingInteractor: NetworkInteracting | ||
private let kms: KeyManagementServiceProtocol | ||
private let pairingStorage: WCPairingStorage | ||
private let logger: ConsoleLogging | ||
|
||
init(networkingInteractor: NetworkInteracting, | ||
kms: KeyManagementServiceProtocol, | ||
pairingStorage: WCPairingStorage, | ||
logger: ConsoleLogging) { | ||
self.networkingInteractor = networkingInteractor | ||
self.kms = kms | ||
self.pairingStorage = pairingStorage | ||
self.logger = logger | ||
} | ||
|
||
func delete(topic: String) async throws { | ||
let reasonCode = ReasonCode.userDisconnected | ||
let reason = SessionType.Reason(code: reasonCode.code, message: reasonCode.message) | ||
logger.debug("Will delete pairing for reason: message: \(reason.message) code: \(reason.code)") | ||
try await networkingInteractor.request(.wcSessionDelete(reason), onTopic: topic) | ||
pairingStorage.delete(topic: topic) | ||
kms.deleteSymmetricKey(for: topic) | ||
networkingInteractor.unsubscribe(topic: topic) | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
Sources/WalletConnectSign/Engine/Common/DeleteSessionService.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import Foundation | ||
import WalletConnectKMS | ||
import WalletConnectUtils | ||
|
||
class DeleteSessionService { | ||
private let networkingInteractor: NetworkInteracting | ||
private let kms: KeyManagementServiceProtocol | ||
private let sessionStore: WCSessionStorage | ||
private let logger: ConsoleLogging | ||
|
||
init(networkingInteractor: NetworkInteracting, | ||
kms: KeyManagementServiceProtocol, | ||
sessionStore: WCSessionStorage, | ||
logger: ConsoleLogging) { | ||
self.networkingInteractor = networkingInteractor | ||
self.kms = kms | ||
self.sessionStore = sessionStore | ||
self.logger = logger | ||
} | ||
|
||
func delete(topic: String) async throws { | ||
let reasonCode = ReasonCode.userDisconnected | ||
let reason = SessionType.Reason(code: reasonCode.code, message: reasonCode.message) | ||
logger.debug("Will delete session for reason: message: \(reason.message) code: \(reason.code)") | ||
try await networkingInteractor.request(.wcSessionDelete(reason), onTopic: topic) | ||
sessionStore.delete(topic: topic) | ||
kms.deleteSymmetricKey(for: topic) | ||
networkingInteractor.unsubscribe(topic: topic) | ||
} | ||
} |
Oops, something went wrong.