@synonymdev/react-native-pubky 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -5
- package/android/src/main/java/com/pubky/PubkyModule.kt +100 -0
- package/android/src/main/java/uniffi/pubkymobile/pubkymobile.kt +157 -0
- package/android/src/main/jniLibs/arm64-v8a/libpubkymobile.so +0 -0
- package/android/src/main/jniLibs/armeabi-v7a/libpubkymobile.so +0 -0
- package/android/src/main/jniLibs/x86/libpubkymobile.so +0 -0
- package/android/src/main/jniLibs/x86_64/libpubkymobile.so +0 -0
- package/ios/Frameworks/PubkyMobile.xcframework/Info.plist +4 -4
- package/ios/Frameworks/PubkyMobile.xcframework/ios-arm64/Headers/pubkymobileFFI.h +25 -0
- package/ios/Frameworks/PubkyMobile.xcframework/ios-arm64/libpubkymobile.a +0 -0
- package/ios/Frameworks/PubkyMobile.xcframework/ios-arm64-simulator/Headers/pubkymobileFFI.h +25 -0
- package/ios/Frameworks/PubkyMobile.xcframework/ios-arm64-simulator/libpubkymobile.a +0 -0
- package/ios/Pubky.mm +22 -0
- package/ios/Pubky.swift +60 -0
- package/ios/pubkymobile.swift +170 -0
- package/lib/commonjs/index.js +60 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/index.js +55 -0
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/commonjs/src/index.d.ts +5 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/index.d.ts +5 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/index.tsx +66 -0
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
|
-
- [ ]
|
17
|
-
- [ ]
|
18
|
-
- [ ]
|
19
|
-
- [ ]
|
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(
|
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
|
|
@@ -13,6 +13,11 @@ import uniffi.pubkymobile.auth
|
|
13
13
|
import uniffi.pubkymobile.parseAuthUrl
|
14
14
|
import uniffi.pubkymobile.publish
|
15
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
|
16
21
|
|
17
22
|
class PubkyModule(reactContext: ReactApplicationContext) :
|
18
23
|
ReactContextBaseJavaModule(reactContext) {
|
@@ -91,6 +96,101 @@ class PubkyModule(reactContext: ReactApplicationContext) :
|
|
91
96
|
}
|
92
97
|
}
|
93
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
|
+
|
94
194
|
companion object {
|
95
195
|
const val NAME = "Pubky"
|
96
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,18 +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
|
388
394
|
fun uniffi_pubkymobile_fn_func_publish(`recordName`: RustBuffer.ByValue,`recordContent`: RustBuffer.ByValue,`secretKey`: RustBuffer.ByValue,_uniffi_out_err: RustCallStatus,
|
389
395
|
): RustBuffer.ByValue
|
396
|
+
fun uniffi_pubkymobile_fn_func_put(`url`: RustBuffer.ByValue,`content`: RustBuffer.ByValue,
|
397
|
+
): Pointer
|
390
398
|
fun uniffi_pubkymobile_fn_func_resolve(`publicKey`: RustBuffer.ByValue,_uniffi_out_err: RustCallStatus,
|
391
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
|
392
406
|
fun ffi_pubkymobile_rustbuffer_alloc(`size`: Int,_uniffi_out_err: RustCallStatus,
|
393
407
|
): RustBuffer.ByValue
|
394
408
|
fun ffi_pubkymobile_rustbuffer_from_bytes(`bytes`: ForeignBytes.ByValue,_uniffi_out_err: RustCallStatus,
|
@@ -505,12 +519,22 @@ internal interface _UniFFILib : Library {
|
|
505
519
|
): Unit
|
506
520
|
fun uniffi_pubkymobile_checksum_func_auth(
|
507
521
|
): Short
|
522
|
+
fun uniffi_pubkymobile_checksum_func_get(
|
523
|
+
): Short
|
508
524
|
fun uniffi_pubkymobile_checksum_func_parse_auth_url(
|
509
525
|
): Short
|
510
526
|
fun uniffi_pubkymobile_checksum_func_publish(
|
511
527
|
): Short
|
528
|
+
fun uniffi_pubkymobile_checksum_func_put(
|
529
|
+
): Short
|
512
530
|
fun uniffi_pubkymobile_checksum_func_resolve(
|
513
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
|
514
538
|
fun ffi_pubkymobile_uniffi_contract_version(
|
515
539
|
): Int
|
516
540
|
|
@@ -531,18 +555,77 @@ private fun uniffiCheckApiChecksums(lib: _UniFFILib) {
|
|
531
555
|
if (lib.uniffi_pubkymobile_checksum_func_auth() != 61378.toShort()) {
|
532
556
|
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
|
533
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
|
+
}
|
534
561
|
if (lib.uniffi_pubkymobile_checksum_func_parse_auth_url() != 29088.toShort()) {
|
535
562
|
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
|
536
563
|
}
|
537
564
|
if (lib.uniffi_pubkymobile_checksum_func_publish() != 20156.toShort()) {
|
538
565
|
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
|
539
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
|
+
}
|
540
570
|
if (lib.uniffi_pubkymobile_checksum_func_resolve() != 18303.toShort()) {
|
541
571
|
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
|
542
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
|
+
}
|
543
582
|
}
|
544
583
|
|
545
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
|
+
|
546
629
|
|
547
630
|
// Public interface members begin here.
|
548
631
|
|
@@ -626,6 +709,10 @@ public object FfiConverterSequenceString: FfiConverterRustBuffer<List<String>> {
|
|
626
709
|
}
|
627
710
|
}
|
628
711
|
|
712
|
+
|
713
|
+
|
714
|
+
|
715
|
+
|
629
716
|
fun `auth`(`url`: String, `secretKey`: String): List<String> {
|
630
717
|
return FfiConverterSequenceString.lift(
|
631
718
|
rustCall() { _status ->
|
@@ -634,6 +721,20 @@ fun `auth`(`url`: String, `secretKey`: String): List<String> {
|
|
634
721
|
}
|
635
722
|
|
636
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
|
+
|
637
738
|
fun `parseAuthUrl`(`url`: String): List<String> {
|
638
739
|
return FfiConverterSequenceString.lift(
|
639
740
|
rustCall() { _status ->
|
@@ -650,6 +751,20 @@ fun `publish`(`recordName`: String, `recordContent`: String, `secretKey`: String
|
|
650
751
|
}
|
651
752
|
|
652
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
|
+
|
653
768
|
fun `resolve`(`publicKey`: String): List<String> {
|
654
769
|
return FfiConverterSequenceString.lift(
|
655
770
|
rustCall() { _status ->
|
@@ -658,3 +773,45 @@ fun `resolve`(`publicKey`: String): List<String> {
|
|
658
773
|
}
|
659
774
|
|
660
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
|
+
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -10,7 +10,7 @@
|
|
10
10
|
<key>HeadersPath</key>
|
11
11
|
<string>Headers</string>
|
12
12
|
<key>LibraryIdentifier</key>
|
13
|
-
<string>ios-arm64
|
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>
|
@@ -65,12 +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
|
);
|
70
72
|
RustBuffer uniffi_pubkymobile_fn_func_publish(RustBuffer record_name, RustBuffer record_content, RustBuffer secret_key, RustCallStatus *_Nonnull out_status
|
71
73
|
);
|
74
|
+
void* _Nonnull uniffi_pubkymobile_fn_func_put(RustBuffer url, RustBuffer content
|
75
|
+
);
|
72
76
|
RustBuffer uniffi_pubkymobile_fn_func_resolve(RustBuffer public_key, RustCallStatus *_Nonnull out_status
|
73
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
|
+
);
|
74
84
|
RustBuffer ffi_pubkymobile_rustbuffer_alloc(int32_t size, RustCallStatus *_Nonnull out_status
|
75
85
|
);
|
76
86
|
RustBuffer ffi_pubkymobile_rustbuffer_from_bytes(ForeignBytes bytes, RustCallStatus *_Nonnull out_status
|
@@ -187,15 +197,30 @@ void ffi_pubkymobile_rust_future_complete_void(void* _Nonnull handle, RustCallSt
|
|
187
197
|
);
|
188
198
|
uint16_t uniffi_pubkymobile_checksum_func_auth(void
|
189
199
|
|
200
|
+
);
|
201
|
+
uint16_t uniffi_pubkymobile_checksum_func_get(void
|
202
|
+
|
190
203
|
);
|
191
204
|
uint16_t uniffi_pubkymobile_checksum_func_parse_auth_url(void
|
192
205
|
|
193
206
|
);
|
194
207
|
uint16_t uniffi_pubkymobile_checksum_func_publish(void
|
195
208
|
|
209
|
+
);
|
210
|
+
uint16_t uniffi_pubkymobile_checksum_func_put(void
|
211
|
+
|
196
212
|
);
|
197
213
|
uint16_t uniffi_pubkymobile_checksum_func_resolve(void
|
198
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
|
+
|
199
224
|
);
|
200
225
|
uint32_t ffi_pubkymobile_uniffi_contract_version(void
|
201
226
|
|
Binary file
|
@@ -65,12 +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
|
);
|
70
72
|
RustBuffer uniffi_pubkymobile_fn_func_publish(RustBuffer record_name, RustBuffer record_content, RustBuffer secret_key, RustCallStatus *_Nonnull out_status
|
71
73
|
);
|
74
|
+
void* _Nonnull uniffi_pubkymobile_fn_func_put(RustBuffer url, RustBuffer content
|
75
|
+
);
|
72
76
|
RustBuffer uniffi_pubkymobile_fn_func_resolve(RustBuffer public_key, RustCallStatus *_Nonnull out_status
|
73
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
|
+
);
|
74
84
|
RustBuffer ffi_pubkymobile_rustbuffer_alloc(int32_t size, RustCallStatus *_Nonnull out_status
|
75
85
|
);
|
76
86
|
RustBuffer ffi_pubkymobile_rustbuffer_from_bytes(ForeignBytes bytes, RustCallStatus *_Nonnull out_status
|
@@ -187,15 +197,30 @@ void ffi_pubkymobile_rust_future_complete_void(void* _Nonnull handle, RustCallSt
|
|
187
197
|
);
|
188
198
|
uint16_t uniffi_pubkymobile_checksum_func_auth(void
|
189
199
|
|
200
|
+
);
|
201
|
+
uint16_t uniffi_pubkymobile_checksum_func_get(void
|
202
|
+
|
190
203
|
);
|
191
204
|
uint16_t uniffi_pubkymobile_checksum_func_parse_auth_url(void
|
192
205
|
|
193
206
|
);
|
194
207
|
uint16_t uniffi_pubkymobile_checksum_func_publish(void
|
195
208
|
|
209
|
+
);
|
210
|
+
uint16_t uniffi_pubkymobile_checksum_func_put(void
|
211
|
+
|
196
212
|
);
|
197
213
|
uint16_t uniffi_pubkymobile_checksum_func_resolve(void
|
198
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
|
+
|
199
224
|
);
|
200
225
|
uint32_t ffi_pubkymobile_uniffi_contract_version(void
|
201
226
|
|
Binary file
|
package/ios/Pubky.mm
CHANGED
@@ -21,6 +21,28 @@ RCT_EXTERN_METHOD(resolve:(NSString *)publicKey
|
|
21
21
|
withResolver:(RCTPromiseResolveBlock)resolve
|
22
22
|
withRejecter:(RCTPromiseRejectBlock)reject)
|
23
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
|
+
|
24
46
|
+ (BOOL)requiresMainQueueSetup
|
25
47
|
{
|
26
48
|
return NO;
|
package/ios/Pubky.swift
CHANGED
@@ -49,4 +49,64 @@ class Pubky: NSObject {
|
|
49
49
|
}
|
50
50
|
}
|
51
51
|
}
|
52
|
+
|
53
|
+
@objc(signUp:homeserver:withResolver:withRejecter:)
|
54
|
+
func signUp(_ secretKey: String, homeserver: String, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
|
55
|
+
Task {
|
56
|
+
do {
|
57
|
+
let result = try await react_native_pubky.signUp(secretKey: secretKey, homeserver: homeserver)
|
58
|
+
resolve(result)
|
59
|
+
} catch {
|
60
|
+
reject("signUp Error", "Failed to sign up", error)
|
61
|
+
}
|
62
|
+
}
|
63
|
+
}
|
64
|
+
|
65
|
+
@objc(signIn:withResolver:withRejecter:)
|
66
|
+
func signIn(_ secretKey: String, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
|
67
|
+
Task {
|
68
|
+
do {
|
69
|
+
let result = try await react_native_pubky.signIn(secretKey: secretKey)
|
70
|
+
resolve(result)
|
71
|
+
} catch {
|
72
|
+
reject("signIn Error", "Failed to sign in", error)
|
73
|
+
}
|
74
|
+
}
|
75
|
+
}
|
76
|
+
|
77
|
+
@objc(signOut:withResolver:withRejecter:)
|
78
|
+
func signOut(_ secretKey: String, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
|
79
|
+
Task {
|
80
|
+
do {
|
81
|
+
let result = try await react_native_pubky.signOut(secretKey: secretKey)
|
82
|
+
resolve(result)
|
83
|
+
} catch {
|
84
|
+
reject("signOut Error", "Failed to sign out", error)
|
85
|
+
}
|
86
|
+
}
|
87
|
+
}
|
88
|
+
|
89
|
+
@objc(put:content:withResolver:withRejecter:)
|
90
|
+
func put(_ url: String, content: String, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
|
91
|
+
Task {
|
92
|
+
do {
|
93
|
+
let result = try await react_native_pubky.put(url: url, content: content)
|
94
|
+
resolve(result)
|
95
|
+
} catch {
|
96
|
+
reject("put Error", "Failed to put", error)
|
97
|
+
}
|
98
|
+
}
|
99
|
+
}
|
100
|
+
|
101
|
+
@objc(get:withResolver:withRejecter:)
|
102
|
+
func get(_ url: String, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
|
103
|
+
Task {
|
104
|
+
do {
|
105
|
+
let result = try await react_native_pubky.get(url: url)
|
106
|
+
resolve(result)
|
107
|
+
} catch {
|
108
|
+
reject("get Error", "Failed to get", error)
|
109
|
+
}
|
110
|
+
}
|
111
|
+
}
|
52
112
|
}
|
package/ios/pubkymobile.swift
CHANGED
@@ -356,6 +356,68 @@ fileprivate struct FfiConverterSequenceString: FfiConverterRustBuffer {
|
|
356
356
|
return seq
|
357
357
|
}
|
358
358
|
}
|
359
|
+
private let UNIFFI_RUST_FUTURE_POLL_READY: Int8 = 0
|
360
|
+
private let UNIFFI_RUST_FUTURE_POLL_MAYBE_READY: Int8 = 1
|
361
|
+
|
362
|
+
fileprivate func uniffiRustCallAsync<F, T>(
|
363
|
+
rustFutureFunc: () -> UnsafeMutableRawPointer,
|
364
|
+
pollFunc: (UnsafeMutableRawPointer, UnsafeMutableRawPointer) -> (),
|
365
|
+
completeFunc: (UnsafeMutableRawPointer, UnsafeMutablePointer<RustCallStatus>) -> F,
|
366
|
+
freeFunc: (UnsafeMutableRawPointer) -> (),
|
367
|
+
liftFunc: (F) throws -> T,
|
368
|
+
errorHandler: ((RustBuffer) throws -> Error)?
|
369
|
+
) async throws -> T {
|
370
|
+
// Make sure to call uniffiEnsureInitialized() since future creation doesn't have a
|
371
|
+
// RustCallStatus param, so doesn't use makeRustCall()
|
372
|
+
uniffiEnsureInitialized()
|
373
|
+
let rustFuture = rustFutureFunc()
|
374
|
+
defer {
|
375
|
+
freeFunc(rustFuture)
|
376
|
+
}
|
377
|
+
var pollResult: Int8;
|
378
|
+
repeat {
|
379
|
+
pollResult = await withUnsafeContinuation {
|
380
|
+
pollFunc(rustFuture, ContinuationHolder($0).toOpaque())
|
381
|
+
}
|
382
|
+
} while pollResult != UNIFFI_RUST_FUTURE_POLL_READY
|
383
|
+
|
384
|
+
return try liftFunc(makeRustCall(
|
385
|
+
{ completeFunc(rustFuture, $0) },
|
386
|
+
errorHandler: errorHandler
|
387
|
+
))
|
388
|
+
}
|
389
|
+
|
390
|
+
// Callback handlers for an async calls. These are invoked by Rust when the future is ready. They
|
391
|
+
// lift the return value or error and resume the suspended function.
|
392
|
+
fileprivate func uniffiFutureContinuationCallback(ptr: UnsafeMutableRawPointer, pollResult: Int8) {
|
393
|
+
ContinuationHolder.fromOpaque(ptr).resume(pollResult)
|
394
|
+
}
|
395
|
+
|
396
|
+
// Wraps UnsafeContinuation in a class so that we can use reference counting when passing it across
|
397
|
+
// the FFI
|
398
|
+
fileprivate class ContinuationHolder {
|
399
|
+
let continuation: UnsafeContinuation<Int8, Never>
|
400
|
+
|
401
|
+
init(_ continuation: UnsafeContinuation<Int8, Never>) {
|
402
|
+
self.continuation = continuation
|
403
|
+
}
|
404
|
+
|
405
|
+
func resume(_ pollResult: Int8) {
|
406
|
+
self.continuation.resume(returning: pollResult)
|
407
|
+
}
|
408
|
+
|
409
|
+
func toOpaque() -> UnsafeMutableRawPointer {
|
410
|
+
return Unmanaged<ContinuationHolder>.passRetained(self).toOpaque()
|
411
|
+
}
|
412
|
+
|
413
|
+
static func fromOpaque(_ ptr: UnsafeRawPointer) -> ContinuationHolder {
|
414
|
+
return Unmanaged<ContinuationHolder>.fromOpaque(ptr).takeRetainedValue()
|
415
|
+
}
|
416
|
+
}
|
417
|
+
|
418
|
+
fileprivate func uniffiInitContinuationCallback() {
|
419
|
+
ffi_pubkymobile_rust_future_continuation_callback_set(uniffiFutureContinuationCallback)
|
420
|
+
}
|
359
421
|
|
360
422
|
public func auth(url: String, secretKey: String) -> [String] {
|
361
423
|
return try! FfiConverterSequenceString.lift(
|
@@ -367,6 +429,24 @@ public func auth(url: String, secretKey: String) -> [String] {
|
|
367
429
|
)
|
368
430
|
}
|
369
431
|
|
432
|
+
public func get(url: String) async -> [String] {
|
433
|
+
return try! await uniffiRustCallAsync(
|
434
|
+
rustFutureFunc: {
|
435
|
+
uniffi_pubkymobile_fn_func_get(
|
436
|
+
FfiConverterString.lower(url)
|
437
|
+
)
|
438
|
+
},
|
439
|
+
pollFunc: ffi_pubkymobile_rust_future_poll_rust_buffer,
|
440
|
+
completeFunc: ffi_pubkymobile_rust_future_complete_rust_buffer,
|
441
|
+
freeFunc: ffi_pubkymobile_rust_future_free_rust_buffer,
|
442
|
+
liftFunc: FfiConverterSequenceString.lift,
|
443
|
+
errorHandler: nil
|
444
|
+
|
445
|
+
)
|
446
|
+
}
|
447
|
+
|
448
|
+
|
449
|
+
|
370
450
|
public func parseAuthUrl(url: String) -> [String] {
|
371
451
|
return try! FfiConverterSequenceString.lift(
|
372
452
|
try! rustCall() {
|
@@ -387,6 +467,25 @@ public func publish(recordName: String, recordContent: String, secretKey: String
|
|
387
467
|
)
|
388
468
|
}
|
389
469
|
|
470
|
+
public func put(url: String, content: String) async -> [String] {
|
471
|
+
return try! await uniffiRustCallAsync(
|
472
|
+
rustFutureFunc: {
|
473
|
+
uniffi_pubkymobile_fn_func_put(
|
474
|
+
FfiConverterString.lower(url),
|
475
|
+
FfiConverterString.lower(content)
|
476
|
+
)
|
477
|
+
},
|
478
|
+
pollFunc: ffi_pubkymobile_rust_future_poll_rust_buffer,
|
479
|
+
completeFunc: ffi_pubkymobile_rust_future_complete_rust_buffer,
|
480
|
+
freeFunc: ffi_pubkymobile_rust_future_free_rust_buffer,
|
481
|
+
liftFunc: FfiConverterSequenceString.lift,
|
482
|
+
errorHandler: nil
|
483
|
+
|
484
|
+
)
|
485
|
+
}
|
486
|
+
|
487
|
+
|
488
|
+
|
390
489
|
public func resolve(publicKey: String) -> [String] {
|
391
490
|
return try! FfiConverterSequenceString.lift(
|
392
491
|
try! rustCall() {
|
@@ -396,6 +495,61 @@ public func resolve(publicKey: String) -> [String] {
|
|
396
495
|
)
|
397
496
|
}
|
398
497
|
|
498
|
+
public func signIn(secretKey: String) async -> [String] {
|
499
|
+
return try! await uniffiRustCallAsync(
|
500
|
+
rustFutureFunc: {
|
501
|
+
uniffi_pubkymobile_fn_func_sign_in(
|
502
|
+
FfiConverterString.lower(secretKey)
|
503
|
+
)
|
504
|
+
},
|
505
|
+
pollFunc: ffi_pubkymobile_rust_future_poll_rust_buffer,
|
506
|
+
completeFunc: ffi_pubkymobile_rust_future_complete_rust_buffer,
|
507
|
+
freeFunc: ffi_pubkymobile_rust_future_free_rust_buffer,
|
508
|
+
liftFunc: FfiConverterSequenceString.lift,
|
509
|
+
errorHandler: nil
|
510
|
+
|
511
|
+
)
|
512
|
+
}
|
513
|
+
|
514
|
+
|
515
|
+
|
516
|
+
public func signOut(secretKey: String) async -> [String] {
|
517
|
+
return try! await uniffiRustCallAsync(
|
518
|
+
rustFutureFunc: {
|
519
|
+
uniffi_pubkymobile_fn_func_sign_out(
|
520
|
+
FfiConverterString.lower(secretKey)
|
521
|
+
)
|
522
|
+
},
|
523
|
+
pollFunc: ffi_pubkymobile_rust_future_poll_rust_buffer,
|
524
|
+
completeFunc: ffi_pubkymobile_rust_future_complete_rust_buffer,
|
525
|
+
freeFunc: ffi_pubkymobile_rust_future_free_rust_buffer,
|
526
|
+
liftFunc: FfiConverterSequenceString.lift,
|
527
|
+
errorHandler: nil
|
528
|
+
|
529
|
+
)
|
530
|
+
}
|
531
|
+
|
532
|
+
|
533
|
+
|
534
|
+
public func signUp(secretKey: String, homeserver: String) async -> [String] {
|
535
|
+
return try! await uniffiRustCallAsync(
|
536
|
+
rustFutureFunc: {
|
537
|
+
uniffi_pubkymobile_fn_func_sign_up(
|
538
|
+
FfiConverterString.lower(secretKey),
|
539
|
+
FfiConverterString.lower(homeserver)
|
540
|
+
)
|
541
|
+
},
|
542
|
+
pollFunc: ffi_pubkymobile_rust_future_poll_rust_buffer,
|
543
|
+
completeFunc: ffi_pubkymobile_rust_future_complete_rust_buffer,
|
544
|
+
freeFunc: ffi_pubkymobile_rust_future_free_rust_buffer,
|
545
|
+
liftFunc: FfiConverterSequenceString.lift,
|
546
|
+
errorHandler: nil
|
547
|
+
|
548
|
+
)
|
549
|
+
}
|
550
|
+
|
551
|
+
|
552
|
+
|
399
553
|
private enum InitializationResult {
|
400
554
|
case ok
|
401
555
|
case contractVersionMismatch
|
@@ -414,16 +568,32 @@ private var initializationResult: InitializationResult {
|
|
414
568
|
if (uniffi_pubkymobile_checksum_func_auth() != 61378) {
|
415
569
|
return InitializationResult.apiChecksumMismatch
|
416
570
|
}
|
571
|
+
if (uniffi_pubkymobile_checksum_func_get() != 5395) {
|
572
|
+
return InitializationResult.apiChecksumMismatch
|
573
|
+
}
|
417
574
|
if (uniffi_pubkymobile_checksum_func_parse_auth_url() != 29088) {
|
418
575
|
return InitializationResult.apiChecksumMismatch
|
419
576
|
}
|
420
577
|
if (uniffi_pubkymobile_checksum_func_publish() != 20156) {
|
421
578
|
return InitializationResult.apiChecksumMismatch
|
422
579
|
}
|
580
|
+
if (uniffi_pubkymobile_checksum_func_put() != 47594) {
|
581
|
+
return InitializationResult.apiChecksumMismatch
|
582
|
+
}
|
423
583
|
if (uniffi_pubkymobile_checksum_func_resolve() != 18303) {
|
424
584
|
return InitializationResult.apiChecksumMismatch
|
425
585
|
}
|
586
|
+
if (uniffi_pubkymobile_checksum_func_sign_in() != 53969) {
|
587
|
+
return InitializationResult.apiChecksumMismatch
|
588
|
+
}
|
589
|
+
if (uniffi_pubkymobile_checksum_func_sign_out() != 32961) {
|
590
|
+
return InitializationResult.apiChecksumMismatch
|
591
|
+
}
|
592
|
+
if (uniffi_pubkymobile_checksum_func_sign_up() != 28083) {
|
593
|
+
return InitializationResult.apiChecksumMismatch
|
594
|
+
}
|
426
595
|
|
596
|
+
uniffiInitContinuationCallback()
|
427
597
|
return InitializationResult.ok
|
428
598
|
}
|
429
599
|
|
package/lib/commonjs/index.js
CHANGED
@@ -4,9 +4,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.auth = auth;
|
7
|
+
exports.get = get;
|
7
8
|
exports.parseAuthUrl = parseAuthUrl;
|
8
9
|
exports.publish = publish;
|
10
|
+
exports.put = put;
|
9
11
|
exports.resolve = resolve;
|
12
|
+
exports.signIn = signIn;
|
13
|
+
exports.signOut = signOut;
|
14
|
+
exports.signUp = signUp;
|
10
15
|
var _reactNative = require("react-native");
|
11
16
|
var _result = require("@synonymdev/result");
|
12
17
|
const LINKING_ERROR = `The package 'react-native-pubky' doesn't seem to be linked. Make sure: \n\n` + _reactNative.Platform.select({
|
@@ -59,4 +64,59 @@ async function resolve(publicKey) {
|
|
59
64
|
return (0, _result.err)(JSON.stringify(e));
|
60
65
|
}
|
61
66
|
}
|
67
|
+
async function signUp(secretKey, homeserver) {
|
68
|
+
try {
|
69
|
+
const res = await Pubky.signUp(secretKey, homeserver);
|
70
|
+
if (res[0] === 'error') {
|
71
|
+
return (0, _result.err)(res[1]);
|
72
|
+
}
|
73
|
+
return (0, _result.ok)(res[1]);
|
74
|
+
} catch (e) {
|
75
|
+
return (0, _result.err)(JSON.stringify(e));
|
76
|
+
}
|
77
|
+
}
|
78
|
+
async function signIn(secretKey) {
|
79
|
+
try {
|
80
|
+
const res = await Pubky.signIn(secretKey);
|
81
|
+
if (res[0] === 'error') {
|
82
|
+
return (0, _result.err)(res[1]);
|
83
|
+
}
|
84
|
+
return (0, _result.ok)(res[1]);
|
85
|
+
} catch (e) {
|
86
|
+
return (0, _result.err)(JSON.stringify(e));
|
87
|
+
}
|
88
|
+
}
|
89
|
+
async function signOut(secretKey) {
|
90
|
+
try {
|
91
|
+
const res = await Pubky.signOut(secretKey);
|
92
|
+
if (res[0] === 'error') {
|
93
|
+
return (0, _result.err)(res[1]);
|
94
|
+
}
|
95
|
+
return (0, _result.ok)(res[1]);
|
96
|
+
} catch (e) {
|
97
|
+
return (0, _result.err)(JSON.stringify(e));
|
98
|
+
}
|
99
|
+
}
|
100
|
+
async function get(url) {
|
101
|
+
try {
|
102
|
+
const res = await Pubky.get(url);
|
103
|
+
if (res[0] === 'error') {
|
104
|
+
return (0, _result.err)(res[1]);
|
105
|
+
}
|
106
|
+
return (0, _result.ok)(JSON.parse(res[1]));
|
107
|
+
} catch (e) {
|
108
|
+
return (0, _result.err)(JSON.stringify(e));
|
109
|
+
}
|
110
|
+
}
|
111
|
+
async function put(url, content) {
|
112
|
+
try {
|
113
|
+
const res = await Pubky.put(url, JSON.stringify(content));
|
114
|
+
if (res[0] === 'error') {
|
115
|
+
return (0, _result.err)(res[1]);
|
116
|
+
}
|
117
|
+
return (0, _result.ok)(res[1]);
|
118
|
+
} catch (e) {
|
119
|
+
return (0, _result.err)(JSON.stringify(e));
|
120
|
+
}
|
121
|
+
}
|
62
122
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_result","LINKING_ERROR","Platform","select","ios","default","Pubky","NativeModules","Proxy","get","Error","auth","url","secretKey","res","err","ok","parseAuthUrl","parsed","JSON","parse","e","stringify","publish","recordName","recordContent","resolve","publicKey"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"
|
1
|
+
{"version":3,"names":["_reactNative","require","_result","LINKING_ERROR","Platform","select","ios","default","Pubky","NativeModules","Proxy","get","Error","auth","url","secretKey","res","err","ok","parseAuthUrl","parsed","JSON","parse","e","stringify","publish","recordName","recordContent","resolve","publicKey","signUp","homeserver","signIn","signOut","put","content"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAEA,MAAME,aAAa,GACjB,6EAA6E,GAC7EC,qBAAQ,CAACC,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;AAEjC,MAAMC,KAAK,GAAGC,0BAAa,CAACD,KAAK,GAC7BC,0BAAa,CAACD,KAAK,GACnB,IAAIE,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACT,aAAa,CAAC;EAChC;AACF,CACF,CAAC;AAEE,eAAeU,IAAIA,CACxBC,GAAW,EACXC,SAAiB,EACU;EAC3B,MAAMC,GAAG,GAAG,MAAMR,KAAK,CAACK,IAAI,CAACC,GAAG,EAAEC,SAAS,CAAC;EAC5C,IAAIC,GAAG,CAAC,CAAC,CAAC,KAAK,OAAO,EAAE;IACtB,OAAO,IAAAC,WAAG,EAACD,GAAG,CAAC,CAAC,CAAC,CAAC;EACpB;EACA,OAAO,IAAAE,UAAE,EAACF,GAAG,CAAC,CAAC,CAAC,CAAC;AACnB;AAaO,eAAeG,YAAYA,CAChCL,GAAW,EACwB;EACnC,IAAI;IACF,MAAME,GAAG,GAAG,MAAMR,KAAK,CAACW,YAAY,CAACL,GAAG,CAAC;IACzC,IAAIE,GAAG,CAAC,CAAC,CAAC,KAAK,OAAO,EAAE;MACtB,OAAO,IAAAC,WAAG,EAACD,GAAG,CAAC,CAAC,CAAC,CAAC;IACpB;IACA,MAAMI,MAAM,GAAGC,IAAI,CAACC,KAAK,CAACN,GAAG,CAAC,CAAC,CAAC,CAAC;IACjC,OAAO,IAAAE,UAAE,EAACE,MAAM,CAAC;EAC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,KAAK,CAACG,GAAG,CAACG,GAAG,CAAC;IAChC,IAAIE,GAAG,CAAC,CAAC,CAAC,KAAK,OAAO,EAAE;MACtB,OAAO,IAAAC,WAAG,EAACD,GAAG,CAAC,CAAC,CAAC,CAAC;IACpB;IACA,OAAO,IAAAE,UAAE,EAACG,IAAI,CAACC,KAAK,CAACN,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;EAC/B,CAAC,CAAC,OAAOO,CAAC,EAAE;IACV,OAAO,IAAAN,WAAG,EAACI,IAAI,CAACG,SAAS,CAACD,CAAC,CAAC,CAAC;EAC/B;AACF;AAEO,eAAeW,GAAGA,CACvBpB,GAAW,EACXqB,OAAe,EACY;EAC3B,IAAI;IACF,MAAMnB,GAAG,GAAG,MAAMR,KAAK,CAAC0B,GAAG,CAACpB,GAAG,EAAEO,IAAI,CAACG,SAAS,CAACW,OAAO,CAAC,CAAC;IACzD,IAAInB,GAAG,CAAC,CAAC,CAAC,KAAK,OAAO,EAAE;MACtB,OAAO,IAAAC,WAAG,EAACD,GAAG,CAAC,CAAC,CAAC,CAAC;IACpB;IACA,OAAO,IAAAE,UAAE,EAACF,GAAG,CAAC,CAAC,CAAC,CAAC;EACnB,CAAC,CAAC,OAAOO,CAAC,EAAE;IACV,OAAO,IAAAN,WAAG,EAACI,IAAI,CAACG,SAAS,CAACD,CAAC,CAAC,CAAC;EAC/B;AACF","ignoreList":[]}
|
package/lib/module/index.js
CHANGED
@@ -52,4 +52,59 @@ export async function resolve(publicKey) {
|
|
52
52
|
return err(JSON.stringify(e));
|
53
53
|
}
|
54
54
|
}
|
55
|
+
export async function signUp(secretKey, homeserver) {
|
56
|
+
try {
|
57
|
+
const res = await Pubky.signUp(secretKey, homeserver);
|
58
|
+
if (res[0] === 'error') {
|
59
|
+
return err(res[1]);
|
60
|
+
}
|
61
|
+
return ok(res[1]);
|
62
|
+
} catch (e) {
|
63
|
+
return err(JSON.stringify(e));
|
64
|
+
}
|
65
|
+
}
|
66
|
+
export async function signIn(secretKey) {
|
67
|
+
try {
|
68
|
+
const res = await Pubky.signIn(secretKey);
|
69
|
+
if (res[0] === 'error') {
|
70
|
+
return err(res[1]);
|
71
|
+
}
|
72
|
+
return ok(res[1]);
|
73
|
+
} catch (e) {
|
74
|
+
return err(JSON.stringify(e));
|
75
|
+
}
|
76
|
+
}
|
77
|
+
export async function signOut(secretKey) {
|
78
|
+
try {
|
79
|
+
const res = await Pubky.signOut(secretKey);
|
80
|
+
if (res[0] === 'error') {
|
81
|
+
return err(res[1]);
|
82
|
+
}
|
83
|
+
return ok(res[1]);
|
84
|
+
} catch (e) {
|
85
|
+
return err(JSON.stringify(e));
|
86
|
+
}
|
87
|
+
}
|
88
|
+
export async function get(url) {
|
89
|
+
try {
|
90
|
+
const res = await Pubky.get(url);
|
91
|
+
if (res[0] === 'error') {
|
92
|
+
return err(res[1]);
|
93
|
+
}
|
94
|
+
return ok(JSON.parse(res[1]));
|
95
|
+
} catch (e) {
|
96
|
+
return err(JSON.stringify(e));
|
97
|
+
}
|
98
|
+
}
|
99
|
+
export async function put(url, content) {
|
100
|
+
try {
|
101
|
+
const res = await Pubky.put(url, JSON.stringify(content));
|
102
|
+
if (res[0] === 'error') {
|
103
|
+
return err(res[1]);
|
104
|
+
}
|
105
|
+
return ok(res[1]);
|
106
|
+
} catch (e) {
|
107
|
+
return err(JSON.stringify(e));
|
108
|
+
}
|
109
|
+
}
|
55
110
|
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["NativeModules","Platform","ok","err","LINKING_ERROR","select","ios","default","Pubky","Proxy","get","Error","auth","url","secretKey","res","parseAuthUrl","parsed","JSON","parse","e","stringify","publish","recordName","recordContent","resolve","publicKey"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,SAASA,aAAa,EAAEC,QAAQ,QAAQ,cAAc;AACtD,SAASC,EAAE,EAAEC,GAAG,QAAqB,oBAAoB;AAEzD,MAA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AC3B,IAAI;IACF,MAAMC,GAAG,GAAG,MAAMP,KAAK,CAACc,OAAO,CAACC,UAAU,EAAEC,aAAa,EAAEV,SAAS,CAAC;IACrE,IAAIC,GAAG,CAAC,CAAC,CAAC,KAAK,OAAO,EAAE;MACtB,OAAOZ,GAAG,CAACY,GAAG,CAAC,CAAC,CAAC,CAAC;IACpB;IACA,OAAOb,EAAE,CAACa,GAAG,CAAC,CAAC,CAAC,CAAC;EACnB,CAAC,CAAC,OAAOK,CAAC,EAAE;IACV,OAAOjB,GAAG,CAACe,IAAI,CAACG,SAAS,CAACD,CAAC,CAAC,CAAC;EAC/B;AACF;AAmBA,OAAO,eAAeK,OAAOA,CAACC,SAAiB,EAA+B;EAC5E,IAAI;IACF,MAAMX,GAAG,GAAG,MAAMP,KAAK,CAACiB,OAAO,CAACC,SAAS,CAAC;IAC1C,IAAIX,GAAG,CAAC,CAAC,CAAC,KAAK,OAAO,EAAE;MACtB,OAAOZ,GAAG,CAACY,GAAG,CAAC,CAAC,CAAC,CAAC;IACpB;IACA,OAAOb,EAAE,CAACgB,IAAI,CAACC,KAAK,CAACJ,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;EAC/B,CAAC,CAAC,OAAOK,CAAC,EAAE;IACV,OAAOjB,GAAG,CAACe,IAAI,CAACG,SAAS,CAACD,CAAC,CAAC,CAAC;EAC/B;AACF","ignoreList":[]}
|
1
|
+
{"version":3,"names":["NativeModules","Platform","ok","err","LINKING_ERROR","select","ios","default","Pubky","Proxy","get","Error","auth","url","secretKey","res","parseAuthUrl","parsed","JSON","parse","e","stringify","publish","recordName","recordContent","resolve","publicKey","signUp","homeserver","signIn","signOut","put","content"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,SAASA,aAAa,EAAEC,QAAQ,QAAQ,cAAc;AACtD,SAASC,EAAE,EAAEC,GAAG,QAAqB,oBAAoB;AAEzD,MAAMC,aAAa,GACjB,6EAA6E,GAC7EH,QAAQ,CAACI,MAAM,CAA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AACe,IAAI,CAACG,SAAS,CAACD,CAAC,CAAC,CAAC;EAC/B;AACF;AAEA,OAAO,eAAeW,GAAGA,CACvBlB,GAAW,EACXmB,OAAe,EACY;EAC3B,IAAI;IACF,MAAMjB,GAAG,GAAG,MAAMP,KAAK,CAACuB,GAAG,CAAClB,GAAG,EAAEK,IAAI,CAACG,SAAS,CAACW,OAAO,CAAC,CAAC;IACzD,IAAIjB,GAAG,CAAC,CAAC,CAAC,KAAK,OAAO,EAAE;MACtB,OAAOZ,GAAG,CAACY,GAAG,CAAC,CAAC,CAAC,CAAC;IACpB;IACA,OAAOb,EAAE,CAACa,GAAG,CAAC,CAAC,CAAC,CAAC;EACnB,CAAC,CAAC,OAAOK,CAAC,EAAE;IACV,OAAOjB,GAAG,CAACe,IAAI,CAACG,SAAS,CAACD,CAAC,CAAC,CAAC;EAC/B;AACF","ignoreList":[]}
|
@@ -29,5 +29,10 @@ interface IDNSPacket {
|
|
29
29
|
timestamp: number;
|
30
30
|
}
|
31
31
|
export declare function resolve(publicKey: string): Promise<Result<IDNSPacket>>;
|
32
|
+
export declare function signUp(secretKey: string, homeserver: string): Promise<Result<string[]>>;
|
33
|
+
export declare function signIn(secretKey: string): Promise<Result<string[]>>;
|
34
|
+
export declare function signOut(secretKey: string): Promise<Result<string[]>>;
|
35
|
+
export declare function get(url: string): Promise<Result<string[]>>;
|
36
|
+
export declare function put(url: string, content: Object): Promise<Result<string[]>>;
|
32
37
|
export {};
|
33
38
|
//# sourceMappingURL=index.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAW,KAAK,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAmB1D,wBAAsB,IAAI,CACxB,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAM3B;AAED,KAAK,UA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,CAUzE;AAED,wBAAsB,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAU1E;AAED,wBAAsB,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAUhE;AAED,wBAAsB,GAAG,CACvB,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAU3B"}
|
@@ -29,5 +29,10 @@ interface IDNSPacket {
|
|
29
29
|
timestamp: number;
|
30
30
|
}
|
31
31
|
export declare function resolve(publicKey: string): Promise<Result<IDNSPacket>>;
|
32
|
+
export declare function signUp(secretKey: string, homeserver: string): Promise<Result<string[]>>;
|
33
|
+
export declare function signIn(secretKey: string): Promise<Result<string[]>>;
|
34
|
+
export declare function signOut(secretKey: string): Promise<Result<string[]>>;
|
35
|
+
export declare function get(url: string): Promise<Result<string[]>>;
|
36
|
+
export declare function put(url: string, content: Object): Promise<Result<string[]>>;
|
32
37
|
export {};
|
33
38
|
//# sourceMappingURL=index.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAW,KAAK,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAmB1D,wBAAsB,IAAI,CACxB,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAM3B;AAED,KAAK,UAAU,GAAG;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,KAAK,gBAAgB,GAAG;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,UAAU,EAAE,CAAC;IAC3B,MAAM,EAAE,MAAM,CAA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AC,CAAC,CAUhE;AAED,wBAAsB,GAAG,CACvB,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAU3B"}
|
package/package.json
CHANGED
package/src/index.tsx
CHANGED
@@ -99,3 +99,69 @@ export async function resolve(publicKey: string): Promise<Result<IDNSPacket>> {
|
|
99
99
|
return err(JSON.stringify(e));
|
100
100
|
}
|
101
101
|
}
|
102
|
+
|
103
|
+
export async function signUp(
|
104
|
+
secretKey: string,
|
105
|
+
homeserver: string
|
106
|
+
): Promise<Result<string[]>> {
|
107
|
+
try {
|
108
|
+
const res = await Pubky.signUp(secretKey, homeserver);
|
109
|
+
if (res[0] === 'error') {
|
110
|
+
return err(res[1]);
|
111
|
+
}
|
112
|
+
return ok(res[1]);
|
113
|
+
} catch (e) {
|
114
|
+
return err(JSON.stringify(e));
|
115
|
+
}
|
116
|
+
}
|
117
|
+
|
118
|
+
export async function signIn(secretKey: string): Promise<Result<string[]>> {
|
119
|
+
try {
|
120
|
+
const res = await Pubky.signIn(secretKey);
|
121
|
+
if (res[0] === 'error') {
|
122
|
+
return err(res[1]);
|
123
|
+
}
|
124
|
+
return ok(res[1]);
|
125
|
+
} catch (e) {
|
126
|
+
return err(JSON.stringify(e));
|
127
|
+
}
|
128
|
+
}
|
129
|
+
|
130
|
+
export async function signOut(secretKey: string): Promise<Result<string[]>> {
|
131
|
+
try {
|
132
|
+
const res = await Pubky.signOut(secretKey);
|
133
|
+
if (res[0] === 'error') {
|
134
|
+
return err(res[1]);
|
135
|
+
}
|
136
|
+
return ok(res[1]);
|
137
|
+
} catch (e) {
|
138
|
+
return err(JSON.stringify(e));
|
139
|
+
}
|
140
|
+
}
|
141
|
+
|
142
|
+
export async function get(url: string): Promise<Result<string[]>> {
|
143
|
+
try {
|
144
|
+
const res = await Pubky.get(url);
|
145
|
+
if (res[0] === 'error') {
|
146
|
+
return err(res[1]);
|
147
|
+
}
|
148
|
+
return ok(JSON.parse(res[1]));
|
149
|
+
} catch (e) {
|
150
|
+
return err(JSON.stringify(e));
|
151
|
+
}
|
152
|
+
}
|
153
|
+
|
154
|
+
export async function put(
|
155
|
+
url: string,
|
156
|
+
content: Object
|
157
|
+
): Promise<Result<string[]>> {
|
158
|
+
try {
|
159
|
+
const res = await Pubky.put(url, JSON.stringify(content));
|
160
|
+
if (res[0] === 'error') {
|
161
|
+
return err(res[1]);
|
162
|
+
}
|
163
|
+
return ok(res[1]);
|
164
|
+
} catch (e) {
|
165
|
+
return err(JSON.stringify(e));
|
166
|
+
}
|
167
|
+
}
|