-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1357 from WalletConnect/develop
1.18.8
- Loading branch information
Showing
16 changed files
with
337 additions
and
48 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
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,55 @@ | ||
import Foundation | ||
|
||
actor UnregisterService { | ||
private let httpClient: HTTPClient | ||
private let projectId: String | ||
private let logger: ConsoleLogging | ||
private let environment: APNSEnvironment | ||
private let pushAuthenticator: PushAuthenticating | ||
private let clientIdStorage: ClientIdStoring | ||
private let pushHost: String | ||
|
||
init(httpClient: HTTPClient, | ||
projectId: String, | ||
clientIdStorage: ClientIdStoring, | ||
pushAuthenticator: PushAuthenticating, | ||
logger: ConsoleLogging, | ||
pushHost: String, | ||
environment: APNSEnvironment) { | ||
self.httpClient = httpClient | ||
self.clientIdStorage = clientIdStorage | ||
self.pushAuthenticator = pushAuthenticator | ||
self.projectId = projectId | ||
self.logger = logger | ||
self.pushHost = pushHost | ||
self.environment = environment | ||
} | ||
|
||
func unregister() async throws { | ||
let pushAuthToken = try pushAuthenticator.createAuthToken() | ||
let clientId = try clientIdStorage.getClientId() | ||
|
||
guard let url = URL(string: "https://\(pushHost)/\(projectId)/clients/\(clientId)") else { | ||
logger.error("Invalid URL") | ||
return | ||
} | ||
|
||
var request = URLRequest(url: url) | ||
request.httpMethod = "DELETE" | ||
request.addValue("\(pushAuthToken)", forHTTPHeaderField: "Authorization") | ||
|
||
do { | ||
let (_, response) = try await URLSession.shared.data(for: request) | ||
|
||
guard let httpResponse = response as? HTTPURLResponse, httpResponse.statusCode == 200 else { | ||
logger.error("Failed to unregister from Push Server") | ||
throw NSError(domain: "UnregisterService", code: 0, userInfo: [NSLocalizedDescriptionKey: "Failed to unregister"]) | ||
} | ||
|
||
logger.debug("Successfully unregistered from Push Server") | ||
} catch { | ||
logger.error("Push Server unregistration error: \(error.localizedDescription)") | ||
throw error | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1 +1 @@ | ||
{"version": "1.18.7"} | ||
{"version": "1.18.8"} |
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
20 changes: 20 additions & 0 deletions
20
Sources/WalletConnectSign/Services/InvalidRequestsSanitiser.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,20 @@ | ||
|
||
import Foundation | ||
|
||
final class InvalidRequestsSanitiser { | ||
private let historyService: HistoryServiceProtocol | ||
private let history: RPCHistoryProtocol | ||
|
||
init(historyService: HistoryServiceProtocol, history: RPCHistoryProtocol) { | ||
self.historyService = historyService | ||
self.history = history | ||
} | ||
|
||
func removeInvalidSessionRequests(validSessionTopics: Set<String>) { | ||
let pendingRequests = historyService.getPendingRequests() | ||
let invalidTopics = Set(pendingRequests.map { $0.request.topic }).subtracting(validSessionTopics) | ||
if !invalidTopics.isEmpty { | ||
history.deleteAll(forTopics: Array(invalidTopics)) | ||
} | ||
} | ||
} |
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
Oops, something went wrong.