@synonymdev/react-native-pubky 0.7.1 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -10,7 +10,7 @@
10
10
  <key>HeadersPath</key>
11
11
  <string>Headers</string>
12
12
  <key>LibraryIdentifier</key>
13
- <string>ios-arm64-simulator</string>
13
+ <string>ios-arm64</string>
14
14
  <key>LibraryPath</key>
15
15
  <string>libpubkymobile.a</string>
16
16
  <key>SupportedArchitectures</key>
@@ -19,8 +19,6 @@
19
19
  </array>
20
20
  <key>SupportedPlatform</key>
21
21
  <string>ios</string>
22
- <key>SupportedPlatformVariant</key>
23
- <string>simulator</string>
24
22
  </dict>
25
23
  <dict>
26
24
  <key>BinaryPath</key>
@@ -28,7 +26,7 @@
28
26
  <key>HeadersPath</key>
29
27
  <string>Headers</string>
30
28
  <key>LibraryIdentifier</key>
31
- <string>ios-arm64</string>
29
+ <string>ios-arm64-simulator</string>
32
30
  <key>LibraryPath</key>
33
31
  <string>libpubkymobile.a</string>
34
32
  <key>SupportedArchitectures</key>
@@ -37,6 +35,8 @@
37
35
  </array>
38
36
  <key>SupportedPlatform</key>
39
37
  <string>ios</string>
38
+ <key>SupportedPlatformVariant</key>
39
+ <string>simulator</string>
40
40
  </dict>
41
41
  </array>
42
42
  <key>CFBundlePackageType</key>
