-
Notifications
You must be signed in to change notification settings - Fork 191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Auth, Sign] #485 remove pairing #486
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
b5f4f13
NetworkInteracting moved to package
flypaper0 fca1b49
Auth NetworkInteractor moved to package
flypaper0 8cef57d
Chat Genaric interactor connected
flypaper0 429b32e
Showcase build errors
flypaper0 eaccdad
savepoint
llbartekll a54aafd
Add disconnect method
llbartekll 1e35971
savepoint
llbartekll 26bc699
Add disconnect to auth client api
llbartekll 9d6cfb0
add disconnect service for sign
llbartekll 1895acb
run lint
llbartekll 2442dca
Merge branch 'develop' of github.com:WalletConnect/WalletConnectSwift…
llbartekll afec45a
after merge fix
llbartekll 3f9b42b
fix tags
llbartekll 8a7e004
update
llbartekll File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we move it in WalletConnectPairing package?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, I see. Whey using different NetworkInteractors..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah exactly, even the protocol method is the same