@synonymdev/react-native-pubky 0.8.0 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +52 -9
- package/android/src/main/java/com/pubky/PubkyModule.kt +364 -273
- package/android/src/main/java/uniffi/pubkycore/pubkycore.kt +1327 -0
- package/android/src/main/jniLibs/arm64-v8a/libpubkycore.so +0 -0
- package/android/src/main/jniLibs/armeabi-v7a/libpubkycore.so +0 -0
- package/android/src/main/jniLibs/x86/libpubkycore.so +0 -0
- package/android/src/main/jniLibs/x86_64/libpubkycore.so +0 -0
- package/ios/Frameworks/{PubkyMobile.xcframework → PubkyCore.xcframework}/Info.plist +8 -8
- package/ios/Frameworks/{PubkyMobile.xcframework → PubkyCore.xcframework}/ios-arm64/Headers/module.modulemap +2 -2
- package/ios/Frameworks/PubkyCore.xcframework/ios-arm64/Headers/pubkycoreFFI.h +297 -0
- package/ios/Frameworks/{PubkyMobile.xcframework/ios-arm64/libpubkymobile.a → PubkyCore.xcframework/ios-arm64/libpubkycore.a} +0 -0
- package/ios/Frameworks/{PubkyMobile.xcframework → PubkyCore.xcframework}/ios-arm64-simulator/Headers/module.modulemap +2 -2
- package/ios/Frameworks/PubkyCore.xcframework/ios-arm64-simulator/Headers/pubkycoreFFI.h +297 -0
- package/ios/Frameworks/{PubkyMobile.xcframework/ios-arm64-simulator/libpubkymobile.a → PubkyCore.xcframework/ios-arm64-simulator/libpubkycore.a} +0 -0
- package/ios/Pubky-Bridging-Header.h +1 -0
- package/ios/Pubky.mm +16 -1
- package/ios/Pubky.swift +64 -1
- package/ios/{pubkymobile.swift → pubkycore.swift} +354 -37
- package/lib/commonjs/index.js +45 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/index.js +42 -1
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/commonjs/src/index.d.ts +16 -9
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/index.d.ts +16 -9
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/package.json +12 -7
- package/react-native-pubky.podspec +1 -1
- package/src/index.tsx +62 -9
- package/android/src/main/java/uniffi/pubkymobile/pubkymobile.kt +0 -862
- 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/ios-arm64/Headers/mobileFFI.h +0 -188
- package/ios/Frameworks/PubkyMobile.xcframework/ios-arm64/Headers/pubkymobileFFI.h +0 -264
- package/ios/Frameworks/PubkyMobile.xcframework/ios-arm64/libmobile.a +0 -0
- package/ios/Frameworks/PubkyMobile.xcframework/ios-arm64-simulator/Headers/mobileFFI.h +0 -188
- package/ios/Frameworks/PubkyMobile.xcframework/ios-arm64-simulator/Headers/pubkymobileFFI.h +0 -264
- package/ios/Frameworks/PubkyMobile.xcframework/ios-arm64-simulator/libmobile.a +0 -0
@@ -5,306 +5,397 @@ import com.facebook.react.bridge.ReactApplicationContext
|
|
5
5
|
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
6
6
|
import com.facebook.react.bridge.ReactMethod
|
7
7
|
import com.facebook.react.bridge.Promise
|
8
|
+
import com.facebook.react.modules.core.DeviceEventManagerModule
|
8
9
|
import kotlinx.coroutines.CoroutineScope
|
9
10
|
import kotlinx.coroutines.Dispatchers
|
10
11
|
import kotlinx.coroutines.launch
|
11
12
|
import kotlinx.coroutines.withContext
|
12
|
-
import uniffi.
|
13
|
+
import uniffi.pubkycore.*
|
13
14
|
|
14
15
|
class PubkyModule(reactContext: ReactApplicationContext) :
|
15
|
-
|
16
|
+
ReactContextBaseJavaModule(reactContext) {
|
16
17
|
|
17
|
-
|
18
|
-
|
19
|
-
|
18
|
+
override fun getName(): String {
|
19
|
+
return NAME
|
20
|
+
}
|
21
|
+
|
22
|
+
private val eventListener = object : EventListener {
|
23
|
+
override fun onEventOccurred(eventData: String) {
|
24
|
+
reactContext
|
25
|
+
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
26
|
+
.emit("PubkyEvent", eventData)
|
27
|
+
}
|
28
|
+
}
|
29
|
+
|
30
|
+
@ReactMethod
|
31
|
+
fun setEventListener(promise: Promise) {
|
32
|
+
CoroutineScope(Dispatchers.IO).launch {
|
33
|
+
try {
|
34
|
+
setEventListener(eventListener)
|
35
|
+
withContext(Dispatchers.Main) {
|
36
|
+
promise.resolve(null)
|
37
|
+
}
|
38
|
+
} catch (e: Exception) {
|
39
|
+
withContext(Dispatchers.Main) {
|
40
|
+
promise.reject("Error", e.message)
|
41
|
+
}
|
42
|
+
}
|
43
|
+
}
|
44
|
+
}
|
20
45
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
}
|
37
|
-
}
|
38
|
-
}
|
46
|
+
@ReactMethod
|
47
|
+
fun removeEventListener(promise: Promise) {
|
48
|
+
CoroutineScope(Dispatchers.IO).launch {
|
49
|
+
try {
|
50
|
+
removeEventListener()
|
51
|
+
withContext(Dispatchers.Main) {
|
52
|
+
promise.resolve(null)
|
53
|
+
}
|
54
|
+
} catch (e: Exception) {
|
55
|
+
withContext(Dispatchers.Main) {
|
56
|
+
promise.reject("Error", e.message)
|
57
|
+
}
|
58
|
+
}
|
59
|
+
}
|
60
|
+
}
|
39
61
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
62
|
+
@ReactMethod
|
63
|
+
fun deleteFile(url: String, promise: Promise) {
|
64
|
+
CoroutineScope(Dispatchers.IO).launch {
|
65
|
+
try {
|
66
|
+
val result = deleteFile(url)
|
67
|
+
val array = Arguments.createArray().apply {
|
68
|
+
result.forEach { pushString(it) }
|
69
|
+
}
|
70
|
+
withContext(Dispatchers.Main) {
|
71
|
+
promise.resolve(array)
|
72
|
+
}
|
73
|
+
} catch (e: Exception) {
|
74
|
+
withContext(Dispatchers.Main) {
|
75
|
+
promise.reject("Error", e.message)
|
76
|
+
}
|
77
|
+
}
|
78
|
+
}
|
50
79
|
}
|
51
|
-
}
|
52
80
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
81
|
+
@ReactMethod
|
82
|
+
fun session(pubky: String, promise: Promise) {
|
83
|
+
CoroutineScope(Dispatchers.IO).launch {
|
84
|
+
try {
|
85
|
+
val result = session(pubky)
|
86
|
+
val array = Arguments.createArray().apply {
|
87
|
+
result.forEach { pushString(it) }
|
88
|
+
}
|
89
|
+
withContext(Dispatchers.Main) {
|
90
|
+
promise.resolve(array)
|
91
|
+
}
|
92
|
+
} catch (e: Exception) {
|
93
|
+
withContext(Dispatchers.Main) {
|
94
|
+
promise.reject("Error", e.message)
|
95
|
+
}
|
96
|
+
}
|
97
|
+
}
|
98
|
+
}
|
71
99
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
100
|
+
@ReactMethod
|
101
|
+
fun auth(url: String, secretKey: String, promise: Promise) {
|
102
|
+
CoroutineScope(Dispatchers.IO).launch {
|
103
|
+
try {
|
104
|
+
val result = auth(url, secretKey)
|
105
|
+
val array = Arguments.createArray().apply {
|
106
|
+
result.forEach { pushString(it) }
|
107
|
+
}
|
108
|
+
withContext(Dispatchers.Main) {
|
109
|
+
promise.resolve(array)
|
110
|
+
}
|
111
|
+
} catch (e: Exception) {
|
112
|
+
withContext(Dispatchers.Main) {
|
113
|
+
promise.reject("Error", e.message)
|
114
|
+
}
|
115
|
+
}
|
116
|
+
}
|
117
|
+
}
|
118
|
+
|
119
|
+
@ReactMethod
|
120
|
+
fun parseAuthUrl(url: String, promise: Promise) {
|
121
|
+
try {
|
122
|
+
val result = parseAuthUrl(url)
|
123
|
+
val array = Arguments.createArray().apply {
|
124
|
+
result.forEach { pushString(it) }
|
125
|
+
}
|
126
|
+
promise.resolve(array)
|
127
|
+
} catch (e: Exception) {
|
128
|
+
promise.reject("Error", e.message)
|
129
|
+
}
|
130
|
+
}
|
131
|
+
|
132
|
+
@ReactMethod
|
133
|
+
fun publish(recordName: String, recordContent: String, secretKey: String, promise: Promise) {
|
134
|
+
CoroutineScope(Dispatchers.IO).launch {
|
135
|
+
try {
|
136
|
+
val result = publish(recordName, recordContent, secretKey)
|
137
|
+
val array = Arguments.createArray().apply {
|
138
|
+
result.forEach { pushString(it) }
|
139
|
+
}
|
140
|
+
withContext(Dispatchers.Main) {
|
141
|
+
promise.resolve(array)
|
142
|
+
}
|
143
|
+
} catch (e: Exception) {
|
144
|
+
withContext(Dispatchers.Main) {
|
145
|
+
promise.reject("Error", e.message)
|
146
|
+
}
|
147
|
+
}
|
148
|
+
}
|
149
|
+
}
|
150
|
+
|
151
|
+
@ReactMethod
|
152
|
+
fun resolve(publicKey: String, promise: Promise) {
|
153
|
+
CoroutineScope(Dispatchers.IO).launch {
|
154
|
+
try {
|
155
|
+
val result = resolve(publicKey)
|
156
|
+
val array = Arguments.createArray().apply {
|
157
|
+
result.forEach { pushString(it) }
|
158
|
+
}
|
159
|
+
withContext(Dispatchers.Main) {
|
160
|
+
promise.resolve(array)
|
161
|
+
}
|
162
|
+
} catch (e: Exception) {
|
163
|
+
withContext(Dispatchers.Main) {
|
164
|
+
promise.reject("Error", e.message)
|
165
|
+
}
|
166
|
+
}
|
167
|
+
}
|
168
|
+
}
|
90
169
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
170
|
+
@ReactMethod
|
171
|
+
fun signUp(secretKey: String, homeserver: String, promise: Promise) {
|
172
|
+
CoroutineScope(Dispatchers.IO).launch {
|
173
|
+
try {
|
174
|
+
val result = signUp(secretKey, homeserver)
|
175
|
+
val array = Arguments.createArray().apply {
|
176
|
+
result.forEach { pushString(it) }
|
177
|
+
}
|
178
|
+
withContext(Dispatchers.Main) {
|
179
|
+
promise.resolve(array)
|
180
|
+
}
|
181
|
+
} catch (e: Exception) {
|
182
|
+
withContext(Dispatchers.Main) {
|
183
|
+
promise.reject("Error", e.message)
|
184
|
+
}
|
185
|
+
}
|
186
|
+
}
|
187
|
+
}
|
109
188
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
189
|
+
@ReactMethod
|
190
|
+
fun signIn(secretKey: String, promise: Promise) {
|
191
|
+
CoroutineScope(Dispatchers.IO).launch {
|
192
|
+
try {
|
193
|
+
val result = signIn(secretKey)
|
194
|
+
val array = Arguments.createArray().apply {
|
195
|
+
result.forEach { pushString(it) }
|
196
|
+
}
|
197
|
+
withContext(Dispatchers.Main) {
|
198
|
+
promise.resolve(array)
|
199
|
+
}
|
200
|
+
} catch (e: Exception) {
|
201
|
+
withContext(Dispatchers.Main) {
|
202
|
+
promise.reject("Error", e.message)
|
203
|
+
}
|
204
|
+
}
|
205
|
+
}
|
206
|
+
}
|
128
207
|
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
208
|
+
@ReactMethod
|
209
|
+
fun signOut(secretKey: String, promise: Promise) {
|
210
|
+
CoroutineScope(Dispatchers.IO).launch {
|
211
|
+
try {
|
212
|
+
val result = signOut(secretKey)
|
213
|
+
val array = Arguments.createArray().apply {
|
214
|
+
result.forEach { pushString(it) }
|
215
|
+
}
|
216
|
+
withContext(Dispatchers.Main) {
|
217
|
+
promise.resolve(array)
|
218
|
+
}
|
219
|
+
} catch (e: Exception) {
|
220
|
+
withContext(Dispatchers.Main) {
|
221
|
+
promise.reject("Error", e.message)
|
222
|
+
}
|
223
|
+
}
|
224
|
+
}
|
225
|
+
}
|
147
226
|
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
227
|
+
@ReactMethod
|
228
|
+
fun put(url: String, content: String, promise: Promise) {
|
229
|
+
CoroutineScope(Dispatchers.IO).launch {
|
230
|
+
try {
|
231
|
+
val result = put(url, content)
|
232
|
+
val array = Arguments.createArray().apply {
|
233
|
+
result.forEach { pushString(it) }
|
234
|
+
}
|
235
|
+
withContext(Dispatchers.Main) {
|
236
|
+
promise.resolve(array)
|
237
|
+
}
|
238
|
+
} catch (e: Exception) {
|
239
|
+
withContext(Dispatchers.Main) {
|
240
|
+
promise.reject("Error", e.message)
|
241
|
+
}
|
242
|
+
}
|
243
|
+
}
|
244
|
+
}
|
166
245
|
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
246
|
+
@ReactMethod
|
247
|
+
fun get(url: String, promise: Promise) {
|
248
|
+
CoroutineScope(Dispatchers.IO).launch {
|
249
|
+
try {
|
250
|
+
val result = get(url)
|
251
|
+
val array = Arguments.createArray().apply {
|
252
|
+
result.forEach { pushString(it) }
|
253
|
+
}
|
254
|
+
withContext(Dispatchers.Main) {
|
255
|
+
promise.resolve(array)
|
256
|
+
}
|
257
|
+
} catch (e: Exception) {
|
258
|
+
withContext(Dispatchers.Main) {
|
259
|
+
promise.reject("Error", e.message)
|
260
|
+
}
|
261
|
+
}
|
262
|
+
}
|
263
|
+
}
|
185
264
|
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
265
|
+
@ReactMethod
|
266
|
+
fun publishHttps(recordName: String, target: String, secretKey: String, promise: Promise) {
|
267
|
+
CoroutineScope(Dispatchers.IO).launch {
|
268
|
+
try {
|
269
|
+
val result = publishHttps(recordName, target, secretKey)
|
270
|
+
val array = Arguments.createArray().apply {
|
271
|
+
result.forEach { pushString(it) }
|
272
|
+
}
|
273
|
+
withContext(Dispatchers.Main) {
|
274
|
+
promise.resolve(array)
|
275
|
+
}
|
276
|
+
} catch (e: Exception) {
|
277
|
+
withContext(Dispatchers.Main) {
|
278
|
+
promise.reject("Error", e.message)
|
279
|
+
}
|
280
|
+
}
|
281
|
+
}
|
282
|
+
}
|
204
283
|
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
284
|
+
@ReactMethod
|
285
|
+
fun resolveHttps(publicKey: String, promise: Promise) {
|
286
|
+
CoroutineScope(Dispatchers.IO).launch {
|
287
|
+
try {
|
288
|
+
val result = resolveHttps(publicKey)
|
289
|
+
val array = Arguments.createArray().apply {
|
290
|
+
result.forEach { pushString(it) }
|
291
|
+
}
|
292
|
+
withContext(Dispatchers.Main) {
|
293
|
+
promise.resolve(array)
|
294
|
+
}
|
295
|
+
} catch (e: Exception) {
|
296
|
+
withContext(Dispatchers.Main) {
|
297
|
+
promise.reject("Error", e.message)
|
298
|
+
}
|
299
|
+
}
|
300
|
+
}
|
301
|
+
}
|
223
302
|
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
303
|
+
@ReactMethod
|
304
|
+
fun list(url: String, promise: Promise) {
|
305
|
+
CoroutineScope(Dispatchers.IO).launch {
|
306
|
+
try {
|
307
|
+
val result = list(url)
|
308
|
+
val array = Arguments.createArray().apply {
|
309
|
+
result.forEach { pushString(it) }
|
310
|
+
}
|
311
|
+
withContext(Dispatchers.Main) {
|
312
|
+
promise.resolve(array)
|
313
|
+
}
|
314
|
+
} catch (e: Exception) {
|
315
|
+
withContext(Dispatchers.Main) {
|
316
|
+
promise.reject("Error", e.message)
|
317
|
+
}
|
318
|
+
}
|
319
|
+
}
|
320
|
+
}
|
242
321
|
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
322
|
+
@ReactMethod
|
323
|
+
fun generateSecretKey(promise: Promise) {
|
324
|
+
CoroutineScope(Dispatchers.IO).launch {
|
325
|
+
try {
|
326
|
+
val result = generateSecretKey()
|
327
|
+
val array = Arguments.createArray().apply {
|
328
|
+
result.forEach { pushString(it) }
|
329
|
+
}
|
330
|
+
withContext(Dispatchers.Main) {
|
331
|
+
promise.resolve(array)
|
332
|
+
}
|
333
|
+
} catch (e: Exception) {
|
334
|
+
withContext(Dispatchers.Main) {
|
335
|
+
promise.reject("Error", e.message)
|
336
|
+
}
|
337
|
+
}
|
338
|
+
}
|
339
|
+
}
|
261
340
|
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
341
|
+
@ReactMethod
|
342
|
+
fun getPublicKeyFromSecretKey(secretKey: String, promise: Promise) {
|
343
|
+
CoroutineScope(Dispatchers.IO).launch {
|
344
|
+
try {
|
345
|
+
val result = getPublicKeyFromSecretKey(secretKey)
|
346
|
+
val array = Arguments.createArray().apply {
|
347
|
+
result.forEach { pushString(it) }
|
348
|
+
}
|
349
|
+
withContext(Dispatchers.Main) {
|
350
|
+
promise.resolve(array)
|
351
|
+
}
|
352
|
+
} catch (e: Exception) {
|
353
|
+
withContext(Dispatchers.Main) {
|
354
|
+
promise.reject("Error", e.message)
|
355
|
+
}
|
356
|
+
}
|
357
|
+
}
|
358
|
+
}
|
280
359
|
|
281
|
-
@ReactMethod
|
282
|
-
fun createRecoveryFile(secretKey: String, passphrase: String, promise: Promise) {
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
360
|
+
@ReactMethod
|
361
|
+
fun createRecoveryFile(secretKey: String, passphrase: String, promise: Promise) {
|
362
|
+
CoroutineScope(Dispatchers.IO).launch {
|
363
|
+
try {
|
364
|
+
val result = createRecoveryFile(secretKey, passphrase)
|
365
|
+
val array = Arguments.createArray().apply {
|
366
|
+
result.forEach { pushString(it) }
|
367
|
+
}
|
368
|
+
withContext(Dispatchers.Main) {
|
369
|
+
promise.resolve(array)
|
370
|
+
}
|
371
|
+
} catch (e: Exception) {
|
372
|
+
withContext(Dispatchers.Main) {
|
373
|
+
promise.reject("Error", e.message)
|
374
|
+
}
|
375
|
+
}
|
287
376
|
}
|
288
|
-
promise.resolve(array)
|
289
|
-
} catch (e: Exception) {
|
290
|
-
promise.reject("Error", e.message)
|
291
377
|
}
|
292
|
-
}
|
293
378
|
|
294
|
-
@ReactMethod
|
295
|
-
fun decryptRecoveryFile(recoveryFile: String, passphrase: String, promise: Promise) {
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
379
|
+
@ReactMethod
|
380
|
+
fun decryptRecoveryFile(recoveryFile: String, passphrase: String, promise: Promise) {
|
381
|
+
CoroutineScope(Dispatchers.IO).launch {
|
382
|
+
try {
|
383
|
+
val result = decryptRecoveryFile(recoveryFile, passphrase)
|
384
|
+
val array = Arguments.createArray().apply {
|
385
|
+
result.forEach { pushString(it) }
|
386
|
+
}
|
387
|
+
withContext(Dispatchers.Main) {
|
388
|
+
promise.resolve(array)
|
389
|
+
}
|
390
|
+
} catch (e: Exception) {
|
391
|
+
withContext(Dispatchers.Main) {
|
392
|
+
promise.reject("Error", e.message)
|
393
|
+
}
|
394
|
+
}
|
300
395
|
}
|
301
|
-
promise.resolve(array)
|
302
|
-
} catch (e: Exception) {
|
303
|
-
promise.reject("Error", e.message)
|
304
396
|
}
|
305
|
-
}
|
306
397
|
|
307
|
-
|
308
|
-
|
309
|
-
|
398
|
+
companion object {
|
399
|
+
const val NAME = "Pubky"
|
400
|
+
}
|
310
401
|
}
|