@@ -63,8 +63,18 @@ typedef struct RustCallStatus {
63
63
  typedef void (*UniFfiRustFutureContinuation)(void * _Nonnull, int8_t);
64
64
 
65
65
  // Scaffolding functions
66
+ void uniffi_pubkymobile_fn_free_eventnotifier(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status
67
+ );
68
+ void uniffi_pubkymobile_fn_init_callback_eventlistener(ForeignCallback _Nonnull callback_stub, RustCallStatus *_Nonnull out_status
69
+ );
66
70
  RustBuffer uniffi_pubkymobile_fn_func_auth(RustBuffer url, RustBuffer secret_key, RustCallStatus *_Nonnull out_status
67
71
  );
72
+ RustBuffer uniffi_pubkymobile_fn_func_create_recovery_file(RustBuffer secret_key, RustBuffer passphrase, RustCallStatus *_Nonnull out_status
73
+ );
74
+ RustBuffer uniffi_pubkymobile_fn_func_decrypt_recovery_file(RustBuffer recovery_file, RustBuffer passphrase, RustCallStatus *_Nonnull out_status
75
+ );
76
+ RustBuffer uniffi_pubkymobile_fn_func_delete_file(RustBuffer url, RustCallStatus *_Nonnull out_status
77
+ );
68
78
  RustBuffer uniffi_pubkymobile_fn_func_generate_secret_key(RustCallStatus *_Nonnull out_status
69
79
 
70
80
  );
@@ -81,11 +91,18 @@ RustBuffer uniffi_pubkymobile_fn_func_publish(RustBuffer record_name, RustBuffer
81
91
  RustBuffer uniffi_pubkymobile_fn_func_publish_https(RustBuffer record_name, RustBuffer target, RustBuffer secret_key, RustCallStatus *_Nonnull out_status
82
92
  );
83
93
  RustBuffer uniffi_pubkymobile_fn_func_put(RustBuffer url, RustBuffer content, RustCallStatus *_Nonnull out_status
94
+ );
95
+ void uniffi_pubkymobile_fn_func_remove_event_listener(RustCallStatus *_Nonnull out_status
96
+
84
97
  );
85
98
  RustBuffer uniffi_pubkymobile_fn_func_resolve(RustBuffer public_key, RustCallStatus *_Nonnull out_status
86
99
  );
87
100
  RustBuffer uniffi_pubkymobile_fn_func_resolve_https(RustBuffer public_key, RustCallStatus *_Nonnull out_status
88
101
  );
102
+ RustBuffer uniffi_pubkymobile_fn_func_session(RustBuffer pubky, RustCallStatus *_Nonnull out_status
103
+ );
104
+ void uniffi_pubkymobile_fn_func_set_event_listener(uint64_t listener, RustCallStatus *_Nonnull out_status
105
+ );
89
106
  RustBuffer uniffi_pubkymobile_fn_func_sign_in(RustBuffer secret_key, RustCallStatus *_Nonnull out_status
90
107
  );
91
108
  RustBuffer uniffi_pubkymobile_fn_func_sign_out(RustBuffer secret_key, RustCallStatus *_Nonnull out_status
@@ -208,6 +225,15 @@ void ffi_pubkymobile_rust_future_complete_void(void* _Nonnull handle, RustCallSt
208
225
  );
209
226
  uint16_t uniffi_pubkymobile_checksum_func_auth(void
210
227
 
228
+ );
229
+ uint16_t uniffi_pubkymobile_checksum_func_create_recovery_file(void
230
+
231
+ );
232
+ uint16_t uniffi_pubkymobile_checksum_func_decrypt_recovery_file(void
233
+
234
+ );
235
+ uint16_t uniffi_pubkymobile_checksum_func_delete_file(void
236
+
211
237
  );
212
238
  uint16_t uniffi_pubkymobile_checksum_func_generate_secret_key(void
213
239
 
@@ -232,12 +258,21 @@ uint16_t uniffi_pubkymobile_checksum_func_publish_https(void
232
258
  );
233
259
  uint16_t uniffi_pubkymobile_checksum_func_put(void
234
260
 
261
+ );
262
+ uint16_t uniffi_pubkymobile_checksum_func_remove_event_listener(void
263
+
235
264
  );
236
265
  uint16_t uniffi_pubkymobile_checksum_func_resolve(void
237
266
 
238
267
  );
239
268
  uint16_t uniffi_pubkymobile_checksum_func_resolve_https(void
240
269
 
270
+ );
271
+ uint16_t uniffi_pubkymobile_checksum_func_session(void
272
+
273
+ );
274
+ uint16_t uniffi_pubkymobile_checksum_func_set_event_listener(void
275
+
241
276
  );
242
277
  uint16_t uniffi_pubkymobile_checksum_func_sign_in(void
243
278
 
@@ -247,6 +282,9 @@ uint16_t uniffi_pubkymobile_checksum_func_sign_out(void
247
282
  );
248
283
  uint16_t uniffi_pubkymobile_checksum_func_sign_up(void
249
284
 
285
+ );
286
+ uint16_t uniffi_pubkymobile_checksum_method_eventlistener_on_event_occurred(void
287
+
250
288
  );
251
289
  uint32_t ffi_pubkymobile_uniffi_contract_version(void
252
290
 
@@ -63,8 +63,18 @@ typedef struct RustCallStatus {
63
63
  typedef void (*UniFfiRustFutureContinuation)(void * _Nonnull, int8_t);
64
64
 
65
65
  // Scaffolding functions
66
+ void uniffi_pubkymobile_fn_free_eventnotifier(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status
67
+ );
68
+ void uniffi_pubkymobile_fn_init_callback_eventlistener(ForeignCallback _Nonnull callback_stub, RustCallStatus *_Nonnull out_status
69
+ );
66
70
  RustBuffer uniffi_pubkymobile_fn_func_auth(RustBuffer url, RustBuffer secret_key, RustCallStatus *_Nonnull out_status
67
71
  );
72
+ RustBuffer uniffi_pubkymobile_fn_func_create_recovery_file(RustBuffer secret_key, RustBuffer passphrase, RustCallStatus *_Nonnull out_status
73
+ );
74
+ RustBuffer uniffi_pubkymobile_fn_func_decrypt_recovery_file(RustBuffer recovery_file, RustBuffer passphrase, RustCallStatus *_Nonnull out_status
75
+ );
76
+ RustBuffer uniffi_pubkymobile_fn_func_delete_file(RustBuffer url, RustCallStatus *_Nonnull out_status
77
+ );
68
78
  RustBuffer uniffi_pubkymobile_fn_func_generate_secret_key(RustCallStatus *_Nonnull out_status
69
79
 
70
80
  );
@@ -81,11 +91,18 @@ RustBuffer uniffi_pubkymobile_fn_func_publish(RustBuffer record_name, RustBuffer
81
91
  RustBuffer uniffi_pubkymobile_fn_func_publish_https(RustBuffer record_name, RustBuffer target, RustBuffer secret_key, RustCallStatus *_Nonnull out_status
82
92
  );
83
93
  RustBuffer uniffi_pubkymobile_fn_func_put(RustBuffer url, RustBuffer content, RustCallStatus *_Nonnull out_status
94
+ );
95
+ void uniffi_pubkymobile_fn_func_remove_event_listener(RustCallStatus *_Nonnull out_status
96
+
84
97
  );
85
98
  RustBuffer uniffi_pubkymobile_fn_func_resolve(RustBuffer public_key, RustCallStatus *_Nonnull out_status
86
99
  );
87
100
  RustBuffer uniffi_pubkymobile_fn_func_resolve_https(RustBuffer public_key, RustCallStatus *_Nonnull out_status
88
101
  );
102
+ RustBuffer uniffi_pubkymobile_fn_func_session(RustBuffer pubky, RustCallStatus *_Nonnull out_status
103
+ );
104
+ void uniffi_pubkymobile_fn_func_set_event_listener(uint64_t listener, RustCallStatus *_Nonnull out_status
105
+ );
89
106
  RustBuffer uniffi_pubkymobile_fn_func_sign_in(RustBuffer secret_key, RustCallStatus *_Nonnull out_status
90
107
  );
91
108
  RustBuffer uniffi_pubkymobile_fn_func_sign_out(RustBuffer secret_key, RustCallStatus *_Nonnull out_status
@@ -208,6 +225,15 @@ void ffi_pubkymobile_rust_future_complete_void(void* _Nonnull handle, RustCallSt
208
225
  );
209
226
  uint16_t uniffi_pubkymobile_checksum_func_auth(void
210
227
 
228
+ );
229
+ uint16_t uniffi_pubkymobile_checksum_func_create_recovery_file(void
230
+
231
+ );
232
+ uint16_t uniffi_pubkymobile_checksum_func_decrypt_recovery_file(void
233
+
234
+ );
235
+ uint16_t uniffi_pubkymobile_checksum_func_delete_file(void
236
+
211
237
  );
212
238
  uint16_t uniffi_pubkymobile_checksum_func_generate_secret_key(void
213
239
 
@@ -232,12 +258,21 @@ uint16_t uniffi_pubkymobile_checksum_func_publish_https(void
232
258
  );
233
259
  uint16_t uniffi_pubkymobile_checksum_func_put(void
234
260
 
261
+ );
262
+ uint16_t uniffi_pubkymobile_checksum_func_remove_event_listener(void
263
+
235
264
  );
236
265
  uint16_t uniffi_pubkymobile_checksum_func_resolve(void
237
266
 
238
267
  );
239
268
  uint16_t uniffi_pubkymobile_checksum_func_resolve_https(void
240
269
 
270
+ );
271
+ uint16_t uniffi_pubkymobile_checksum_func_session(void
272
+
273
+ );
274
+ uint16_t uniffi_pubkymobile_checksum_func_set_event_listener(void
275
+
241
276
  );
242
277
  uint16_t uniffi_pubkymobile_checksum_func_sign_in(void
243
278
 
@@ -247,6 +282,9 @@ uint16_t uniffi_pubkymobile_checksum_func_sign_out(void
247
282
  );
248
283
  uint16_t uniffi_pubkymobile_checksum_func_sign_up(void
249
284
 
285
+ );
286
+ uint16_t uniffi_pubkymobile_checksum_method_eventlistener_on_event_occurred(void
287
+
250
288
  );
251
289
  uint32_t ffi_pubkymobile_uniffi_contract_version(void
252
290
 
@@ -1,2 +1,3 @@
1
1
  #import <React/RCTBridgeModule.h>
2
2
  #import <React/RCTViewManager.h>
3
+ #import <React/RCTEventEmitter.h>
package/ios/Pubky.mm CHANGED
@@ -1,6 +1,21 @@
1
1
  #import <React/RCTBridgeModule.h>
2
+ #import <React/RCTEventEmitter.h>
2
3
 
3
- @interface RCT_EXTERN_MODULE(Pubky, NSObject)
4
+ @interface RCT_EXTERN_MODULE(Pubky, RCTEventEmitter)
5
+
6
+ RCT_EXTERN_METHOD(setEventListener:(RCTPromiseResolveBlock)resolve
7
+ withRejecter:(RCTPromiseRejectBlock)reject)
8
+
9
+ RCT_EXTERN_METHOD(removeEventListener:(RCTPromiseResolveBlock)resolve
10
+ withRejecter:(RCTPromiseRejectBlock)reject)
11
+
12
+ RCT_EXTERN_METHOD(deleteFile:(NSString *)url
13
+ withResolver:(RCTPromiseResolveBlock)resolve
14
+ withRejecter:(RCTPromiseRejectBlock)reject)
15
+
16
+ RCT_EXTERN_METHOD(session:(NSString *)pubky
17
+ withResolver:(RCTPromiseResolveBlock)resolve
18
+ withRejecter:(RCTPromiseRejectBlock)reject)
4
19
 
5
20
  RCT_EXTERN_METHOD(auth:(NSString *)url
6
21
  secretKey:(NSString *)secretKey
@@ -64,6 +79,16 @@ RCT_EXTERN_METHOD(getPublicKeyFromSecretKey:(NSString *)secretKey
64
79
  withResolver:(RCTPromiseResolveBlock)resolve
65
80
  withRejecter:(RCTPromiseRejectBlock)reject)
66
81
 
82
+ RCT_EXTERN_METHOD(createRecoveryFile:(NSString *)secretKey
83
+ passphrase:(NSString *)passphrase
84
+ withResolver:(RCTPromiseResolveBlock)resolve
85
+ withRejecter:(RCTPromiseRejectBlock)reject)
86
+
87
+ RCT_EXTERN_METHOD(decryptRecoveryFile:(NSString *)recoveryFile
88
+ passphrase:(NSString *)passphrase
89
+ withResolver:(RCTPromiseResolveBlock)resolve
90
+ withRejecter:(RCTPromiseRejectBlock)reject)
91
+
67
92
  + (BOOL)requiresMainQueueSetup
68
93
  {
69
94
  return NO;
package/ios/Pubky.swift CHANGED
@@ -1,7 +1,46 @@
1
1
  import Foundation
2
+ import React
2
3
 
3
4
  @objc(Pubky)
4
- class Pubky: NSObject {
5
+ class Pubky: RCTEventEmitter {
6
+
7
+ override init() {
8
+ super.init()
9
+ }
10
+
11
+ @objc override static func requiresMainQueueSetup() -> Bool {
12
+ return false
13
+ }
14
+
15
+ override func supportedEvents() -> [String]! {
16
+ return ["PubkyEvent"]
17
+ }
18
+
19
+ class EventListenerImpl: EventListener {
20
+ weak var pubky: Pubky?
21
+
22
+ init(pubky: Pubky) {
23
+ self.pubky = pubky
24
+ }
25
+
26
+ func onEventOccurred(eventData: String) {
27
+ pubky?.sendEvent(withName: "PubkyEvent", body: eventData)
28
+ }
29
+ }
30
+
31
+ @objc(setEventListener:withRejecter:)
32
+ func setEventListener(_ resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
33
+ let listener = EventListenerImpl(pubky: self)
34
+ react_native_pubky.setEventListener(listener: listener)
35
+ resolve(nil)
36
+ }
37
+
38
+ @objc(removeEventListener:withRejecter:)
39
+ func removeEventListener(_ resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
40
+ react_native_pubky.removeEventListener()
41
+ resolve(nil)
42
+ }
43
+
5
44
  @objc(auth:secretKey:withResolver:withRejecter:)
6
45
  func auth(_ url: String, secretKey: String, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
7
46
  Task {
@@ -144,6 +183,30 @@ class Pubky: NSObject {
144
183
  }
145
184
  }
146
185
 
186
+ @objc(deleteFile:withResolver:withRejecter:)
187
+ func deleteFile(_ url: String, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
188
+ Task {
189
+ do {
190
+ let result = try await react_native_pubky.deleteFile(url: url)
191
+ resolve(result)
192
+ } catch {
193
+ reject("list Error", "Failed to deleteFile", error)
194
+ }
195
+ }
196
+ }
197
+
198
+ @objc(session:withResolver:withRejecter:)
199
+ func session(_ pubky: String, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
200
+ Task {
201
+ do {
202
+ let result = react_native_pubky.session(pubky: pubky)
203
+ resolve(result)
204
+ } catch {
205
+ reject("session Error", "Failed to get session", error)
206
+ }
207
+ }
208
+ }
209
+
147
210
  @objc(generateSecretKey:withRejecter:)
148
211
  func generateSecretKey(_ resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
149
212
  Task {
@@ -167,4 +230,24 @@ class Pubky: NSObject {
167
230
  }
168
231
  }
169
232
  }
233
+
234
+ @objc(createRecoveryFile:passphrase:withResolver:withRejecter:)
235
+ func createRecoveryFile(_ secretKey: String, passphrase: String, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
236
+ do {
237
+ let result = react_native_pubky.createRecoveryFile(secretKey: secretKey, passphrase: passphrase)
238
+ resolve(result)
239
+ } catch {
240
+ reject("createRecoveryFile Error", "Failed to create recovery file", error)
241
+ }
242
+ }
243
+
244
+ @objc(decryptRecoveryFile:passphrase:withResolver:withRejecter:)
245
+ func decryptRecoveryFile(_ recoveryFile: String, passphrase: String, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
246
+ do {
247
+ let result = react_native_pubky.decryptRecoveryFile(recoveryFile: recoveryFile, passphrase: passphrase)
248
+ resolve(result)
249
+ } catch {
250
+ reject("decryptRecoveryFile Error", "Failed to decrypt recovery file", error)
251
+ }
252
+ }
170
253
  }