From d042af5ef1884b214537986e4b0ecb411255f02f Mon Sep 17 00:00:00 2001 From: Artur Guseinov Date: Sun, 10 Sep 2023 22:31:04 +0800 Subject: [PATCH] Inject group ID --- Example/PNDecryptionService/NotificationService.swift | 2 +- .../WalletApp/ApplicationLayer/ConfigurationService.swift | 1 + .../Client/Common/NotifyDecryptionService.swift | 4 ++-- .../Client/Wallet/NotifyClientFactory.swift | 4 ++-- Sources/WalletConnectNotify/Notify.swift | 5 +++-- Sources/WalletConnectNotify/NotifyConfig.swift | 1 + Sources/Web3Inbox/Web3Inbox.swift | 3 ++- 7 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Example/PNDecryptionService/NotificationService.swift b/Example/PNDecryptionService/NotificationService.swift index abf6473c2..21da33666 100644 --- a/Example/PNDecryptionService/NotificationService.swift +++ b/Example/PNDecryptionService/NotificationService.swift @@ -15,7 +15,7 @@ class NotificationService: UNNotificationServiceExtension { let ciphertext = bestAttemptContent.userInfo["blob"] as! String NSLog("Push decryption, topic=%@", topic) do { - let service = NotifyDecryptionService() + let service = NotifyDecryptionService(groupIdentifier: "group.com.walletconnect.sdk") let pushMessage = try service.decryptMessage(topic: topic, ciphertext: ciphertext) bestAttemptContent.title = pushMessage.title bestAttemptContent.body = pushMessage.body diff --git a/Example/WalletApp/ApplicationLayer/ConfigurationService.swift b/Example/WalletApp/ApplicationLayer/ConfigurationService.swift index 5aa30d797..225848c93 100644 --- a/Example/WalletApp/ApplicationLayer/ConfigurationService.swift +++ b/Example/WalletApp/ApplicationLayer/ConfigurationService.swift @@ -22,6 +22,7 @@ final class ConfigurationService { account: importAccount.account, bip44: DefaultBIP44Provider(), config: [.chatEnabled: false, .settingsEnabled: false], + groupIdentifier: "group.com.walletconnect.sdk", environment: BuildConfiguration.shared.apnsEnvironment, crypto: DefaultCryptoProvider(), onSign: importAccount.onSign diff --git a/Sources/WalletConnectNotify/Client/Common/NotifyDecryptionService.swift b/Sources/WalletConnectNotify/Client/Common/NotifyDecryptionService.swift index 5fe116af5..7931911ed 100644 --- a/Sources/WalletConnectNotify/Client/Common/NotifyDecryptionService.swift +++ b/Sources/WalletConnectNotify/Client/Common/NotifyDecryptionService.swift @@ -10,8 +10,8 @@ public class NotifyDecryptionService { self.serializer = serializer } - public init() { - let keychainStorage = GroupKeychainStorage(serviceIdentifier: "group.com.walletconnect.sdk") + public init(groupIdentifier: String) { + let keychainStorage = GroupKeychainStorage(serviceIdentifier: groupIdentifier) let kms = KeyManagementService(keychain: keychainStorage) self.serializer = Serializer(kms: kms, logger: ConsoleLogger(prefix: "🔐", loggingLevel: .off)) } diff --git a/Sources/WalletConnectNotify/Client/Wallet/NotifyClientFactory.swift b/Sources/WalletConnectNotify/Client/Wallet/NotifyClientFactory.swift index cb77bce9a..436cb724d 100644 --- a/Sources/WalletConnectNotify/Client/Wallet/NotifyClientFactory.swift +++ b/Sources/WalletConnectNotify/Client/Wallet/NotifyClientFactory.swift @@ -2,12 +2,12 @@ import Foundation public struct NotifyClientFactory { - public static func create(networkInteractor: NetworkInteracting, pairingRegisterer: PairingRegisterer, pushClient: PushClient, crypto: CryptoProvider) -> NotifyClient { + public static func create(groupIdentifier: String, networkInteractor: NetworkInteracting, pairingRegisterer: PairingRegisterer, pushClient: PushClient, crypto: CryptoProvider) -> NotifyClient { let logger = ConsoleLogger(prefix: "🔔",loggingLevel: .debug) let keyValueStorage = UserDefaults.standard let keyserverURL = URL(string: "https://keys.walletconnect.com")! let keychainStorage = KeychainStorage(serviceIdentifier: "com.walletconnect.sdk") - let groupKeychainService = GroupKeychainStorage(serviceIdentifier: "group.com.walletconnect.sdk") + let groupKeychainService = GroupKeychainStorage(serviceIdentifier: groupIdentifier) return NotifyClientFactory.create( keyserverURL: keyserverURL, diff --git a/Sources/WalletConnectNotify/Notify.swift b/Sources/WalletConnectNotify/Notify.swift index 3a8a0bb14..9b258d89f 100644 --- a/Sources/WalletConnectNotify/Notify.swift +++ b/Sources/WalletConnectNotify/Notify.swift @@ -7,6 +7,7 @@ public class Notify { } Push.configure(pushHost: config.pushHost, environment: config.environment) return NotifyClientFactory.create( + groupIdentifier: config.groupIdentifier, networkInteractor: Networking.interactor, pairingRegisterer: Pair.registerer, pushClient: Push.instance, @@ -19,8 +20,8 @@ public class Notify { private init() { } /// Wallet's configuration method - static public func configure(pushHost: String = "echo.walletconnect.com", environment: APNSEnvironment, crypto: CryptoProvider) { - Notify.config = Notify.Config(pushHost: pushHost, environment: environment, crypto: crypto) + static public func configure(pushHost: String = "echo.walletconnect.com", groupIdentifier: String, environment: APNSEnvironment, crypto: CryptoProvider) { + Notify.config = Notify.Config(pushHost: pushHost, groupIdentifier: groupIdentifier, environment: environment, crypto: crypto) } } diff --git a/Sources/WalletConnectNotify/NotifyConfig.swift b/Sources/WalletConnectNotify/NotifyConfig.swift index 479c830ab..977f024f3 100644 --- a/Sources/WalletConnectNotify/NotifyConfig.swift +++ b/Sources/WalletConnectNotify/NotifyConfig.swift @@ -3,6 +3,7 @@ import Foundation extension Notify { struct Config { let pushHost: String + let groupIdentifier: String let environment: APNSEnvironment let crypto: CryptoProvider } diff --git a/Sources/Web3Inbox/Web3Inbox.swift b/Sources/Web3Inbox/Web3Inbox.swift index 17bbc7f55..17b139665 100644 --- a/Sources/Web3Inbox/Web3Inbox.swift +++ b/Sources/Web3Inbox/Web3Inbox.swift @@ -21,6 +21,7 @@ public final class Web3Inbox { account: Account, bip44: BIP44Provider, config: [ConfigParam: Bool] = [:], + groupIdentifier: String, environment: APNSEnvironment, crypto: CryptoProvider, onSign: @escaping SigningCallback @@ -29,6 +30,6 @@ public final class Web3Inbox { Web3Inbox.config = config Web3Inbox.onSign = onSign Chat.configure(bip44: bip44) - Notify.configure(environment: environment, crypto: crypto) + Notify.configure(groupIdentifier: groupIdentifier, environment: environment, crypto: crypto) } }