@@ -22,8 +22,9 @@ public class NotifyClient {
22
22
23
23
public let logger : ConsoleLogging
24
24
25
+ private let keyserverURL : URL
25
26
private let pushClient : PushClient
26
- private let identityService : NotifyIdentityService
27
+ private let identityClient : IdentityClient
27
28
private let notifyStorage : NotifyStorage
28
29
private let notifyAccountProvider : NotifyAccountProvider
29
30
private let notifyMessageSubscriber : NotifyMessageSubscriber
@@ -38,8 +39,9 @@ public class NotifyClient {
38
39
private let subscriptionWatcher : SubscriptionWatcher
39
40
40
41
init ( logger: ConsoleLogging ,
42
+ keyserverURL: URL ,
41
43
kms: KeyManagementServiceProtocol ,
42
- identityService : NotifyIdentityService ,
44
+ identityClient : IdentityClient ,
43
45
pushClient: PushClient ,
44
46
notifyMessageSubscriber: NotifyMessageSubscriber ,
45
47
notifyStorage: NotifyStorage ,
@@ -57,8 +59,9 @@ public class NotifyClient {
57
59
subscriptionWatcher: SubscriptionWatcher
58
60
) {
59
61
self . logger = logger
62
+ self . keyserverURL = keyserverURL
60
63
self . pushClient = pushClient
61
- self . identityService = identityService
64
+ self . identityClient = identityClient
62
65
self . notifyMessageSubscriber = notifyMessageSubscriber
63
66
self . notifyStorage = notifyStorage
64
67
self . deleteNotifySubscriptionRequester = deleteNotifySubscriptionRequester
@@ -76,17 +79,22 @@ public class NotifyClient {
76
79
}
77
80
78
81
public func prepareRegistration( account: Account , domain: String , allApps: Bool = true ) async throws -> IdentityRegistrationParams {
79
- return try await identityService. prepareRegistration ( account: account, domain: domain, allApps: allApps)
82
+ return try await identityClient. prepareRegistration (
83
+ account: account,
84
+ domain: domain,
85
+ statement: makeStatement ( allApps: allApps) ,
86
+ resources: [ keyserverURL. absoluteString]
87
+ )
80
88
}
81
89
82
90
public func register( params: IdentityRegistrationParams , signature: CacaoSignature ) async throws {
83
- try await identityService . register ( params: params, signature: signature)
91
+ try await identityClient . register ( params: params, signature: signature)
84
92
notifyAccountProvider. setAccount ( try params. account)
85
93
try await subscriptionWatcher. start ( )
86
94
}
87
95
88
96
public func unregister( account: Account ) async throws {
89
- try await identityService . unregister ( account: account)
97
+ try await identityClient . unregister ( account: account)
90
98
notifyWatcherAgreementKeysProvider. removeAgreement ( account: account)
91
99
try notifyStorage. clearDatabase ( account: account)
92
100
notifyAccountProvider. logout ( )
@@ -126,7 +134,7 @@ public class NotifyClient {
126
134
}
127
135
128
136
public func isIdentityRegistered( account: Account ) -> Bool {
129
- return identityService . isIdentityRegistered ( account: account)
137
+ return identityClient . isIdentityRegistered ( account: account)
130
138
}
131
139
132
140
public func subscriptionsPublisher( account: Account ) -> AnyPublisher < [ NotifySubscription ] , Never > {
@@ -138,6 +146,18 @@ public class NotifyClient {
138
146
}
139
147
}
140
148
149
+ private extension NotifyClient {
150
+
151
+ func makeStatement( allApps: Bool ) -> String {
152
+ switch allApps {
153
+ case false :
154
+ return " I further authorize this app to send me notifications. Read more at https://walletconnect.com/notifications "
155
+ case true :
156
+ return " I further authorize this app to view and manage my notifications for ALL apps. Read more at https://walletconnect.com/notifications "
157
+ }
158
+ }
159
+ }
160
+
141
161
#if targetEnvironment(simulator)
142
162
extension NotifyClient {
143
163
0 commit comments