@@ -30,18 +30,24 @@ enum PubkyService {
3030 static let requiredCapabilities = " /pub/paykit.app/v0/:rw,/pub/pubky.app/profile.json:rw,/pub/pubky.app/follows/:rw "
3131
3232 static func initialize( ) async throws {
33- try await paykitInitialize ( )
33+ try await ServiceQueue . background ( . core) {
34+ try await paykitInitialize ( )
35+ }
3436 }
3537
3638 // MARK: - Session Management
3739
3840 /// Import a session secret into paykit and return the public key.
3941 static func importSession( secret: String ) async throws -> String {
40- try await paykitImportSession ( sessionSecret: secret)
42+ try await ServiceQueue . background ( . core) {
43+ try await paykitImportSession ( sessionSecret: secret)
44+ }
4145 }
4246
4347 static func exportSession( ) async throws -> String {
44- try await paykitExportSession ( )
48+ try await ServiceQueue . background ( . core) {
49+ try await paykitExportSession ( )
50+ }
4551 }
4652
4753 static func isAuthenticated( ) async -> Bool {
@@ -56,61 +62,83 @@ enum PubkyService {
5662
5763 /// Step 1: Generate the pubkyauth:// URL to open in Pubky Ring.
5864 static func startAuth( ) async throws -> String {
59- try await startPubkyAuth ( caps: requiredCapabilities)
65+ try await ServiceQueue . background ( . core) {
66+ try await startPubkyAuth ( caps: requiredCapabilities)
67+ }
6068 }
6169
6270 /// Step 2: Long-poll until Ring approves. Returns the raw session secret.
6371 static func completeAuth( ) async throws -> String {
64- try await completePubkyAuth ( )
72+ try await ServiceQueue . background ( . core) {
73+ try await completePubkyAuth ( )
74+ }
6575 }
6676
6777 /// Cancel an in-progress auth relay poll started by `startAuth`.
6878 static func cancelAuth( ) async throws {
69- try await cancelPubkyAuth ( )
79+ try await ServiceQueue . background ( . core) {
80+ try await cancelPubkyAuth ( )
81+ }
7082 }
7183
7284 // MARK: - File Fetching
7385
7486 /// Fetch raw bytes from a `pubky://` URI via PKDNS resolution.
7587 static func fetchFile( uri: String ) async throws -> Data {
76- let bytes = try await fetchPubkyFile ( uri: uri)
77- return Data ( bytes)
88+ try await ServiceQueue . background ( . core) {
89+ let bytes = try await fetchPubkyFile ( uri: uri)
90+ return Data ( bytes)
91+ }
7892 }
7993
8094 // MARK: - Profile
8195
8296 static func getProfile( publicKey: String ) async throws -> FfiProfile {
83- try await paykitGetProfile ( publicKey: publicKey)
97+ try await ServiceQueue . background ( . core) {
98+ try await paykitGetProfile ( publicKey: publicKey)
99+ }
84100 }
85101
86102 // MARK: - Contacts
87103
88104 static func getContacts( publicKey: String ) async throws -> [ String ] {
89- try await paykitGetContacts ( publicKey: publicKey)
105+ try await ServiceQueue . background ( . core) {
106+ try await paykitGetContacts ( publicKey: publicKey)
107+ }
90108 }
91109
92110 // MARK: - Payments
93111
94112 static func getPaymentList( publicKey: String ) async throws -> [ FfiPaymentEntry ] {
95- try await paykitGetPaymentList ( publicKey: publicKey)
113+ try await ServiceQueue . background ( . core) {
114+ try await paykitGetPaymentList ( publicKey: publicKey)
115+ }
96116 }
97117
98118 static func getPaymentEndpoint( publicKey: String , methodId: String ) async throws -> String ? {
99- try await paykitGetPaymentEndpoint ( publicKey: publicKey, methodId: methodId)
119+ try await ServiceQueue . background ( . core) {
120+ try await paykitGetPaymentEndpoint ( publicKey: publicKey, methodId: methodId)
121+ }
100122 }
101123
102124 static func setPaymentEndpoint( methodId: String , endpointData: String ) async throws {
103- try await paykitSetPaymentEndpoint ( methodId: methodId, endpointData: endpointData)
125+ try await ServiceQueue . background ( . core) {
126+ try await paykitSetPaymentEndpoint ( methodId: methodId, endpointData: endpointData)
127+ }
104128 }
105129
106130 static func removePaymentEndpoint( methodId: String ) async throws {
107- try await paykitRemovePaymentEndpoint ( methodId: methodId)
131+ try await ServiceQueue . background ( . core) {
132+ try await paykitRemovePaymentEndpoint ( methodId: methodId)
133+ }
108134 }
109135
110136 // MARK: - Sign Out
111137
112138 static func signOut( ) async throws {
113- try await paykitSignOut ( )
139+ try await ServiceQueue . background ( . core) {
140+ try await paykitSignOut ( )
141+ }
114142 }
115143
116144 static func forceSignOut( ) async {
0 commit comments