@synonymdev/react-native-pubky 0.2.3 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
package/README.md CHANGED
@@ -12,11 +12,14 @@ npm install @synonymdev/react-native-pubky
12
12
  ### Implemented Methods
13
13
  - [x] [auth](#auth): Authentication functionality.
14
14
  - [x] [parseAuthUrl](#parseAuthUrl): Method to decode an authUrl.
15
+ - [x] [publish](#publish): Functionality to publish content.
16
+ - [x] [resolve](#resolve): Functionality to resolve content.
15
17
  ### Methods to be Implemented
16
- - [ ] publish: Functionality to publish content.
17
- - [ ] resolve: Functionality to resolve content.
18
- - [ ] signIn: Functionality to sign in.
19
- - [ ] signUp: Functionality to sign up.
18
+ - [ ] signIn: Sign-in to a homeserver.
19
+ - [ ] signUp: Sign-up to a homeserver and update Pkarr accordingly.
20
+ - [ ] signOut: Sign-out from a homeserver.
21
+ - [ ] put: Upload a small payload to a given path.
22
+ - [ ] get: Download a small payload from a given path relative to a pubky author.
20
23
 
21
24
 
22
25
  ## Usage
@@ -24,7 +27,10 @@ npm install @synonymdev/react-native-pubky
24
27
  ```js
25
28
  import { auth } from '@synonymdev/react-native-pubky';
26
29
 
27
- const authRes = await auth("pubkyAuthUrl", "secretKey");
30
+ const authRes = await auth(
31
+ 'pubkyauth:///?caps=/pub/pubky.app/:rw,/pub/foo.bar/file:r&secret=U55XnoH6vsMCpx1pxHtt8fReVg4Brvu9C0gUBuw-Jkw&relay=http://167.86.102.121:4173/',
32
+ 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'
33
+ );
28
34
  if (authRes.isErr()) {
29
35
  console.log(authRes.error.message);
30
36
  return;
@@ -43,6 +49,34 @@ if (parseRes.isErr()) {
43
49
  }
44
50
  console.log(parseRes.value);
45
51
  ```
52
+ ### <a name="publish"></a>publish
53
+ ```js
54
+ import { publish } from '@synonymdev/react-native-pubky';
55
+
56
+ const publishRes = await publish(
57
+ 'recordnametest',
58
+ 'recordcontenttest',
59
+ 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'
60
+ );
61
+ if (publishRes.isErr()) {
62
+ console.log(publishRes.error.message);
63
+ return;
64
+ }
65
+ console.log(publishRes.value);
66
+ ```
67
+ ### <a name="resolve"></a>resolve
68
+ ```js
69
+ import { resolve } from '@synonymdev/react-native-pubky';
70
+
71
+ const resolveRes = await resolve(
72
+ 'z4e8s17cou9qmuwen8p1556jzhf1wktmzo6ijsfnri9c4hnrdfty'
73
+ );
74
+ if (resolveRes.isErr()) {
75
+ console.log(resolveRes.error.message);
76
+ return;
77
+ }
78
+ console.log(resolveRes.value);
79
+ ```
46
80
 
47
81
  ## Local Installation
48
82
 
@@ -11,6 +11,13 @@ import kotlinx.coroutines.launch
11
11
  import kotlinx.coroutines.withContext
12
12
  import uniffi.pubkymobile.auth
13
13
  import uniffi.pubkymobile.parseAuthUrl
14
+ import uniffi.pubkymobile.publish
15
+ import uniffi.pubkymobile.resolve
16
+ import uniffi.pubkymobile.signUp
17
+ import uniffi.pubkymobile.signIn
18
+ import uniffi.pubkymobile.signOut
19
+ import uniffi.pubkymobile.put
20
+ import uniffi.pubkymobile.get
14
21
 
15
22
  class PubkyModule(reactContext: ReactApplicationContext) :
16
23
  ReactContextBaseJavaModule(reactContext) {
@@ -51,6 +58,139 @@ class PubkyModule(reactContext: ReactApplicationContext) :
51
58
  }
52
59
  }
53
60
 
61
+ @ReactMethod
62
+ fun publish(recordName: String, recordContent: String, secretKey: String, promise: Promise) {
63
+ CoroutineScope(Dispatchers.IO).launch {
64
+ try {
65
+ val result = publish(recordName, recordContent, secretKey)
66
+ val array = Arguments.createArray().apply {
67
+ result.forEach { pushString(it) }
68
+ }
69
+ withContext(Dispatchers.Main) {
70
+ promise.resolve(array)
71
+ }
72
+ } catch (e: Exception) {
73
+ withContext(Dispatchers.Main) {
74
+ promise.reject("Error", e.message)
75
+ }
76
+ }
77
+ }
78
+ }
79
+
80
+ @ReactMethod
81
+ fun resolve(publicKey: String, promise: Promise) {
82
+ CoroutineScope(Dispatchers.IO).launch {
83
+ try {
84
+ val result = resolve(publicKey)
85
+ val array = Arguments.createArray().apply {
86
+ result.forEach { pushString(it) }
87
+ }
88
+ withContext(Dispatchers.Main) {
89
+ promise.resolve(array)
90
+ }
91
+ } catch (e: Exception) {
92
+ withContext(Dispatchers.Main) {
93
+ promise.reject("Error", e.message)
94
+ }
95
+ }
96
+ }
97
+ }
98
+
99
+ @ReactMethod
100
+ fun signUp(secretKey: String, homeserver: String, promise: Promise) {
101
+ CoroutineScope(Dispatchers.IO).launch {
102
+ try {
103
+ val result = signUp(secretKey, homeserver)
104
+ val array = Arguments.createArray().apply {
105
+ result.forEach { pushString(it) }
106
+ }
107
+ withContext(Dispatchers.Main) {
108
+ promise.resolve(array)
109
+ }
110
+ } catch (e: Exception) {
111
+ withContext(Dispatchers.Main) {
112
+ promise.reject("Error", e.message)
113
+ }
114
+ }
115
+ }
116
+ }
117
+
118
+ @ReactMethod
119
+ fun signIn(secretKey: String, promise: Promise) {
120
+ CoroutineScope(Dispatchers.IO).launch {
121
+ try {
122
+ val result = signIn(secretKey)
123
+ val array = Arguments.createArray().apply {
124
+ result.forEach { pushString(it) }
125
+ }
126
+ withContext(Dispatchers.Main) {
127
+ promise.resolve(array)
128
+ }
129
+ } catch (e: Exception) {
130
+ withContext(Dispatchers.Main) {
131
+ promise.reject("Error", e.message)
132
+ }
133
+ }
134
+ }
135
+ }
136
+
137
+ @ReactMethod
138
+ fun signOut(secretKey: String, promise: Promise) {
139
+ CoroutineScope(Dispatchers.IO).launch {
140
+ try {
141
+ val result = signOut(secretKey)
142
+ val array = Arguments.createArray().apply {
143
+ result.forEach { pushString(it) }
144
+ }
145
+ withContext(Dispatchers.Main) {
146
+ promise.resolve(array)
147
+ }
148
+ } catch (e: Exception) {
149
+ withContext(Dispatchers.Main) {
150
+ promise.reject("Error", e.message)
151
+ }
152
+ }
153
+ }
154
+ }
155
+
156
+ @ReactMethod
157
+ fun put(url: String, content: String, promise: Promise) {
158
+ CoroutineScope(Dispatchers.IO).launch {
159
+ try {
160
+ val result = put(url, content)
161
+ val array = Arguments.createArray().apply {
162
+ result.forEach { pushString(it) }
163
+ }
164
+ withContext(Dispatchers.Main) {
165
+ promise.resolve(array)
166
+ }
167
+ } catch (e: Exception) {
168
+ withContext(Dispatchers.Main) {
169
+ promise.reject("Error", e.message)
170
+ }
171
+ }
172
+ }
173
+ }
174
+
175
+ @ReactMethod
176
+ fun get(url: String, promise: Promise) {
177
+ CoroutineScope(Dispatchers.IO).launch {
178
+ try {
179
+ val result = get(url)
180
+ val array = Arguments.createArray().apply {
181
+ result.forEach { pushString(it) }
182
+ }
183
+ withContext(Dispatchers.Main) {
184
+ promise.resolve(array)
185
+ }
186
+ } catch (e: Exception) {
187
+ withContext(Dispatchers.Main) {
188
+ promise.reject("Error", e.message)
189
+ }
190
+ }
191
+ }
192
+ }
193
+
54
194
  companion object {
55
195
  const val NAME = "Pubky"
56
196
  }
@@ -29,6 +29,9 @@ import java.nio.ByteOrder
29
29
  import java.nio.CharBuffer
30
30
  import java.nio.charset.CodingErrorAction
31
31
  import java.util.concurrent.ConcurrentHashMap
32
+ import kotlin.coroutines.resume
33
+ import kotlinx.coroutines.CancellableContinuation
34
+ import kotlinx.coroutines.suspendCancellableCoroutine
32
35
 
33
36
  // This is a helper for safely working with byte buffers returned from the Rust code.
34
37
  // A rust-owned buffer is represented by its capacity, its current length, and a
@@ -377,14 +380,29 @@ internal interface _UniFFILib : Library {
377
380
  .also { lib: _UniFFILib ->
378
381
  uniffiCheckContractApiVersion(lib)
379
382
  uniffiCheckApiChecksums(lib)
383
+ uniffiRustFutureContinuationCallback.register(lib)
380
384
  }
381
385
  }
382
386
  }
383
387
 
384
388
  fun uniffi_pubkymobile_fn_func_auth(`url`: RustBuffer.ByValue,`secretKey`: RustBuffer.ByValue,_uniffi_out_err: RustCallStatus,
385
389
  ): RustBuffer.ByValue
390
+ fun uniffi_pubkymobile_fn_func_get(`url`: RustBuffer.ByValue,
391
+ ): Pointer
386
392
  fun uniffi_pubkymobile_fn_func_parse_auth_url(`url`: RustBuffer.ByValue,_uniffi_out_err: RustCallStatus,
387
393
  ): RustBuffer.ByValue
394
+ fun uniffi_pubkymobile_fn_func_publish(`recordName`: RustBuffer.ByValue,`recordContent`: RustBuffer.ByValue,`secretKey`: RustBuffer.ByValue,_uniffi_out_err: RustCallStatus,
395
+ ): RustBuffer.ByValue
396
+ fun uniffi_pubkymobile_fn_func_put(`url`: RustBuffer.ByValue,`content`: RustBuffer.ByValue,
397
+ ): Pointer
398
+ fun uniffi_pubkymobile_fn_func_resolve(`publicKey`: RustBuffer.ByValue,_uniffi_out_err: RustCallStatus,
399
+ ): RustBuffer.ByValue
400
+ fun uniffi_pubkymobile_fn_func_sign_in(`secretKey`: RustBuffer.ByValue,
401
+ ): Pointer
402
+ fun uniffi_pubkymobile_fn_func_sign_out(`secretKey`: RustBuffer.ByValue,
403
+ ): Pointer
404
+ fun uniffi_pubkymobile_fn_func_sign_up(`secretKey`: RustBuffer.ByValue,`homeserver`: RustBuffer.ByValue,
405
+ ): Pointer
388
406
  fun ffi_pubkymobile_rustbuffer_alloc(`size`: Int,_uniffi_out_err: RustCallStatus,
389
407
  ): RustBuffer.ByValue
390
408
  fun ffi_pubkymobile_rustbuffer_from_bytes(`bytes`: ForeignBytes.ByValue,_uniffi_out_err: RustCallStatus,
@@ -501,8 +519,22 @@ internal interface _UniFFILib : Library {
501
519
  ): Unit
502
520
  fun uniffi_pubkymobile_checksum_func_auth(
503
521
  ): Short
522
+ fun uniffi_pubkymobile_checksum_func_get(
523
+ ): Short
504
524
  fun uniffi_pubkymobile_checksum_func_parse_auth_url(
505
525
  ): Short
526
+ fun uniffi_pubkymobile_checksum_func_publish(
527
+ ): Short
528
+ fun uniffi_pubkymobile_checksum_func_put(
529
+ ): Short
530
+ fun uniffi_pubkymobile_checksum_func_resolve(
531
+ ): Short
532
+ fun uniffi_pubkymobile_checksum_func_sign_in(
533
+ ): Short
534
+ fun uniffi_pubkymobile_checksum_func_sign_out(
535
+ ): Short
536
+ fun uniffi_pubkymobile_checksum_func_sign_up(
537
+ ): Short
506
538
  fun ffi_pubkymobile_uniffi_contract_version(
507
539
  ): Int
508
540
 
@@ -523,12 +555,77 @@ private fun uniffiCheckApiChecksums(lib: _UniFFILib) {
523
555
  if (lib.uniffi_pubkymobile_checksum_func_auth() != 61378.toShort()) {
524
556
  throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
525
557
  }
558
+ if (lib.uniffi_pubkymobile_checksum_func_get() != 5395.toShort()) {
559
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
560
+ }
526
561
  if (lib.uniffi_pubkymobile_checksum_func_parse_auth_url() != 29088.toShort()) {
527
562
  throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
528
563
  }
564
+ if (lib.uniffi_pubkymobile_checksum_func_publish() != 20156.toShort()) {
565
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
566
+ }
567
+ if (lib.uniffi_pubkymobile_checksum_func_put() != 47594.toShort()) {
568
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
569
+ }
570
+ if (lib.uniffi_pubkymobile_checksum_func_resolve() != 18303.toShort()) {
571
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
572
+ }
573
+ if (lib.uniffi_pubkymobile_checksum_func_sign_in() != 53969.toShort()) {
574
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
575
+ }
576
+ if (lib.uniffi_pubkymobile_checksum_func_sign_out() != 32961.toShort()) {
577
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
578
+ }
579
+ if (lib.uniffi_pubkymobile_checksum_func_sign_up() != 28083.toShort()) {
580
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
581
+ }
529
582
  }
530
583
 
531
584
  // Async support
585
+ // Async return type handlers
586
+
587
+ internal const val UNIFFI_RUST_FUTURE_POLL_READY = 0.toShort()
588
+ internal const val UNIFFI_RUST_FUTURE_POLL_MAYBE_READY = 1.toShort()
589
+
590
+ internal val uniffiContinuationHandleMap = UniFfiHandleMap<CancellableContinuation<Short>>()
591
+
592
+ // FFI type for Rust future continuations
593
+ internal object uniffiRustFutureContinuationCallback: UniFffiRustFutureContinuationCallbackType {
594
+ override fun callback(continuationHandle: USize, pollResult: Short) {
595
+ uniffiContinuationHandleMap.remove(continuationHandle)?.resume(pollResult)
596
+ }
597
+
598
+ internal fun register(lib: _UniFFILib) {
599
+ lib.ffi_pubkymobile_rust_future_continuation_callback_set(this)
600
+ }
601
+ }
602
+
603
+ internal suspend fun<T, F, E: Exception> uniffiRustCallAsync(
604
+ rustFuture: Pointer,
605
+ pollFunc: (Pointer, USize) -> Unit,
606
+ completeFunc: (Pointer, RustCallStatus) -> F,
607
+ freeFunc: (Pointer) -> Unit,
608
+ liftFunc: (F) -> T,
609
+ errorHandler: CallStatusErrorHandler<E>
610
+ ): T {
611
+ try {
612
+ do {
613
+ val pollResult = suspendCancellableCoroutine<Short> { continuation ->
614
+ pollFunc(
615
+ rustFuture,
616
+ uniffiContinuationHandleMap.insert(continuation)
617
+ )
618
+ }
619
+ } while (pollResult != UNIFFI_RUST_FUTURE_POLL_READY);
620
+
621
+ return liftFunc(
622
+ rustCallWithError(errorHandler, { status -> completeFunc(rustFuture, status) })
623
+ )
624
+ } finally {
625
+ freeFunc(rustFuture)
626
+ }
627
+ }
628
+
532
629
 
533
630
  // Public interface members begin here.
534
631
 
@@ -612,6 +709,10 @@ public object FfiConverterSequenceString: FfiConverterRustBuffer<List<String>> {
612
709
  }
613
710
  }
614
711
 
712
+
713
+
714
+
715
+
615
716
  fun `auth`(`url`: String, `secretKey`: String): List<String> {
616
717
  return FfiConverterSequenceString.lift(
617
718
  rustCall() { _status ->
@@ -620,6 +721,20 @@ fun `auth`(`url`: String, `secretKey`: String): List<String> {
620
721
  }
621
722
 
622
723
 
724
+ @Suppress("ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE")
725
+ suspend fun `get`(`url`: String) : List<String> {
726
+ return uniffiRustCallAsync(
727
+ _UniFFILib.INSTANCE.uniffi_pubkymobile_fn_func_get(FfiConverterString.lower(`url`),),
728
+ { future, continuation -> _UniFFILib.INSTANCE.ffi_pubkymobile_rust_future_poll_rust_buffer(future, continuation) },
729
+ { future, continuation -> _UniFFILib.INSTANCE.ffi_pubkymobile_rust_future_complete_rust_buffer(future, continuation) },
730
+ { future -> _UniFFILib.INSTANCE.ffi_pubkymobile_rust_future_free_rust_buffer(future) },
731
+ // lift function
732
+ { FfiConverterSequenceString.lift(it) },
733
+ // Error FFI converter
734
+ NullCallStatusErrorHandler,
735
+ )
736
+ }
737
+
623
738
  fun `parseAuthUrl`(`url`: String): List<String> {
624
739
  return FfiConverterSequenceString.lift(
625
740
  rustCall() { _status ->
@@ -628,3 +743,75 @@ fun `parseAuthUrl`(`url`: String): List<String> {
628
743
  }
629
744
 
630
745
 
746
+ fun `publish`(`recordName`: String, `recordContent`: String, `secretKey`: String): List<String> {
747
+ return FfiConverterSequenceString.lift(
748
+ rustCall() { _status ->
749
+ _UniFFILib.INSTANCE.uniffi_pubkymobile_fn_func_publish(FfiConverterString.lower(`recordName`),FfiConverterString.lower(`recordContent`),FfiConverterString.lower(`secretKey`),_status)
750
+ })
751
+ }
752
+
753
+
754
+ @Suppress("ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE")
755
+ suspend fun `put`(`url`: String, `content`: String) : List<String> {
756
+ return uniffiRustCallAsync(
757
+ _UniFFILib.INSTANCE.uniffi_pubkymobile_fn_func_put(FfiConverterString.lower(`url`),FfiConverterString.lower(`content`),),
758
+ { future, continuation -> _UniFFILib.INSTANCE.ffi_pubkymobile_rust_future_poll_rust_buffer(future, continuation) },
759
+ { future, continuation -> _UniFFILib.INSTANCE.ffi_pubkymobile_rust_future_complete_rust_buffer(future, continuation) },
760
+ { future -> _UniFFILib.INSTANCE.ffi_pubkymobile_rust_future_free_rust_buffer(future) },
761
+ // lift function
762
+ { FfiConverterSequenceString.lift(it) },
763
+ // Error FFI converter
764
+ NullCallStatusErrorHandler,
765
+ )
766
+ }
767
+
768
+ fun `resolve`(`publicKey`: String): List<String> {
769
+ return FfiConverterSequenceString.lift(
770
+ rustCall() { _status ->
771
+ _UniFFILib.INSTANCE.uniffi_pubkymobile_fn_func_resolve(FfiConverterString.lower(`publicKey`),_status)
772
+ })
773
+ }
774
+
775
+
776
+ @Suppress("ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE")
777
+ suspend fun `signIn`(`secretKey`: String) : List<String> {
778
+ return uniffiRustCallAsync(
779
+ _UniFFILib.INSTANCE.uniffi_pubkymobile_fn_func_sign_in(FfiConverterString.lower(`secretKey`),),
780
+ { future, continuation -> _UniFFILib.INSTANCE.ffi_pubkymobile_rust_future_poll_rust_buffer(future, continuation) },
781
+ { future, continuation -> _UniFFILib.INSTANCE.ffi_pubkymobile_rust_future_complete_rust_buffer(future, continuation) },
782
+ { future -> _UniFFILib.INSTANCE.ffi_pubkymobile_rust_future_free_rust_buffer(future) },
783
+ // lift function
784
+ { FfiConverterSequenceString.lift(it) },
785
+ // Error FFI converter
786
+ NullCallStatusErrorHandler,
787
+ )
788
+ }
789
+
790
+ @Suppress("ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE")
791
+ suspend fun `signOut`(`secretKey`: String) : List<String> {
792
+ return uniffiRustCallAsync(
793
+ _UniFFILib.INSTANCE.uniffi_pubkymobile_fn_func_sign_out(FfiConverterString.lower(`secretKey`),),
794
+ { future, continuation -> _UniFFILib.INSTANCE.ffi_pubkymobile_rust_future_poll_rust_buffer(future, continuation) },
795
+ { future, continuation -> _UniFFILib.INSTANCE.ffi_pubkymobile_rust_future_complete_rust_buffer(future, continuation) },
796
+ { future -> _UniFFILib.INSTANCE.ffi_pubkymobile_rust_future_free_rust_buffer(future) },
797
+ // lift function
798
+ { FfiConverterSequenceString.lift(it) },
799
+ // Error FFI converter
800
+ NullCallStatusErrorHandler,
801
+ )
802
+ }
803
+
804
+ @Suppress("ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE")
805
+ suspend fun `signUp`(`secretKey`: String, `homeserver`: String) : List<String> {
806
+ return uniffiRustCallAsync(
807
+ _UniFFILib.INSTANCE.uniffi_pubkymobile_fn_func_sign_up(FfiConverterString.lower(`secretKey`),FfiConverterString.lower(`homeserver`),),
808
+ { future, continuation -> _UniFFILib.INSTANCE.ffi_pubkymobile_rust_future_poll_rust_buffer(future, continuation) },
809
+ { future, continuation -> _UniFFILib.INSTANCE.ffi_pubkymobile_rust_future_complete_rust_buffer(future, continuation) },
810
+ { future -> _UniFFILib.INSTANCE.ffi_pubkymobile_rust_future_free_rust_buffer(future) },
811
+ // lift function
812
+ { FfiConverterSequenceString.lift(it) },
813
+ // Error FFI converter
814
+ NullCallStatusErrorHandler,
815
+ )
816
+ }
817
+
@@ -65,8 +65,22 @@ typedef void (*UniFfiRustFutureContinuation)(void * _Nonnull, int8_t);
65
65
  // Scaffolding functions
66
66
  RustBuffer uniffi_pubkymobile_fn_func_auth(RustBuffer url, RustBuffer secret_key, RustCallStatus *_Nonnull out_status
67
67
  );
68
+ void* _Nonnull uniffi_pubkymobile_fn_func_get(RustBuffer url
69
+ );
68
70
  RustBuffer uniffi_pubkymobile_fn_func_parse_auth_url(RustBuffer url, RustCallStatus *_Nonnull out_status
69
71
  );
72
+ RustBuffer uniffi_pubkymobile_fn_func_publish(RustBuffer record_name, RustBuffer record_content, RustBuffer secret_key, RustCallStatus *_Nonnull out_status
73
+ );
74
+ void* _Nonnull uniffi_pubkymobile_fn_func_put(RustBuffer url, RustBuffer content
75
+ );
76
+ RustBuffer uniffi_pubkymobile_fn_func_resolve(RustBuffer public_key, RustCallStatus *_Nonnull out_status
77
+ );
78
+ void* _Nonnull uniffi_pubkymobile_fn_func_sign_in(RustBuffer secret_key
79
+ );
80
+ void* _Nonnull uniffi_pubkymobile_fn_func_sign_out(RustBuffer secret_key
81
+ );
82
+ void* _Nonnull uniffi_pubkymobile_fn_func_sign_up(RustBuffer secret_key, RustBuffer homeserver
83
+ );
70
84
  RustBuffer ffi_pubkymobile_rustbuffer_alloc(int32_t size, RustCallStatus *_Nonnull out_status
71
85
  );
72
86
  RustBuffer ffi_pubkymobile_rustbuffer_from_bytes(ForeignBytes bytes, RustCallStatus *_Nonnull out_status
@@ -183,9 +197,30 @@ void ffi_pubkymobile_rust_future_complete_void(void* _Nonnull handle, RustCallSt
183
197
  );
184
198
  uint16_t uniffi_pubkymobile_checksum_func_auth(void
185
199
 
200
+ );
201
+ uint16_t uniffi_pubkymobile_checksum_func_get(void
202
+
186
203
  );
187
204
  uint16_t uniffi_pubkymobile_checksum_func_parse_auth_url(void
188
205
 
206
+ );
207
+ uint16_t uniffi_pubkymobile_checksum_func_publish(void
208
+
209
+ );
210
+ uint16_t uniffi_pubkymobile_checksum_func_put(void
211
+
212
+ );
213
+ uint16_t uniffi_pubkymobile_checksum_func_resolve(void
214
+
215
+ );
216
+ uint16_t uniffi_pubkymobile_checksum_func_sign_in(void
217
+
218
+ );
219
+ uint16_t uniffi_pubkymobile_checksum_func_sign_out(void
220
+
221
+ );
222
+ uint16_t uniffi_pubkymobile_checksum_func_sign_up(void
223
+
189
224
  );
190
225
  uint32_t ffi_pubkymobile_uniffi_contract_version(void
191
226
 
@@ -65,8 +65,22 @@ typedef void (*UniFfiRustFutureContinuation)(void * _Nonnull, int8_t);
65
65
  // Scaffolding functions
66
66
  RustBuffer uniffi_pubkymobile_fn_func_auth(RustBuffer url, RustBuffer secret_key, RustCallStatus *_Nonnull out_status
67
67
  );
68
+ void* _Nonnull uniffi_pubkymobile_fn_func_get(RustBuffer url
69
+ );
68
70
  RustBuffer uniffi_pubkymobile_fn_func_parse_auth_url(RustBuffer url, RustCallStatus *_Nonnull out_status
69
71
  );
72
+ RustBuffer uniffi_pubkymobile_fn_func_publish(RustBuffer record_name, RustBuffer record_content, RustBuffer secret_key, RustCallStatus *_Nonnull out_status
73
+ );
74
+ void* _Nonnull uniffi_pubkymobile_fn_func_put(RustBuffer url, RustBuffer content
75
+ );
76
+ RustBuffer uniffi_pubkymobile_fn_func_resolve(RustBuffer public_key, RustCallStatus *_Nonnull out_status
77
+ );
78
+ void* _Nonnull uniffi_pubkymobile_fn_func_sign_in(RustBuffer secret_key
79
+ );
80
+ void* _Nonnull uniffi_pubkymobile_fn_func_sign_out(RustBuffer secret_key
81
+ );
82
+ void* _Nonnull uniffi_pubkymobile_fn_func_sign_up(RustBuffer secret_key, RustBuffer homeserver
83
+ );
70
84
  RustBuffer ffi_pubkymobile_rustbuffer_alloc(int32_t size, RustCallStatus *_Nonnull out_status
71
85
  );
72
86
  RustBuffer ffi_pubkymobile_rustbuffer_from_bytes(ForeignBytes bytes, RustCallStatus *_Nonnull out_status
@@ -183,9 +197,30 @@ void ffi_pubkymobile_rust_future_complete_void(void* _Nonnull handle, RustCallSt
183
197
  );
184
198
  uint16_t uniffi_pubkymobile_checksum_func_auth(void
185
199
 
200
+ );
201
+ uint16_t uniffi_pubkymobile_checksum_func_get(void
202
+
186
203
  );
187
204
  uint16_t uniffi_pubkymobile_checksum_func_parse_auth_url(void
188
205
 
206
+ );
207
+ uint16_t uniffi_pubkymobile_checksum_func_publish(void
208
+
209
+ );
210
+ uint16_t uniffi_pubkymobile_checksum_func_put(void
211
+
212
+ );
213
+ uint16_t uniffi_pubkymobile_checksum_func_resolve(void
214
+
215
+ );
216
+ uint16_t uniffi_pubkymobile_checksum_func_sign_in(void
217
+
218
+ );
219
+ uint16_t uniffi_pubkymobile_checksum_func_sign_out(void
220
+
221
+ );
222
+ uint16_t uniffi_pubkymobile_checksum_func_sign_up(void
223
+
189
224
  );
190
225
  uint32_t ffi_pubkymobile_uniffi_contract_version(void
191
226
 
package/ios/Pubky.mm CHANGED
@@ -11,6 +11,38 @@ RCT_EXTERN_METHOD(parseAuthUrl:(NSString *)url
11
11
  withResolver:(RCTPromiseResolveBlock)resolve
12
12
  withRejecter:(RCTPromiseRejectBlock)reject)
13
13
 
14
+ RCT_EXTERN_METHOD(publish:(NSString *)recordName
15
+ recordContent:(NSString *)recordContent
16
+ secretKey:(NSString *)secretKey
17
+ withResolver:(RCTPromiseResolveBlock)resolve
18
+ withRejecter:(RCTPromiseRejectBlock)reject)
19
+
20
+ RCT_EXTERN_METHOD(resolve:(NSString *)publicKey
21
+ withResolver:(RCTPromiseResolveBlock)resolve
22
+ withRejecter:(RCTPromiseRejectBlock)reject)
23
+
24
+ RCT_EXTERN_METHOD(signUp:(NSString *)secretKey
25
+ homeserver:(NSString *)homeserver
26
+ withResolver:(RCTPromiseResolveBlock)resolve
27
+ withRejecter:(RCTPromiseRejectBlock)reject)
28
+
29
+ RCT_EXTERN_METHOD(signIn:(NSString *)secretKey
30
+ withResolver:(RCTPromiseResolveBlock)resolve
31
+ withRejecter:(RCTPromiseRejectBlock)reject)
32
+
33
+ RCT_EXTERN_METHOD(signOut:(NSString *)secretKey
34
+ withResolver:(RCTPromiseResolveBlock)resolve
35
+ withRejecter:(RCTPromiseRejectBlock)reject)
36
+
37
+ RCT_EXTERN_METHOD(put:(NSString *)url
38
+ content:(NSString *)content
39
+ withResolver:(RCTPromiseResolveBlock)resolve
40
+ withRejecter:(RCTPromiseRejectBlock)reject)
41
+
42
+ RCT_EXTERN_METHOD(get:(NSString *)url
43
+ withResolver:(RCTPromiseResolveBlock)resolve
44
+ withRejecter:(RCTPromiseRejectBlock)reject)
45
+
14
46
  + (BOOL)requiresMainQueueSetup
15
47
  {
16
48
  return NO;