Skip to content
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

[Core] Inject group ID #1082

Merged
merged 1 commit into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Example/PNDecryptionService/NotificationService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 3 additions & 2 deletions Sources/WalletConnectNotify/Notify.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)
}

}
1 change: 1 addition & 0 deletions Sources/WalletConnectNotify/NotifyConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import Foundation
extension Notify {
struct Config {
let pushHost: String
let groupIdentifier: String
let environment: APNSEnvironment
let crypto: CryptoProvider
}
Expand Down
3 changes: 2 additions & 1 deletion Sources/Web3Inbox/Web3Inbox.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public final class Web3Inbox {
account: Account,
bip44: BIP44Provider,
config: [ConfigParam: Bool] = [:],
groupIdentifier: String,
environment: APNSEnvironment,
crypto: CryptoProvider,
onSign: @escaping SigningCallback
Expand All @@ -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)
}
}